From 27d4ba1bdde932efa07837743ebf9a0b2594e1fe Mon Sep 17 00:00:00 2001 From: "Kuleshov, Elena" Date: Tue, 8 Sep 2020 16:45:49 -0400 Subject: Populate serviceInstanceId from instanceMap on Populate serviceInstanceId from instanceMap on validation error. Use Optional for return value for serviceInstanceId assist methods. Issue-ID: SO-3224 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I36a44ae42bb89d621dec5a2f85266458ea0e0766 --- .../apihandlerinfra/RequestHandlerUtilsTest.java | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java') diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java index 7f9ff98b19..2ba646fba0 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/RequestHandlerUtilsTest.java @@ -39,6 +39,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Paths; +import java.util.HashMap; import java.util.List; import javax.ws.rs.core.MediaType; import org.apache.http.HttpStatus; @@ -338,4 +339,34 @@ public class RequestHandlerUtilsTest extends BaseTest { assertEquals(expectedBasicAuth, basicAuth); } + @Test + public void getServiceInstanceIdForValidationErrorTest() { + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + String requestScope = "vnf"; + HashMap instanceIdMap = new HashMap(); + instanceIdMap.put("serviceInstanceId", "testServiceInstanceId"); + String serviceInstanceId = + requestHandlerUtils.getServiceInstanceIdForValidationError(sir, instanceIdMap, requestScope).get(); + assertEquals("testServiceInstanceId", serviceInstanceId); + } + + @Test + public void getServiceInstanceIdForValidationErrorInstanceGroupTest() throws Exception { + ServiceInstancesRequest sir = + mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class); + String requestScope = "instanceGroup"; + String serviceInstanceId = + requestHandlerUtils.getServiceInstanceIdForValidationError(sir, null, requestScope).get(); + assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", serviceInstanceId); + } + + @Test + public void getServiceInstanceIdForInstanceGroupTest() throws Exception { + ServiceInstancesRequest sir = + mapper.readValue(inputStream("/CreateInstanceGroup.json"), ServiceInstancesRequest.class); + String requestScope = "instanceGroup"; + String serviceInstanceId = requestHandlerUtils.getServiceInstanceIdForInstanceGroup(requestScope, sir).get(); + assertEquals("ddcbbf3d-f2c1-4ca0-8852-76a807285efc", serviceInstanceId); + } + } -- cgit 1.2.3-korg