From 9685aca488284d484adc11bc260dd2c451dfff43 Mon Sep 17 00:00:00 2001 From: Arthur Martella Date: Fri, 6 Oct 2017 11:45:32 -0400 Subject: MSO API Handler Test cases Adding test cases for MSO API Handler coverage. Change-Id: Ie4a3fc86395b9010357fb7027178933ff73150cc Issue-ID: SO-171 Signed-off-by: Arthur Martella --- .../GlobalHealthcheckHandlerTest.java | 60 +++++ .../apihandlerinfra/OrchestrationRequestsTest.java | 260 ++++++++++++++++----- .../apihandlerinfra/RecipeLookupResultTest.java | 96 ++++++++ .../mso/apihandlerinfra/ServiceInstancesTest.java | 146 ++++++++++++ .../taskbeans/RequestDetailsTest.java | 74 ++++++ .../apihandlerinfra/taskbeans/RequestInfoTest.java | 120 ++++++++++ .../apihandlerinfra/taskbeans/TaskListTest.java | 247 ++++++++++++++++++++ .../taskbeans/TaskRequestReferenceTest.java | 72 ++++++ .../taskbeans/TaskVariableValueTest.java | 114 +++++++++ .../taskbeans/TaskVariablesTest.java | 71 ++++++ .../taskbeans/TasksGetResponseTest.java | 71 ++++++ .../taskbeans/TasksRequestTest.java | 72 ++++++ .../mso/apihandlerinfra/taskbeans/ValueTest.java | 69 ++++++ .../apihandlerinfra/taskbeans/VariablesTest.java | 97 ++++++++ 14 files changed, 1510 insertions(+), 59 deletions(-) create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java create mode 100644 mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java (limited to 'mso-api-handlers/mso-api-handler-infra/src/test/java/org') diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java new file mode 100644 index 0000000000..5502d38268 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/GlobalHealthcheckHandlerTest.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra; + +import static org.junit.Assert.*; + +import javax.ws.rs.core.Response; + +import org.apache.http.HttpStatus; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.MsoStatusUtil; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class GlobalHealthcheckHandlerTest { + + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + private static final String CHECK_HTML = "Health CheckApplication ready"; + public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + + @Test + public final void testGlobalHealthcheck() { + try { + MsoStatusUtil statusUtil = Mockito.mock(MsoStatusUtil.class); + HealthCheckUtils utils = Mockito.mock(HealthCheckUtils.class); + Mockito.when(utils.verifyGlobalHealthCheck(true, null)).thenReturn(true); + Mockito.when(statusUtil.getSiteStatus(Mockito.anyString())).thenReturn(true); + GlobalHealthcheckHandler gh = Mockito.mock(GlobalHealthcheckHandler.class); + Mockito.when(gh.globalHealthcheck(Mockito.anyBoolean())).thenReturn(HEALTH_CHECK_RESPONSE); + Response resp = gh.globalHealthcheck(true); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java index 82eb8d4a60..552d765602 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/OrchestrationRequestsTest.java @@ -1,59 +1,201 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.mso.apihandlerinfra; - -import static org.junit.Assert.assertTrue; - -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - -import org.junit.Test; -import org.mockito.Mockito; - -public class OrchestrationRequestsTest { - - OrchestrationRequests req = new OrchestrationRequests(); - - @Test - public void getOrchestrationRequestTest(){ - Response resp = req.getOrchestrationRequest("1001", "v3"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getE2EServiceInstancesTest(){ - Response resp = req.getE2EServiceInstances("1001", "v3","599934"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void getOrchestrationRequest2Test(){ - UriInfo uriInfo = Mockito.mock(UriInfo.class); - Response resp = req.getOrchestrationRequest(uriInfo, "v3"); - assertTrue(resp.getEntity().toString() != null); - } - - @Test - public void unlockOrchestrationRequestTest(){ - Response resp = req.unlockOrchestrationRequest("{\"result\":\"success\"}","1001", "v3"); - assertTrue(resp.getEntity().toString() != null); - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.apihandlerinfra; + +import static org.junit.Assert.assertEquals; + +import static org.junit.Assert.assertFalse; +import java.io.IOException; +import javax.ws.rs.core.Response; + +import org.apache.http.HttpStatus; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.requestsdb.RequestsDatabase; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; + +public class OrchestrationRequestsTest { + + private static final String CHECK_HTML = ""; + public static final Response RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + @Mock + private static RequestsDatabase db; + private static OrchestrationRequests orReq; + private static GetOrchestrationResponse orRes; + + @Test + public void testGetOrchestrationRequest() { + orReq = Mockito.mock(OrchestrationRequests.class); + orRes = new GetOrchestrationResponse(); + try { + // create InfraActiveRequests object + InfraActiveRequests infraRequests = new InfraActiveRequests(); + infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333"); + infraRequests.setNetworkType("CONTRAIL30_BASIC"); + infraRequests.setRequestType("createInstance"); + infraRequests.setSource("VID"); + infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682"); + infraRequests.setServiceInstanceId("bc305d54-75b4-431b-adb2-eb6b9e546014"); + infraRequests.setRequestStatus("IN_PROGRESS"); + infraRequests.setRequestorId("ab1234"); + String body = "{\"modelInfo\":{\"modelInvariantId\":\"9771b085-4705-4bf7-815d-8c0627bb7e36\",\"modelType\":\"service\",\"modelName\":\"Service with VNFs with modules\",\"modelVersion\":\"1.0\"}}"; + infraRequests.setRequestBody(body); + + db = Mockito.mock(RequestsDatabase.class); + Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests); + + ///// mock mapInfraActiveRequestToRequest() + Request request = new Request(); + request.setRequestId(infraRequests.getRequestId()); + request.setRequestScope(infraRequests.getRequestScope()); + request.setRequestType(infraRequests.getRequestAction()); + + InstanceReferences ir = new InstanceReferences(); + if (infraRequests.getNetworkId() != null) + ir.setNetworkInstanceId(infraRequests.getNetworkId()); + if (infraRequests.getNetworkName() != null) + ir.setNetworkInstanceName(infraRequests.getNetworkName()); + if (infraRequests.getServiceInstanceId() != null) + ir.setServiceInstanceId(infraRequests.getServiceInstanceId()); + if (infraRequests.getServiceInstanceName() != null) + ir.setServiceInstanceName(infraRequests.getServiceInstanceName()); + if (infraRequests.getVfModuleId() != null) + ir.setVfModuleInstanceId(infraRequests.getVfModuleId()); + if (infraRequests.getVfModuleName() != null) + ir.setVfModuleInstanceName(infraRequests.getVfModuleName()); + if (infraRequests.getVnfId() != null) + ir.setVnfInstanceId(infraRequests.getVnfId()); + if (infraRequests.getVnfName() != null) + ir.setVnfInstanceName(infraRequests.getVnfName()); + if (infraRequests.getVolumeGroupId() != null) + ir.setVolumeGroupInstanceId(infraRequests.getVolumeGroupId()); + if (infraRequests.getVolumeGroupName() != null) + ir.setVolumeGroupInstanceName(infraRequests.getVolumeGroupName()); + if (infraRequests.getRequestorId() != null) + ir.setRequestorId(infraRequests.getRequestorId()); + + request.setInstanceReferences(ir); + RequestStatus status = new RequestStatus(); + + if (infraRequests.getRequestStatus() != null) { + status.setRequestState(infraRequests.getRequestStatus()); + } + + request.setRequestStatus(status); + // RequestStatus reqStatus = request.getRequestStatus(); + orRes.setRequest(request); + Mockito.when(orReq.getOrchestrationRequest(Mockito.anyString(), Mockito.anyString())).thenReturn(RESPONSE); + Response resp = orReq.getOrchestrationRequest("rq1234d1-5a33-55df-13ab-12abad84e333", "v3"); + + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestId(), + "rq1234d1-5a33-55df-13ab-12abad84e333"); + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getSource(), "VID"); + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getTenantId(), + "19123c2924c648eb8e42a3c1f14b7682"); + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getServiceInstanceId(), + "bc305d54-75b4-431b-adb2-eb6b9e546014"); + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestStatus(), + "IN_PROGRESS"); + assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestorId(), + "ab1234"); + assertEquals(request.getInstanceReferences().getServiceInstanceId(),"bc305d54-75b4-431b-adb2-eb6b9e546014"); + assertEquals(request.getInstanceReferences().getRequestorId(),"ab1234"); + assertEquals(orRes.getRequest().getRequestId(), "rq1234d1-5a33-55df-13ab-12abad84e333"); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Test + public void testGetOrchestrationRequestNotPresent() { + orReq = Mockito.mock(OrchestrationRequests.class); + orRes = new GetOrchestrationResponse(); + try { + // create InfraActiveRequests object + InfraActiveRequests infraRequests = Mockito.mock(InfraActiveRequests.class); + db = Mockito.mock(RequestsDatabase.class); + Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests); + + Request request = new Request(); + RequestStatus status = new RequestStatus(); + request.setRequestStatus(status); + orRes.setRequest(request); + assertFalse("rq1234d1-5a33-55df-13ab-12abad84e333".equalsIgnoreCase(orRes.getRequest().getRequestId())); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Test + public void testUnlockOrchestrationRequest() + throws JsonParseException, JsonMappingException, IOException, ValidationException { + ObjectMapper mapper = new ObjectMapper(); + String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"ab1234\"}}}"; + + MsoRequest msoRequest = new MsoRequest("rq1234d1-5a33-55df-13ab-12abad84e333"); + ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); + msoRequest.parseOrchestration(sir); + + //create object instead of a DB call. + InfraActiveRequests infraRequests = new InfraActiveRequests(); + infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333"); + infraRequests.setNetworkType("CONTRAIL30_BASIC"); + infraRequests.setSource("VID"); + infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682"); + infraRequests.setServiceInstanceId("ea4d5374-d28d-4bbf-9691-22985f088b12"); + infraRequests.setRequestStatus("IN-PROGRESS"); + + db = Mockito.mock(RequestsDatabase.class); + Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests); + + Request request = new Request(); + InstanceReferences ir = new InstanceReferences(); + request.setInstanceReferences(ir); + RequestStatus status = new RequestStatus(); + + if (infraRequests.getRequestStatus() != null) { + status.setRequestState(infraRequests.getRequestStatus()); + } + request.setRequestStatus(status); + RequestStatus reqStatus = request.getRequestStatus(); + + assertEquals(reqStatus.getRequestState(),"IN-PROGRESS"); + + if (reqStatus.getRequestState().equalsIgnoreCase("IN-PROGRESS")){ + reqStatus.setRequestState(Status.UNLOCKED.toString ()); + } + assertEquals(reqStatus.getRequestState(),"UNLOCKED"); + + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java new file mode 100644 index 0000000000..3bc2edf8e2 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/RecipeLookupResultTest.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra; + +import org.junit.After; +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + + + +public class RecipeLookupResultTest { + + RecipeLookupResult instance; + + public RecipeLookupResultTest() { + } + + @Before + public void setUp() { + instance = mock(RecipeLookupResult.class); + } + + @After + public void tearDown() { + instance = null; + } + + /** + * Test of getOrchestrationURI method + */ + @Test + public void testGetOrchestrationURI() { + String expResult = "orchestrationURI"; + when(instance.getOrchestrationURI()).thenReturn(expResult); + String result = instance.getOrchestrationURI(); + assertEquals(expResult, result); + } + + + /** + * Test of setOrchestrationURI method. + */ + @Test + public void testSetOrchestrationURI() { + String orchestrationUri = "orchestrationURI"; + instance.setOrchestrationURI(orchestrationUri); + verify(instance).setOrchestrationURI(orchestrationUri); + } + + /** + * Test of getRecipeTimeout method + */ + @Test + public void testGetRecipeTimeout() { + int expResult = 10; + when(instance.getRecipeTimeout()).thenReturn(expResult); + int result = instance.getRecipeTimeout(); + assertEquals(expResult, result); + } + + + /** + * Test of setRecipeTimeout method. + */ + @Test + public void testSetRecipeTimeout() { + int recipeTimeOut = 10; + instance.setRecipeTimeout(recipeTimeOut); + verify(instance).setRecipeTimeout(10); + } + + +} + \ No newline at end of file diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java new file mode 100644 index 0000000000..5f93db3012 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/ServiceInstancesTest.java @@ -0,0 +1,146 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.openecomp.mso.apihandlerinfra; + +import static org.junit.Assert.assertEquals; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.HashMap; + +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +import org.apache.commons.io.IOUtils; +import org.apache.http.HttpStatus; +import org.codehaus.jackson.JsonParseException; +import org.codehaus.jackson.map.JsonMappingException; +import org.codehaus.jackson.map.ObjectMapper; +import org.junit.Test; +import org.mockito.Mockito; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.apihandler.common.ValidationException; +import org.openecomp.mso.requestsdb.InfraActiveRequests; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request; +import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest; + +public class ServiceInstancesTest { + + private static final String requestJSONCreate = "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\", " + + "\"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\"," + + " \"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", \"modelName\": \"Test\"," + + " \"modelVersion\": \"1.0\" }, \"cloudConfiguration\": " + + "{ \"lcpCloudRegionId\": \"mdt1\", \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" }," + + " \"subscriberInfo\": { \"globalSubscriberId\": \"{some subscriber id}\"," + + " \"subscriberName\": \"{some subscriber name}\" }," + + " \"requestInfo\": { \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + + "\"source\": \"VID\", \"suppressRollback\": true, \"requestorId\": \"az2016\" }," + + " \"requestParameters\": { \"subscriptionServiceType\": \"MOG\", \"aLaCarte\": false," + + " \"userParams\": [ { \"name\": \"someUserParam\", \"value\": \"someValue\" } ] } } } "; + + private static final String requestJSONActivateDeacivate = + "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\"," + + " \"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\", " + + "\"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", " + + "\"modelName\": \"Test\", \"modelVersion\": \"1.0\" }, " + + "\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"az2016\" }, " + + "\"requestParameters\": { \"userParams\": [ { \"name\": \"aic_zone\", " + + "\"value\": \"someValue\" } ] } } } "; + + private static final String requestJSONDelete = + "{ \"requestDetails\": { \"modelInfo\": { \"modelType\":\"network\", " + + "\"modelName\":\"CONTRAIL30_BASIC\" }, \"cloudConfiguration\": { \"lcpCloudRegionId\":\"mdt1\", " + + "\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\" }, " + + "\"requestInfo\": { \"source\":\"VID\", \"requestorId\":\"az2016\" } } }"; + + @Test + public void testCreateServiceInstance() + throws JsonParseException, JsonMappingException, IOException, ValidationException { + final String CHECK_HTML = ""; + final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + + try { + ServiceInstances sir = Mockito.mock(ServiceInstances.class); + sir.createServiceInstance(requestJSONCreate, "v3"); + Mockito.when(sir.createServiceInstance(requestJSONCreate, "v3")).thenReturn(SERVICE_RESPONSE); + Response resp = sir.createServiceInstance(requestJSONCreate, "v3"); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Test + public void testActivateServiceInstance() + throws JsonParseException, JsonMappingException, IOException, ValidationException { + final String CHECK_HTML = ""; + final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + try { + ServiceInstances sir = Mockito.mock(ServiceInstances.class); + Mockito.when(sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc")) + .thenReturn(SERVICE_RESPONSE); + Response resp = sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Test + public void testDeactivateServiceInstance() + throws JsonParseException, JsonMappingException, IOException, ValidationException { + final String CHECK_HTML = ""; + final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + try { + ServiceInstances sir = Mockito.mock(ServiceInstances.class); + Mockito.when(sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc")) + .thenReturn(SERVICE_RESPONSE); + Response resp = sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } + + @Test + public void testDeleteServiceInstance() + throws JsonParseException, JsonMappingException, IOException, ValidationException { + final String CHECK_HTML = "Health CheckApplication ready"; + final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build(); + try { + ServiceInstances sir = Mockito.mock(ServiceInstances.class); + Mockito.when(sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc")) + .thenReturn(SERVICE_RESPONSE); + Response resp = sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"); + assertEquals(resp.getStatus(), HttpStatus.SC_OK); + } catch (Exception e) { + + e.printStackTrace(); + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java new file mode 100644 index 0000000000..f257ca7a80 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestDetailsTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; +import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails; +import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo; + + + +public class RequestDetailsTest { + + RequestDetails _requestDetails; + RequestInfo _requestInfo; + + public RequestDetailsTest() { + } + + @Before + public void setUp() { + _requestDetails = mock(RequestDetails.class); + _requestInfo = new RequestInfo(); + when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo); + } + + @After + public void tearDown() { + _requestDetails = null; + _requestInfo = null; + } + + /** + * Test of getRequestInfo method + */ + @Test + public void testGetRequestInfo() { + _requestDetails.setRequestInfo(_requestInfo); + assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo)); + + } + + /** + * Test setRequestInfo + */ + @Test + public void testSetRequestInfo() { + _requestDetails.setRequestInfo(_requestInfo); + verify(_requestDetails).setRequestInfo(_requestInfo); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java new file mode 100644 index 0000000000..3ff389124a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/RequestInfoTest.java @@ -0,0 +1,120 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo; +import org.openecomp.mso.apihandlerinfra.tasksbeans.ValidResponses; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class RequestInfoTest { + + RequestInfo _requestInfo; + String _source; + ValidResponses _responseValue; + String _requestorId; + + public RequestInfoTest() { + } + + @Before + public void setUp() { + _requestInfo = mock(RequestInfo.class); + _responseValue = ValidResponses.abort; + _requestorId = "ab1234"; + _source = "VID"; + when(_requestInfo.getRequestorId()).thenReturn(_requestorId); + when(_requestInfo.getSource()).thenReturn(_source); + when(_requestInfo.getResponseValue()).thenReturn(_responseValue); + + } + + @After + public void tearDown() { + _requestInfo = null; + _responseValue = null; + } + + /** + * Test of getSource method + */ + @Test + public void testGetSource() { + String result = _requestInfo.getSource(); + assertEquals(_source, result); + + } + + /** + * Test setSource + */ + @Test + public void testSetSource() { + _requestInfo.setSource("VID"); + verify(_requestInfo).setSource(_source); + } + + /** + * Test of getRequestorId method + */ + @Test + public void testGetRequestorId() { + String result = _requestInfo.getRequestorId(); + assertEquals(_requestorId, result); + + } + + /** + * Test setRequestInfo + */ + @Test + public void testSetRequestorId() { + _requestInfo.setRequestorId(_requestorId); + verify(_requestInfo).setRequestorId(_requestorId); + } + + + /** + * Test of getResponseValue method + */ + @Test + public void testGetResponseValue() { + ValidResponses result = _requestInfo.getResponseValue(); + assertEquals(_responseValue, result); + + } + + /** + * Test setResponseValues method + */ + @Test + public void testSetResponseValue() { + _requestInfo.setResponseValue(ValidResponses.abort); + verify(_requestInfo).setResponseValue(_responseValue); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java new file mode 100644 index 0000000000..293278955a --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskListTest.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.json.JSONArray; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList; + +public class TaskListTest { + + TaskList _taskList; + protected String _taskId; + protected String _type; + protected String _nfRole; + protected String _subscriptionServiceType; + protected String _originalRequestId; + protected String _originalRequestorId; + protected String _errorSource; + protected String _errorCode; + protected String _errorMessage; + protected String _buildingBlockName; + protected String _buildingBlockStep; + protected JSONArray _validResponses; + + public TaskListTest() { + } + + @Before + public void setUp() { + _taskList = mock(TaskList.class); + _taskId = "_taskid"; + _type = "type"; + _nfRole = "nfrole"; + _subscriptionServiceType = "subscriptionservicetype"; + _originalRequestId = "originalrequestid"; + _originalRequestorId = "originalrequestorid"; + _errorSource = "errorsource"; + _errorCode = "errorcode"; + _errorMessage = "errormessage"; + _buildingBlockName = "buildingblockname"; + _buildingBlockStep = "buildingblockstep"; + _validResponses = mock(JSONArray.class); + + when(_taskList.getTaskId()).thenReturn(_taskId); + when(_taskList.getType()).thenReturn(_type); + when(_taskList.getNfRole()).thenReturn(_nfRole); + when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType); + when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId); + when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId); + when(_taskList.getErrorSource()).thenReturn(_errorSource); + when(_taskList.getErrorCode()).thenReturn(_errorCode); + when(_taskList.getErrorMessage()).thenReturn(_errorMessage); + when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName); + when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep); + when(_taskList.getValidResponses()).thenReturn(_validResponses); + } + + @After + public void tearDown() { + _taskList = null; + _validResponses = null; + } + + @Test + public void testGetTaskId() { + String result = _taskList.getTaskId(); + assertEquals(_taskId, result); + + } + + @Test + public void testSetTaskId() { + _taskList.setTaskId("_taskid"); + verify(_taskList).setTaskId(_taskId); + } + + @Test + public void testGetType() { + String result = _taskList.getType(); + assertEquals(_type, result); + + } + + @Test + public void testSetType() { + _taskList.setType(_type); + verify(_taskList).setType(_type); + } + + @Test + public void testGetNfRole() { + String result = _taskList.getNfRole(); + assertEquals(_nfRole, result); + + } + + @Test + public void testSetNfRole() { + _taskList.setType(_nfRole); + verify(_taskList).setType(_nfRole); + } + + @Test + public void testGetSubscriptionServiceType() { + String result = _taskList.getSubscriptionServiceType(); + assertEquals(_subscriptionServiceType, result); + + } + + @Test + public void testSetSubscriptionServiceType() { + _taskList.setSubscriptionServiceType(_subscriptionServiceType); + verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType); + } + + @Test + public void testGetOriginalRequestId() { + String result = _taskList.getOriginalRequestId(); + assertEquals(_originalRequestId, result); + + } + + @Test + public void testSetOriginalRequestId() { + _taskList.setOriginalRequestId(_originalRequestId); + verify(_taskList).setOriginalRequestId(_originalRequestId); + } + + @Test + public void testGetOriginalRequestorId() { + String result = _taskList.getOriginalRequestorId(); + assertEquals(_originalRequestorId, result); + + } + + @Test + public void testSetOriginalRequestorId() { + _taskList.setOriginalRequestorId(_originalRequestorId); + verify(_taskList).setOriginalRequestorId(_originalRequestorId); + } + + @Test + public void testGetErrorSource() { + String result = _taskList.getErrorSource(); + assertEquals(_errorSource, result); + + } + + @Test + public void testSetErrorSource() { + _taskList.setErrorSource(_errorSource); + verify(_taskList).setErrorSource(_errorSource); + } + + @Test + public void testGetErrorCode() { + String result = _taskList.getErrorCode(); + assertEquals(_errorCode, result); + + } + + @Test + public void testSetErrorCode() { + _taskList.setErrorCode(_errorCode); + verify(_taskList).setErrorCode(_errorCode); + } + + @Test + public void testGetErrorMessage() { + String result = _taskList.getErrorMessage(); + assertEquals(_errorMessage, result); + + } + + @Test + public void testSetErrorMessage() { + _taskList.setErrorMessage(_errorMessage); + verify(_taskList).setErrorMessage(_errorMessage); + } + + @Test + public void testGetBuildingBlockName() { + String result = _taskList.getBuildingBlockName(); + assertEquals(_buildingBlockName, result); + + } + + @Test + public void testSetBuildingBlockName() { + _taskList.setBuildingBlockName(_buildingBlockName); + verify(_taskList).setBuildingBlockName(_buildingBlockName); + } + + @Test + public void testGetBuildingBlockStep() { + String result = _taskList.getBuildingBlockStep(); + assertEquals(_buildingBlockStep, result); + + } + + @Test + public void testSetBuildingBlockStep() { + _taskList.setBuildingBlockStep(_buildingBlockStep); + verify(_taskList).setBuildingBlockStep(_buildingBlockStep); + } + + @Test + public void testGetValidResponses() { + + JSONArray result = _taskList.getValidResponses(); + assertEquals(_validResponses, result); + + } + + @Test + public void testSetValidResponses() { + _taskList.setValidResponses(_validResponses); + verify(_taskList).setValidResponses(_validResponses); + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java new file mode 100644 index 0000000000..ec45592704 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskRequestReferenceTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskRequestReference; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class TaskRequestReferenceTest { + + TaskRequestReference _taskRequestReference; + + protected String _taskId; + public TaskRequestReferenceTest() { + } + + @Before + public void setUp() { + _taskRequestReference = mock(TaskRequestReference.class); + _taskId = "taskid"; + + when(_taskRequestReference.getTaskId()).thenReturn(_taskId); + } + + @After + public void tearDown() { + _taskRequestReference = null; + } + + /** + * Test getTaskRequestReference + */ + @Test + public void taskGetRequestReference() { + String result = _taskRequestReference.getTaskId(); + assertEquals(_taskId, result); + } + + /** + * Test setTaskRequestReference + */ + @Test + public void testSetRequestInfo() { + _taskRequestReference.setTaskId(_taskId); + verify(_taskRequestReference).setTaskId(_taskId); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java new file mode 100644 index 0000000000..b593036556 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariableValueTest.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue; + +public class TaskVariableValueTest { + TaskVariableValue _taskVariableValue; + protected String _name; + protected String _value; + protected String _operator; + + public TaskVariableValueTest() { + } + + @Before + public void setUp() { + _taskVariableValue = mock(TaskVariableValue.class); + _name = "name"; + _value = "value"; + _operator = "operator"; + when(_taskVariableValue.getName()).thenReturn(_name); + when(_taskVariableValue.getValue()).thenReturn(_value); + when(_taskVariableValue.getOperator()).thenReturn(_operator); + } + + @After + public void tearDown() { + _taskVariableValue = null; + } + + /** + * Test of getName method + */ + @Test + public void testGetName() { + _taskVariableValue.setName(_name); + assertEquals(_taskVariableValue.getName(),_name); + + } + + /** + * Test setName + */ + @Test + public void testSetName() { + _taskVariableValue.setName(_name); + verify(_taskVariableValue).setName(_name); + } + + /** + * Test of getName method + */ + @Test + public void testGetValue() { + _taskVariableValue.setValue(_value); + assertEquals(_taskVariableValue.getValue(),_value); + + } + + /** + * Test setName + */ + @Test + public void testSetValue() { + _taskVariableValue.setValue(_value); + verify(_taskVariableValue).setValue(_value); + } + + /** + * Test of getName method + */ + @Test + public void testGetOperator() { + _taskVariableValue.setOperator(_operator); + assertEquals(_taskVariableValue.getOperator(),_operator); + + } + + /** + * Test setName + */ + @Test + public void testSetRequestDetails() { + _taskVariableValue.setOperator(_operator); + verify(_taskVariableValue).setOperator(_operator); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java new file mode 100644 index 0000000000..b08729b0ff --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TaskVariablesTest.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariables; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; + +public class TaskVariablesTest { + + TaskVariables _taskVariables; + private List _taskVariableValueList; + + public TaskVariablesTest() { + } + + @SuppressWarnings("unchecked") + @Before + public void setUp() { + _taskVariables = mock(TaskVariables.class); + _taskVariableValueList = mock(List.class); + when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList); + } + + @After + public void tearDown() { + _taskVariables = null; + } + + @Test + public void testGetTaskVariables() { + List result = _taskVariables.getTaskVariables(); + assertEquals(_taskVariableValueList, result); + + } + + @Test + public void testSetTaskVariables() { + _taskVariables.setTaskVariables(_taskVariableValueList); + verify(_taskVariables).setTaskVariables(_taskVariableValueList); + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java new file mode 100644 index 0000000000..eeb745d3bf --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksGetResponseTest.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; + +import static org.junit.Assert.assertEquals; +import org.junit.Before; +import org.junit.Test; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksGetResponse; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.List; + +public class TasksGetResponseTest { + + TasksGetResponse _tasksGetResponse; + private List _taskList; + + public TasksGetResponseTest() { + } + + @SuppressWarnings("unchecked") + @Before + public void setUp() { + _tasksGetResponse = mock(TasksGetResponse.class); + _taskList = mock(List.class); + when(_tasksGetResponse.getTaskList()).thenReturn(_taskList); + } + + @After + public void tearDown() { + _tasksGetResponse = null; + } + + @Test + public void testGetTaskList() { + List result = _tasksGetResponse.getTaskList(); + assertEquals(_taskList, result); + + } + + @Test + public void testSetTaskList() { + _tasksGetResponse.setTaskList(_taskList); + verify(_tasksGetResponse).setTaskList(_taskList); + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java new file mode 100644 index 0000000000..8bfdb645d7 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/TasksRequestTest.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; +import static org.junit.Assert.assertTrue; +import org.junit.Before; +import org.junit.Test; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails; +import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksRequest; + + +public class TasksRequestTest { + TasksRequest _tasksRequest; + private RequestDetails _requestDetails; + + public TasksRequestTest() { + } + + @Before + public void setUp() { + _tasksRequest = mock(TasksRequest.class); + _requestDetails = new RequestDetails(); + when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails); + } + + @After + public void tearDown() { + _tasksRequest = null; + } + + /** + * Test of getRequestDetails method + */ + @Test + public void testGetRequestDetails() { + _tasksRequest.setRequestDetails(_requestDetails); + assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails)); + + } + + /** + * Test setRequestDetails + */ + @Test + public void testSetRequestDetails() { + _tasksRequest.setRequestDetails(_requestDetails); + verify(_tasksRequest).setRequestDetails(_requestDetails); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java new file mode 100644 index 0000000000..41b43c06d8 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/ValueTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.openecomp.mso.apihandlerinfra.tasksbeans.Value; + +public class ValueTest { + Value _valueInstance; + protected String _value; + + public ValueTest() { + } + + @Before + public void setUp() { + _valueInstance = mock(Value.class); + _value = "_value"; + when(_valueInstance.getValue()).thenReturn(_value); + } + + @After + public void tearDown() { + _valueInstance = null; + } + + /** + * Test of getValue method + */ + @Test + public void testGetValue() { + _valueInstance.setValue(_value); + assertEquals(_valueInstance.getValue(),_value); + + } + + /** + * Test setValue + */ + @Test + public void testSetValue() { + _valueInstance.setValue(_value); + verify(_valueInstance).setValue(_value); + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java new file mode 100644 index 0000000000..fdfd5a16bc --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/taskbeans/VariablesTest.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.apihandlerinfra.taskbeans; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import org.openecomp.mso.apihandlerinfra.tasksbeans.Variables; +import org.openecomp.mso.apihandlerinfra.tasksbeans.Value; + +public class VariablesTest { + + Variables _variables; + protected Value _source; + protected Value _responseValue; + protected Value _requestorId; + + @Before + public void setUp() { + _variables = mock(Variables.class); + _source = mock(Value.class); + _responseValue = mock(Value.class); + _requestorId = mock(Value.class); + + when(_variables.getSource()).thenReturn(_source); + when(_variables.getRequestorId()).thenReturn(_requestorId); + when(_variables.getResponseValue()).thenReturn(_responseValue); + + } + + @After + public void tearDown() { + _variables = null; + _source = null; + _responseValue = null; + _requestorId = null; + } + + @Test + public void testGetSource() { + _variables.setSource(_source); + assertTrue(_variables.getSource().equals(_source)); + } + + @Test + public void testSetSource(){ + _variables.setSource(_source); + verify(_variables).setSource(_source); + } + + @Test + public void testGetResponseValue() { + _variables.setResponseValue(_responseValue); + assertTrue(_variables.getResponseValue().equals(_responseValue)); + } + + @Test + public void testSetResponseValue(){ + _variables.setResponseValue(_responseValue); + verify(_variables).setResponseValue(_responseValue); + } + + @Test + public void testGetRequestorId() { + _variables.setRequestorId(_requestorId); + assertTrue(_variables.getRequestorId().equals(_requestorId)); + } + + @Test + public void testSetRequestorId(){ + _variables.setRequestorId(_requestorId); + verify(_variables).setRequestorId(_requestorId); + } + +} -- cgit 1.2.3-korg