Adding test cases for MSO API Handler coverage.
Change-Id: Ie4a3fc86395b9010357fb7027178933ff73150cc
Issue-ID: SO-171
Signed-off-by: Arthur Martella <amartell@research.att.com>
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.apache.http.HttpStatus;\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mockito;\r
+import org.openecomp.mso.HealthCheckUtils;\r
+import org.openecomp.mso.MsoStatusUtil;\r
+import org.openecomp.mso.logger.MsoLogger;\r
+import org.openecomp.mso.properties.MsoJavaProperties;\r
+import org.openecomp.mso.properties.MsoPropertiesFactory;\r
+\r
+public class GlobalHealthcheckHandlerTest {\r
+\r
+ public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();\r
+ private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";\r
+ public static final Response HEALTH_CHECK_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+\r
+ @Test\r
+ public final void testGlobalHealthcheck() {\r
+ try {\r
+ MsoStatusUtil statusUtil = Mockito.mock(MsoStatusUtil.class);\r
+ HealthCheckUtils utils = Mockito.mock(HealthCheckUtils.class);\r
+ Mockito.when(utils.verifyGlobalHealthCheck(true, null)).thenReturn(true);\r
+ Mockito.when(statusUtil.getSiteStatus(Mockito.anyString())).thenReturn(true);\r
+ GlobalHealthcheckHandler gh = Mockito.mock(GlobalHealthcheckHandler.class);\r
+ Mockito.when(gh.globalHealthcheck(Mockito.anyBoolean())).thenReturn(HEALTH_CHECK_RESPONSE);\r
+ Response resp = gh.globalHealthcheck(true);\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+}\r
-/*-
- * ============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);
- }
-}
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * OPENECOMP - MSO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.openecomp.mso.apihandlerinfra;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import static org.junit.Assert.assertFalse;\r
+import java.io.IOException;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.apache.http.HttpStatus;\r
+import org.codehaus.jackson.JsonParseException;\r
+import org.codehaus.jackson.map.JsonMappingException;\r
+import org.codehaus.jackson.map.ObjectMapper;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.openecomp.mso.apihandler.common.ValidationException;\r
+import org.openecomp.mso.requestsdb.InfraActiveRequests;\r
+import org.openecomp.mso.requestsdb.RequestsDatabase;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.GetOrchestrationResponse;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.InstanceReferences;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.RequestStatus;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;\r
+\r
+public class OrchestrationRequestsTest {\r
+\r
+ private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";\r
+ public static final Response RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+ @Mock\r
+ private static RequestsDatabase db;\r
+ private static OrchestrationRequests orReq;\r
+ private static GetOrchestrationResponse orRes;\r
+\r
+ @Test\r
+ public void testGetOrchestrationRequest() {\r
+ orReq = Mockito.mock(OrchestrationRequests.class);\r
+ orRes = new GetOrchestrationResponse();\r
+ try {\r
+ // create InfraActiveRequests object\r
+ InfraActiveRequests infraRequests = new InfraActiveRequests();\r
+ infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333");\r
+ infraRequests.setNetworkType("CONTRAIL30_BASIC");\r
+ infraRequests.setRequestType("createInstance");\r
+ infraRequests.setSource("VID");\r
+ infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682");\r
+ infraRequests.setServiceInstanceId("bc305d54-75b4-431b-adb2-eb6b9e546014");\r
+ infraRequests.setRequestStatus("IN_PROGRESS");\r
+ infraRequests.setRequestorId("ab1234");\r
+ String body = "{\"modelInfo\":{\"modelInvariantId\":\"9771b085-4705-4bf7-815d-8c0627bb7e36\",\"modelType\":\"service\",\"modelName\":\"Service with VNFs with modules\",\"modelVersion\":\"1.0\"}}"; \r
+ infraRequests.setRequestBody(body);\r
+ \r
+ db = Mockito.mock(RequestsDatabase.class);\r
+ Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests);\r
+\r
+ ///// mock mapInfraActiveRequestToRequest()\r
+ Request request = new Request();\r
+ request.setRequestId(infraRequests.getRequestId());\r
+ request.setRequestScope(infraRequests.getRequestScope());\r
+ request.setRequestType(infraRequests.getRequestAction());\r
+\r
+ InstanceReferences ir = new InstanceReferences();\r
+ if (infraRequests.getNetworkId() != null)\r
+ ir.setNetworkInstanceId(infraRequests.getNetworkId());\r
+ if (infraRequests.getNetworkName() != null)\r
+ ir.setNetworkInstanceName(infraRequests.getNetworkName());\r
+ if (infraRequests.getServiceInstanceId() != null)\r
+ ir.setServiceInstanceId(infraRequests.getServiceInstanceId());\r
+ if (infraRequests.getServiceInstanceName() != null)\r
+ ir.setServiceInstanceName(infraRequests.getServiceInstanceName());\r
+ if (infraRequests.getVfModuleId() != null)\r
+ ir.setVfModuleInstanceId(infraRequests.getVfModuleId());\r
+ if (infraRequests.getVfModuleName() != null)\r
+ ir.setVfModuleInstanceName(infraRequests.getVfModuleName());\r
+ if (infraRequests.getVnfId() != null)\r
+ ir.setVnfInstanceId(infraRequests.getVnfId());\r
+ if (infraRequests.getVnfName() != null)\r
+ ir.setVnfInstanceName(infraRequests.getVnfName());\r
+ if (infraRequests.getVolumeGroupId() != null)\r
+ ir.setVolumeGroupInstanceId(infraRequests.getVolumeGroupId());\r
+ if (infraRequests.getVolumeGroupName() != null)\r
+ ir.setVolumeGroupInstanceName(infraRequests.getVolumeGroupName());\r
+ if (infraRequests.getRequestorId() != null)\r
+ ir.setRequestorId(infraRequests.getRequestorId());\r
+\r
+ request.setInstanceReferences(ir);\r
+ RequestStatus status = new RequestStatus();\r
+\r
+ if (infraRequests.getRequestStatus() != null) {\r
+ status.setRequestState(infraRequests.getRequestStatus());\r
+ }\r
+\r
+ request.setRequestStatus(status);\r
+ // RequestStatus reqStatus = request.getRequestStatus(); \r
+ orRes.setRequest(request); \r
+ Mockito.when(orReq.getOrchestrationRequest(Mockito.anyString(), Mockito.anyString())).thenReturn(RESPONSE);\r
+ Response resp = orReq.getOrchestrationRequest("rq1234d1-5a33-55df-13ab-12abad84e333", "v3");\r
+ \r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestId(),\r
+ "rq1234d1-5a33-55df-13ab-12abad84e333");\r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getSource(), "VID");\r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getTenantId(),\r
+ "19123c2924c648eb8e42a3c1f14b7682");\r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getServiceInstanceId(),\r
+ "bc305d54-75b4-431b-adb2-eb6b9e546014");\r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestStatus(),\r
+ "IN_PROGRESS");\r
+ assertEquals(db.getRequestFromInfraActive("rq1234d1-5a33-55df-13ab-12abad84e333").getRequestorId(),\r
+ "ab1234");\r
+ assertEquals(request.getInstanceReferences().getServiceInstanceId(),"bc305d54-75b4-431b-adb2-eb6b9e546014");\r
+ assertEquals(request.getInstanceReferences().getRequestorId(),"ab1234");\r
+ assertEquals(orRes.getRequest().getRequestId(), "rq1234d1-5a33-55df-13ab-12abad84e333");\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testGetOrchestrationRequestNotPresent() {\r
+ orReq = Mockito.mock(OrchestrationRequests.class);\r
+ orRes = new GetOrchestrationResponse();\r
+ try {\r
+ // create InfraActiveRequests object\r
+ InfraActiveRequests infraRequests = Mockito.mock(InfraActiveRequests.class); \r
+ db = Mockito.mock(RequestsDatabase.class);\r
+ Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests);\r
+\r
+ Request request = new Request();\r
+ RequestStatus status = new RequestStatus();\r
+ request.setRequestStatus(status);\r
+ orRes.setRequest(request); \r
+ assertFalse("rq1234d1-5a33-55df-13ab-12abad84e333".equalsIgnoreCase(orRes.getRequest().getRequestId()));\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testUnlockOrchestrationRequest()\r
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {\r
+ ObjectMapper mapper = new ObjectMapper();\r
+ String requestJSON = " {\"requestDetails\": {\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"ab1234\"}}}";\r
+ \r
+ MsoRequest msoRequest = new MsoRequest("rq1234d1-5a33-55df-13ab-12abad84e333");\r
+ ServiceInstancesRequest sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class);\r
+ msoRequest.parseOrchestration(sir);\r
+\r
+ //create object instead of a DB call.\r
+ InfraActiveRequests infraRequests = new InfraActiveRequests();\r
+ infraRequests.setRequestId("rq1234d1-5a33-55df-13ab-12abad84e333");\r
+ infraRequests.setNetworkType("CONTRAIL30_BASIC");\r
+ infraRequests.setSource("VID");\r
+ infraRequests.setTenantId("19123c2924c648eb8e42a3c1f14b7682");\r
+ infraRequests.setServiceInstanceId("ea4d5374-d28d-4bbf-9691-22985f088b12");\r
+ infraRequests.setRequestStatus("IN-PROGRESS");\r
+\r
+ db = Mockito.mock(RequestsDatabase.class);\r
+ Mockito.when(db.getRequestFromInfraActive(Mockito.anyString())).thenReturn(infraRequests);\r
+\r
+ Request request = new Request();\r
+ InstanceReferences ir = new InstanceReferences();\r
+ request.setInstanceReferences(ir);\r
+ RequestStatus status = new RequestStatus();\r
+\r
+ if (infraRequests.getRequestStatus() != null) {\r
+ status.setRequestState(infraRequests.getRequestStatus());\r
+ }\r
+ request.setRequestStatus(status);\r
+ RequestStatus reqStatus = request.getRequestStatus();\r
+ \r
+ assertEquals(reqStatus.getRequestState(),"IN-PROGRESS");\r
+ \r
+ if (reqStatus.getRequestState().equalsIgnoreCase("IN-PROGRESS")){\r
+ reqStatus.setRequestState(Status.UNLOCKED.toString ());\r
+ }\r
+ assertEquals(reqStatus.getRequestState(),"UNLOCKED");\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra;\r
+\r
+import org.junit.After;\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+\r
+\r
+public class RecipeLookupResultTest {\r
+\r
+ RecipeLookupResult instance;\r
+\r
+ public RecipeLookupResultTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ instance = mock(RecipeLookupResult.class);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ instance = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getOrchestrationURI method\r
+ */\r
+ @Test\r
+ public void testGetOrchestrationURI() {\r
+ String expResult = "orchestrationURI";\r
+ when(instance.getOrchestrationURI()).thenReturn(expResult);\r
+ String result = instance.getOrchestrationURI();\r
+ assertEquals(expResult, result);\r
+ }\r
+\r
+ \r
+ /**\r
+ * Test of setOrchestrationURI method.\r
+ */\r
+ @Test\r
+ public void testSetOrchestrationURI() {\r
+ String orchestrationUri = "orchestrationURI";\r
+ instance.setOrchestrationURI(orchestrationUri);\r
+ verify(instance).setOrchestrationURI(orchestrationUri);\r
+ }\r
+\r
+ /**\r
+ * Test of getRecipeTimeout method\r
+ */\r
+ @Test\r
+ public void testGetRecipeTimeout() {\r
+ int expResult = 10;\r
+ when(instance.getRecipeTimeout()).thenReturn(expResult);\r
+ int result = instance.getRecipeTimeout();\r
+ assertEquals(expResult, result);\r
+ }\r
+\r
+ \r
+ /**\r
+ * Test of setRecipeTimeout method.\r
+ */\r
+ @Test\r
+ public void testSetRecipeTimeout() {\r
+ int recipeTimeOut = 10;\r
+ instance.setRecipeTimeout(recipeTimeOut);\r
+ verify(instance).setRecipeTimeout(10);\r
+ }\r
+ \r
+ \r
+}\r
+
\ No newline at end of file
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * OPENECOMP - MSO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+package org.openecomp.mso.apihandlerinfra;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertTrue;\r
+import static org.junit.Assert.fail;\r
+\r
+import java.io.IOException;\r
+import java.nio.charset.Charset;\r
+import java.util.HashMap;\r
+\r
+import javax.ws.rs.PathParam;\r
+import javax.ws.rs.core.Response;\r
+\r
+import org.apache.commons.io.IOUtils;\r
+import org.apache.http.HttpStatus;\r
+import org.codehaus.jackson.JsonParseException;\r
+import org.codehaus.jackson.map.JsonMappingException;\r
+import org.codehaus.jackson.map.ObjectMapper;\r
+import org.junit.Test;\r
+import org.mockito.Mockito;\r
+import org.openecomp.mso.HealthCheckUtils;\r
+import org.openecomp.mso.apihandler.common.ValidationException;\r
+import org.openecomp.mso.requestsdb.InfraActiveRequests;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.Request;\r
+import org.openecomp.mso.apihandlerinfra.serviceinstancebeans.ServiceInstancesRequest;\r
+\r
+public class ServiceInstancesTest {\r
+\r
+ private static final String requestJSONCreate = "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\", "\r
+ + "\"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\","\r
+ + " \"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", \"modelName\": \"Test\","\r
+ + " \"modelVersion\": \"1.0\" }, \"cloudConfiguration\": "\r
+ + "{ \"lcpCloudRegionId\": \"mdt1\", \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" },"\r
+ + " \"subscriberInfo\": { \"globalSubscriberId\": \"{some subscriber id}\","\r
+ + " \"subscriberName\": \"{some subscriber name}\" },"\r
+ + " \"requestInfo\": { \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", "\r
+ + "\"source\": \"VID\", \"suppressRollback\": true, \"requestorId\": \"az2016\" },"\r
+ + " \"requestParameters\": { \"subscriptionServiceType\": \"MOG\", \"aLaCarte\": false,"\r
+ + " \"userParams\": [ { \"name\": \"someUserParam\", \"value\": \"someValue\" } ] } } } ";\r
+ \r
+ private static final String requestJSONActivateDeacivate =\r
+ "{ \"requestDetails\": { \"modelInfo\": { \"modelType\": \"service\","\r
+ + " \"modelInvariantId\": \"ff3514e3-5a33-55df-13ab-12abad84e7ff\", "\r
+ + "\"modelVersionId\": \"fe6985cd-ea33-3346-ac12-ab121484a3fe\", "\r
+ + "\"modelName\": \"Test\", \"modelVersion\": \"1.0\" }, "\r
+ + "\"requestInfo\": { \"source\": \"VID\", \"requestorId\": \"az2016\" }, "\r
+ + "\"requestParameters\": { \"userParams\": [ { \"name\": \"aic_zone\", "\r
+ + "\"value\": \"someValue\" } ] } } } ";\r
+\r
+ private static final String requestJSONDelete =\r
+ "{ \"requestDetails\": { \"modelInfo\": { \"modelType\":\"network\", "\r
+ + "\"modelName\":\"CONTRAIL30_BASIC\" }, \"cloudConfiguration\": { \"lcpCloudRegionId\":\"mdt1\", "\r
+ + "\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\" }, "\r
+ + "\"requestInfo\": { \"source\":\"VID\", \"requestorId\":\"az2016\" } } }";\r
+ \r
+ @Test\r
+ public void testCreateServiceInstance()\r
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {\r
+ final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";\r
+ final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+\r
+ try {\r
+ ServiceInstances sir = Mockito.mock(ServiceInstances.class);\r
+ sir.createServiceInstance(requestJSONCreate, "v3");\r
+ Mockito.when(sir.createServiceInstance(requestJSONCreate, "v3")).thenReturn(SERVICE_RESPONSE);\r
+ Response resp = sir.createServiceInstance(requestJSONCreate, "v3");\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testActivateServiceInstance()\r
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {\r
+ final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";\r
+ final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+ try {\r
+ ServiceInstances sir = Mockito.mock(ServiceInstances.class);\r
+ Mockito.when(sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))\r
+ .thenReturn(SERVICE_RESPONSE);\r
+ Response resp = sir.activateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testDeactivateServiceInstance()\r
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {\r
+ final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title></title></head><body></body></html>";\r
+ final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+ try {\r
+ ServiceInstances sir = Mockito.mock(ServiceInstances.class);\r
+ Mockito.when(sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))\r
+ .thenReturn(SERVICE_RESPONSE);\r
+ Response resp = sir.deactivateServiceInstance(requestJSONActivateDeacivate, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void testDeleteServiceInstance()\r
+ throws JsonParseException, JsonMappingException, IOException, ValidationException {\r
+ final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";\r
+ final Response SERVICE_RESPONSE = Response.status(HttpStatus.SC_OK).entity(CHECK_HTML).build();\r
+ try {\r
+ ServiceInstances sir = Mockito.mock(ServiceInstances.class);\r
+ Mockito.when(sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc"))\r
+ .thenReturn(SERVICE_RESPONSE);\r
+ Response resp = sir.deleteServiceInstance(requestJSONDelete, "v5", "3eecada1-83a4-4f33-9ed2-7937e7b8dbbc");\r
+ assertEquals(resp.getStatus(), HttpStatus.SC_OK);\r
+ } catch (Exception e) {\r
+\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+import static org.junit.Assert.assertTrue;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo;\r
+\r
+\r
+\r
+public class RequestDetailsTest {\r
+\r
+ RequestDetails _requestDetails;\r
+ RequestInfo _requestInfo;\r
+\r
+ public RequestDetailsTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _requestDetails = mock(RequestDetails.class);\r
+ _requestInfo = new RequestInfo();\r
+ when(_requestDetails.getRequestInfo()).thenReturn(_requestInfo);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _requestDetails = null;\r
+ _requestInfo = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getRequestInfo method\r
+ */\r
+ @Test\r
+ public void testGetRequestInfo() {\r
+ _requestDetails.setRequestInfo(_requestInfo);\r
+ assertTrue(_requestDetails.getRequestInfo().equals(_requestInfo));\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setRequestInfo\r
+ */\r
+ @Test\r
+ public void testSetRequestInfo() {\r
+ _requestDetails.setRequestInfo(_requestInfo);\r
+ verify(_requestDetails).setRequestInfo(_requestInfo);\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestInfo;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.ValidResponses;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+public class RequestInfoTest {\r
+\r
+ RequestInfo _requestInfo;\r
+ String _source;\r
+ ValidResponses _responseValue;\r
+ String _requestorId;\r
+\r
+ public RequestInfoTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _requestInfo = mock(RequestInfo.class);\r
+ _responseValue = ValidResponses.abort;\r
+ _requestorId = "ab1234";\r
+ _source = "VID";\r
+ when(_requestInfo.getRequestorId()).thenReturn(_requestorId);\r
+ when(_requestInfo.getSource()).thenReturn(_source);\r
+ when(_requestInfo.getResponseValue()).thenReturn(_responseValue);\r
+\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _requestInfo = null;\r
+ _responseValue = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getSource method\r
+ */\r
+ @Test\r
+ public void testGetSource() {\r
+ String result = _requestInfo.getSource();\r
+ assertEquals(_source, result);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setSource\r
+ */\r
+ @Test\r
+ public void testSetSource() {\r
+ _requestInfo.setSource("VID");\r
+ verify(_requestInfo).setSource(_source);\r
+ }\r
+ \r
+ /**\r
+ * Test of getRequestorId method\r
+ */\r
+ @Test\r
+ public void testGetRequestorId() {\r
+ String result = _requestInfo.getRequestorId();\r
+ assertEquals(_requestorId, result);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setRequestInfo\r
+ */\r
+ @Test\r
+ public void testSetRequestorId() {\r
+ _requestInfo.setRequestorId(_requestorId);\r
+ verify(_requestInfo).setRequestorId(_requestorId);\r
+ }\r
+ \r
+\r
+ /**\r
+ * Test of getResponseValue method\r
+ */\r
+ @Test\r
+ public void testGetResponseValue() {\r
+ ValidResponses result = _requestInfo.getResponseValue();\r
+ assertEquals(_responseValue, result);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setResponseValues method\r
+ */\r
+ @Test\r
+ public void testSetResponseValue() {\r
+ _requestInfo.setResponseValue(ValidResponses.abort);\r
+ verify(_requestInfo).setResponseValue(_responseValue);\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.json.JSONArray;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList;\r
+\r
+public class TaskListTest {\r
+\r
+ TaskList _taskList;\r
+ protected String _taskId;\r
+ protected String _type;\r
+ protected String _nfRole;\r
+ protected String _subscriptionServiceType;\r
+ protected String _originalRequestId;\r
+ protected String _originalRequestorId;\r
+ protected String _errorSource;\r
+ protected String _errorCode;\r
+ protected String _errorMessage;\r
+ protected String _buildingBlockName;\r
+ protected String _buildingBlockStep;\r
+ protected JSONArray _validResponses;\r
+\r
+ public TaskListTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _taskList = mock(TaskList.class);\r
+ _taskId = "_taskid";\r
+ _type = "type";\r
+ _nfRole = "nfrole";\r
+ _subscriptionServiceType = "subscriptionservicetype";\r
+ _originalRequestId = "originalrequestid";\r
+ _originalRequestorId = "originalrequestorid";\r
+ _errorSource = "errorsource";\r
+ _errorCode = "errorcode";\r
+ _errorMessage = "errormessage";\r
+ _buildingBlockName = "buildingblockname";\r
+ _buildingBlockStep = "buildingblockstep";\r
+ _validResponses = mock(JSONArray.class);\r
+\r
+ when(_taskList.getTaskId()).thenReturn(_taskId);\r
+ when(_taskList.getType()).thenReturn(_type);\r
+ when(_taskList.getNfRole()).thenReturn(_nfRole);\r
+ when(_taskList.getSubscriptionServiceType()).thenReturn(_subscriptionServiceType);\r
+ when(_taskList.getOriginalRequestId()).thenReturn(_originalRequestId);\r
+ when(_taskList.getOriginalRequestorId()).thenReturn(_originalRequestorId);\r
+ when(_taskList.getErrorSource()).thenReturn(_errorSource);\r
+ when(_taskList.getErrorCode()).thenReturn(_errorCode);\r
+ when(_taskList.getErrorMessage()).thenReturn(_errorMessage);\r
+ when(_taskList.getBuildingBlockName()).thenReturn(_buildingBlockName);\r
+ when(_taskList.getBuildingBlockStep()).thenReturn(_buildingBlockStep);\r
+ when(_taskList.getValidResponses()).thenReturn(_validResponses);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _taskList = null;\r
+ _validResponses = null;\r
+ }\r
+\r
+ @Test\r
+ public void testGetTaskId() {\r
+ String result = _taskList.getTaskId();\r
+ assertEquals(_taskId, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetTaskId() {\r
+ _taskList.setTaskId("_taskid");\r
+ verify(_taskList).setTaskId(_taskId);\r
+ }\r
+\r
+ @Test\r
+ public void testGetType() {\r
+ String result = _taskList.getType();\r
+ assertEquals(_type, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetType() {\r
+ _taskList.setType(_type);\r
+ verify(_taskList).setType(_type);\r
+ }\r
+\r
+ @Test\r
+ public void testGetNfRole() {\r
+ String result = _taskList.getNfRole();\r
+ assertEquals(_nfRole, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetNfRole() {\r
+ _taskList.setType(_nfRole);\r
+ verify(_taskList).setType(_nfRole);\r
+ }\r
+\r
+ @Test\r
+ public void testGetSubscriptionServiceType() {\r
+ String result = _taskList.getSubscriptionServiceType();\r
+ assertEquals(_subscriptionServiceType, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetSubscriptionServiceType() {\r
+ _taskList.setSubscriptionServiceType(_subscriptionServiceType);\r
+ verify(_taskList).setSubscriptionServiceType(_subscriptionServiceType);\r
+ }\r
+\r
+ @Test\r
+ public void testGetOriginalRequestId() {\r
+ String result = _taskList.getOriginalRequestId();\r
+ assertEquals(_originalRequestId, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetOriginalRequestId() {\r
+ _taskList.setOriginalRequestId(_originalRequestId);\r
+ verify(_taskList).setOriginalRequestId(_originalRequestId);\r
+ }\r
+\r
+ @Test\r
+ public void testGetOriginalRequestorId() {\r
+ String result = _taskList.getOriginalRequestorId();\r
+ assertEquals(_originalRequestorId, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetOriginalRequestorId() {\r
+ _taskList.setOriginalRequestorId(_originalRequestorId);\r
+ verify(_taskList).setOriginalRequestorId(_originalRequestorId);\r
+ }\r
+\r
+ @Test\r
+ public void testGetErrorSource() {\r
+ String result = _taskList.getErrorSource();\r
+ assertEquals(_errorSource, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetErrorSource() {\r
+ _taskList.setErrorSource(_errorSource);\r
+ verify(_taskList).setErrorSource(_errorSource);\r
+ }\r
+\r
+ @Test\r
+ public void testGetErrorCode() {\r
+ String result = _taskList.getErrorCode();\r
+ assertEquals(_errorCode, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetErrorCode() {\r
+ _taskList.setErrorCode(_errorCode);\r
+ verify(_taskList).setErrorCode(_errorCode);\r
+ }\r
+\r
+ @Test\r
+ public void testGetErrorMessage() {\r
+ String result = _taskList.getErrorMessage();\r
+ assertEquals(_errorMessage, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetErrorMessage() {\r
+ _taskList.setErrorMessage(_errorMessage);\r
+ verify(_taskList).setErrorMessage(_errorMessage);\r
+ }\r
+\r
+ @Test\r
+ public void testGetBuildingBlockName() {\r
+ String result = _taskList.getBuildingBlockName();\r
+ assertEquals(_buildingBlockName, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetBuildingBlockName() {\r
+ _taskList.setBuildingBlockName(_buildingBlockName);\r
+ verify(_taskList).setBuildingBlockName(_buildingBlockName);\r
+ }\r
+\r
+ @Test\r
+ public void testGetBuildingBlockStep() {\r
+ String result = _taskList.getBuildingBlockStep();\r
+ assertEquals(_buildingBlockStep, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetBuildingBlockStep() {\r
+ _taskList.setBuildingBlockStep(_buildingBlockStep);\r
+ verify(_taskList).setBuildingBlockStep(_buildingBlockStep);\r
+ }\r
+\r
+ @Test\r
+ public void testGetValidResponses() {\r
+\r
+ JSONArray result = _taskList.getValidResponses();\r
+ assertEquals(_validResponses, result);\r
+\r
+ }\r
+ \r
+ @Test\r
+ public void testSetValidResponses() {\r
+ _taskList.setValidResponses(_validResponses);\r
+ verify(_taskList).setValidResponses(_validResponses);\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskRequestReference;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+public class TaskRequestReferenceTest {\r
+\r
+ TaskRequestReference _taskRequestReference;\r
+\r
+ protected String _taskId;\r
+ public TaskRequestReferenceTest() {\r
+ }\r
+ \r
+ @Before\r
+ public void setUp() {\r
+ _taskRequestReference = mock(TaskRequestReference.class);\r
+ _taskId = "taskid";\r
+ \r
+ when(_taskRequestReference.getTaskId()).thenReturn(_taskId);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _taskRequestReference = null;\r
+ }\r
+\r
+ /**\r
+ * Test getTaskRequestReference \r
+ */\r
+ @Test\r
+ public void taskGetRequestReference() {\r
+ String result = _taskRequestReference.getTaskId();\r
+ assertEquals(_taskId, result);\r
+ }\r
+\r
+ /**\r
+ * Test setTaskRequestReference\r
+ */\r
+ @Test\r
+ public void testSetRequestInfo() {\r
+ _taskRequestReference.setTaskId(_taskId);\r
+ verify(_taskRequestReference).setTaskId(_taskId);\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue;\r
+\r
+public class TaskVariableValueTest {\r
+ TaskVariableValue _taskVariableValue;\r
+ protected String _name;\r
+ protected String _value;\r
+ protected String _operator;\r
+\r
+ public TaskVariableValueTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _taskVariableValue = mock(TaskVariableValue.class);\r
+ _name = "name";\r
+ _value = "value";\r
+ _operator = "operator";\r
+ when(_taskVariableValue.getName()).thenReturn(_name);\r
+ when(_taskVariableValue.getValue()).thenReturn(_value);\r
+ when(_taskVariableValue.getOperator()).thenReturn(_operator);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _taskVariableValue = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getName method\r
+ */\r
+ @Test\r
+ public void testGetName() {\r
+ _taskVariableValue.setName(_name);\r
+ assertEquals(_taskVariableValue.getName(),_name);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setName\r
+ */\r
+ @Test\r
+ public void testSetName() {\r
+ _taskVariableValue.setName(_name);\r
+ verify(_taskVariableValue).setName(_name);\r
+ }\r
+ \r
+ /**\r
+ * Test of getName method\r
+ */\r
+ @Test\r
+ public void testGetValue() {\r
+ _taskVariableValue.setValue(_value);\r
+ assertEquals(_taskVariableValue.getValue(),_value);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setName\r
+ */\r
+ @Test\r
+ public void testSetValue() {\r
+ _taskVariableValue.setValue(_value);\r
+ verify(_taskVariableValue).setValue(_value);\r
+ }\r
+ \r
+ /**\r
+ * Test of getName method\r
+ */\r
+ @Test\r
+ public void testGetOperator() {\r
+ _taskVariableValue.setOperator(_operator);\r
+ assertEquals(_taskVariableValue.getOperator(),_operator);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setName\r
+ */\r
+ @Test\r
+ public void testSetRequestDetails() {\r
+ _taskVariableValue.setOperator(_operator);\r
+ verify(_taskVariableValue).setOperator(_operator);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariableValue;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskVariables;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+import java.util.List;\r
+\r
+public class TaskVariablesTest {\r
+\r
+ TaskVariables _taskVariables;\r
+ private List<TaskVariableValue> _taskVariableValueList;\r
+\r
+ public TaskVariablesTest() {\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Before\r
+ public void setUp() {\r
+ _taskVariables = mock(TaskVariables.class);\r
+ _taskVariableValueList = mock(List.class);\r
+ when(_taskVariables.getTaskVariables()).thenReturn(_taskVariableValueList);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _taskVariables = null;\r
+ }\r
+\r
+ @Test\r
+ public void testGetTaskVariables() {\r
+ List<TaskVariableValue> result = _taskVariables.getTaskVariables();\r
+ assertEquals(_taskVariableValueList, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetTaskVariables() {\r
+ _taskVariables.setTaskVariables(_taskVariableValueList);\r
+ verify(_taskVariables).setTaskVariables(_taskVariableValueList);\r
+\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TaskList;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksGetResponse;\r
+\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+\r
+import java.util.List;\r
+\r
+public class TasksGetResponseTest {\r
+\r
+ TasksGetResponse _tasksGetResponse;\r
+ private List<TaskList> _taskList;\r
+\r
+ public TasksGetResponseTest() {\r
+ }\r
+\r
+ @SuppressWarnings("unchecked")\r
+ @Before\r
+ public void setUp() {\r
+ _tasksGetResponse = mock(TasksGetResponse.class);\r
+ _taskList = mock(List.class);\r
+ when(_tasksGetResponse.getTaskList()).thenReturn(_taskList);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _tasksGetResponse = null;\r
+ }\r
+\r
+ @Test\r
+ public void testGetTaskList() {\r
+ List<TaskList> result = _tasksGetResponse.getTaskList();\r
+ assertEquals(_taskList, result);\r
+\r
+ }\r
+\r
+ @Test\r
+ public void testSetTaskList() {\r
+ _tasksGetResponse.setTaskList(_taskList);\r
+ verify(_tasksGetResponse).setTaskList(_taskList);\r
+\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+import static org.junit.Assert.assertTrue;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.RequestDetails;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.TasksRequest;\r
+\r
+\r
+public class TasksRequestTest {\r
+ TasksRequest _tasksRequest;\r
+ private RequestDetails _requestDetails;\r
+\r
+ public TasksRequestTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _tasksRequest = mock(TasksRequest.class);\r
+ _requestDetails = new RequestDetails();\r
+ when(_tasksRequest.getRequestDetails()).thenReturn(_requestDetails);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _tasksRequest = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getRequestDetails method\r
+ */\r
+ @Test\r
+ public void testGetRequestDetails() {\r
+ _tasksRequest.setRequestDetails(_requestDetails);\r
+ assertTrue(_tasksRequest.getRequestDetails().equals(_requestDetails));\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setRequestDetails\r
+ */\r
+ @Test\r
+ public void testSetRequestDetails() {\r
+ _tasksRequest.setRequestDetails(_requestDetails);\r
+ verify(_tasksRequest).setRequestDetails(_requestDetails);\r
+ }\r
+\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.Value;\r
+\r
+public class ValueTest {\r
+ Value _valueInstance;\r
+ protected String _value;\r
+\r
+ public ValueTest() {\r
+ }\r
+\r
+ @Before\r
+ public void setUp() {\r
+ _valueInstance = mock(Value.class);\r
+ _value = "_value";\r
+ when(_valueInstance.getValue()).thenReturn(_value);\r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _valueInstance = null;\r
+ }\r
+\r
+ /**\r
+ * Test of getValue method\r
+ */\r
+ @Test\r
+ public void testGetValue() {\r
+ _valueInstance.setValue(_value);\r
+ assertEquals(_valueInstance.getValue(),_value);\r
+\r
+ }\r
+\r
+ /**\r
+ * Test setValue\r
+ */\r
+ @Test\r
+ public void testSetValue() {\r
+ _valueInstance.setValue(_value);\r
+ verify(_valueInstance).setValue(_value);\r
+ }\r
+}\r
--- /dev/null
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP - SO\r
+ * ================================================================================\r
+ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.openecomp.mso.apihandlerinfra.taskbeans;\r
+\r
+import org.junit.After;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Mockito.mock;\r
+import static org.mockito.Mockito.verify;\r
+import static org.mockito.Mockito.when;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.Variables;\r
+import org.openecomp.mso.apihandlerinfra.tasksbeans.Value;\r
+\r
+public class VariablesTest {\r
+\r
+ Variables _variables;\r
+ protected Value _source;\r
+ protected Value _responseValue;\r
+ protected Value _requestorId;\r
+ \r
+ @Before\r
+ public void setUp() {\r
+ _variables = mock(Variables.class);\r
+ _source = mock(Value.class);\r
+ _responseValue = mock(Value.class);\r
+ _requestorId = mock(Value.class);\r
+ \r
+ when(_variables.getSource()).thenReturn(_source);\r
+ when(_variables.getRequestorId()).thenReturn(_requestorId);\r
+ when(_variables.getResponseValue()).thenReturn(_responseValue);\r
+ \r
+ }\r
+\r
+ @After\r
+ public void tearDown() {\r
+ _variables = null;\r
+ _source = null;\r
+ _responseValue = null;\r
+ _requestorId = null;\r
+ }\r
+ \r
+ @Test\r
+ public void testGetSource() {\r
+ _variables.setSource(_source);\r
+ assertTrue(_variables.getSource().equals(_source));\r
+ }\r
+\r
+ @Test\r
+ public void testSetSource(){\r
+ _variables.setSource(_source);\r
+ verify(_variables).setSource(_source);\r
+ } \r
+ \r
+ @Test\r
+ public void testGetResponseValue() {\r
+ _variables.setResponseValue(_responseValue);\r
+ assertTrue(_variables.getResponseValue().equals(_responseValue));\r
+ }\r
+\r
+ @Test\r
+ public void testSetResponseValue(){\r
+ _variables.setResponseValue(_responseValue);\r
+ verify(_variables).setResponseValue(_responseValue);\r
+ } \r
+ \r
+ @Test\r
+ public void testGetRequestorId() {\r
+ _variables.setRequestorId(_requestorId);\r
+ assertTrue(_variables.getRequestorId().equals(_requestorId));\r
+ }\r
+\r
+ @Test\r
+ public void testSetRequestorId(){\r
+ _variables.setRequestorId(_requestorId);\r
+ verify(_variables).setRequestorId(_requestorId);\r
+ } \r
+ \r
+}\r