[FINERACT-1678] Fix Job API with empty request body
This commit is contained in:
committed by
Arnold Gálovics
parent
856c47398d
commit
b7f88d1196
+2
-1
@@ -27,6 +27,7 @@ import java.util.HashSet;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.apache.fineract.infrastructure.jobs.data.JobParameterDTO;
|
import org.apache.fineract.infrastructure.jobs.data.JobParameterDTO;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@@ -38,7 +39,7 @@ public class JobParameterDataParser {
|
|||||||
private final FromJsonHelper jsonHelper;
|
private final FromJsonHelper jsonHelper;
|
||||||
|
|
||||||
public Set<JobParameterDTO> parseExecution(String requestBody) {
|
public Set<JobParameterDTO> parseExecution(String requestBody) {
|
||||||
if (Objects.isNull(requestBody)) {
|
if (StringUtils.isBlank(requestBody)) {
|
||||||
return Collections.emptySet();
|
return Collections.emptySet();
|
||||||
}
|
}
|
||||||
JsonObject element = JsonParser.parseString(requestBody).getAsJsonObject();
|
JsonObject element = JsonParser.parseString(requestBody).getAsJsonObject();
|
||||||
|
|||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
package org.apache.fineract.infrastructure.jobs.service;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.mockito.junit.jupiter.MockitoSettings;
|
||||||
|
import org.mockito.quality.Strictness;
|
||||||
|
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
@MockitoSettings(strictness = Strictness.LENIENT)
|
||||||
|
class JobParameterDataParserTest {
|
||||||
|
|
||||||
|
@InjectMocks
|
||||||
|
private JobParameterDataParser testObj;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldParserReturnsWithEmptyListWhenRequestBodyIsNull() {
|
||||||
|
assertEquals(Collections.emptySet(), testObj.parseExecution(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldParserReturnsWithEmptyListWhenRequestBodyIsEmptyString() {
|
||||||
|
assertEquals(Collections.emptySet(), testObj.parseExecution(""));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user