From b078c9d89a9d6c07f7cb6e7196b34caf797138d6 Mon Sep 17 00:00:00 2001 From: Parshad Patel Date: Thu, 15 Nov 2018 11:59:54 +0900 Subject: Rename test classes in drools-applications Make test classes name consistence by putting 'Test' at end as per google java style guide Issue-ID: POLICY-1258 Change-Id: Id79e5d3fe3688f7f2569b7996613595cc6b746e7 Signed-off-by: Parshad Patel --- .../src/test/java/org/onap/policy/so/DemoTest.java | 186 ++++++++++ .../onap/policy/so/SoAsyncRequestStatusTest.java | 78 ++++ .../onap/policy/so/SoCloudConfigurationTest.java | 48 +++ .../java/org/onap/policy/so/SoDummyServerTest.java | 239 ++++++++++++ .../onap/policy/so/SoInstanceReferencesTest.java | 48 +++ .../java/org/onap/policy/so/SoManagerTest.java | 404 +++++++++++++++++++++ .../java/org/onap/policy/so/SoModelInfoTest.java | 69 ++++ .../policy/so/SoPolicyExceptionHolderTest.java | 48 +++ .../so/SoRelatedInstanceListElementTest.java | 45 +++ .../org/onap/policy/so/SoRelatedInstanceTest.java | 53 +++ .../org/onap/policy/so/SoRequestDetailsTest.java | 174 +++++++++ .../org/onap/policy/so/SoRequestErrorTest.java | 50 +++ .../java/org/onap/policy/so/SoRequestInfoTest.java | 81 +++++ .../onap/policy/so/SoRequestParametersTest.java | 46 +++ .../onap/policy/so/SoRequestReferencesTest.java | 48 +++ .../org/onap/policy/so/SoRequestStatusTest.java | 57 +++ .../java/org/onap/policy/so/SoRequestTest.java | 75 ++++ .../java/org/onap/policy/so/SoResponseTest.java | 59 +++ .../org/onap/policy/so/SoResponseWrapperTest.java | 105 ++++++ .../policy/so/SoServiceExceptionHolderTest.java | 50 +++ .../org/onap/policy/so/SoSubscriberInfoTest.java | 52 +++ .../src/test/java/org/onap/policy/so/TestDemo.java | 186 ---------- .../onap/policy/so/TestSoAsyncRequestStatus.java | 78 ---- .../onap/policy/so/TestSoCloudConfiguration.java | 48 --- .../java/org/onap/policy/so/TestSoDummyServer.java | 239 ------------ .../onap/policy/so/TestSoInstanceReferences.java | 48 --- .../java/org/onap/policy/so/TestSoManager.java | 404 --------------------- .../java/org/onap/policy/so/TestSoModelInfo.java | 69 ---- .../policy/so/TestSoPolicyExceptionHolder.java | 48 --- .../org/onap/policy/so/TestSoRelatedInstance.java | 53 --- .../so/TestSoRelatedInstanceListElement.java | 45 --- .../java/org/onap/policy/so/TestSoRequest.java | 75 ---- .../org/onap/policy/so/TestSoRequestDetails.java | 174 --------- .../org/onap/policy/so/TestSoRequestError.java | 50 --- .../java/org/onap/policy/so/TestSoRequestInfo.java | 81 ----- .../onap/policy/so/TestSoRequestParameters.java | 46 --- .../onap/policy/so/TestSoRequestReferences.java | 48 --- .../org/onap/policy/so/TestSoRequestStatus.java | 57 --- .../java/org/onap/policy/so/TestSoResponse.java | 59 --- .../org/onap/policy/so/TestSoResponseWrapper.java | 105 ------ .../policy/so/TestSoServiceExceptionHolder.java | 50 --- .../org/onap/policy/so/TestSoSubscriberInfo.java | 52 --- 42 files changed, 2015 insertions(+), 2015 deletions(-) create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java create mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java create mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java delete mode 100644 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java delete mode 100755 controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java (limited to 'controlloop/common/model-impl/so/src') diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java new file mode 100644 index 000000000..43cce61e1 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/DemoTest.java @@ -0,0 +1,186 @@ +/*- + * ============LICENSE_START======================================================= + * 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.onap.policy.so; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.Test; +import org.onap.policy.so.SOCloudConfiguration; +import org.onap.policy.so.SOModelInfo; +import org.onap.policy.so.SORelatedInstance; +import org.onap.policy.so.SORelatedInstanceListElement; +import org.onap.policy.so.SORequest; +import org.onap.policy.so.SORequestDetails; +import org.onap.policy.so.SORequestInfo; +import org.onap.policy.so.SORequestParameters; +import org.onap.policy.so.util.Serialization; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DemoTest { + private static final Logger logger = LoggerFactory.getLogger(DemoTest.class); + + @Test + public void test() { + + SORequest request = new SORequest(); + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); + request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); + request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("1"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); + request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); + + request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); + request.getRequestDetails().getRequestInfo().setSource("VID"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(true); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement3 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement3.setRelatedInstance(new SORelatedInstance()); + + relatedInstanceListElement1.getRelatedInstance().setInstanceId( + "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); + relatedInstanceListElement1.getRelatedInstance().setInstanceName( + "SOTESTVOL103a-vSAMP12_base_module-0_vol"); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); + + relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff3514e3-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6985cd-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( + "parent service model name"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + + relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); + relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( + "ff5256d1-5a33-55df-13ab-12abad84e7ff"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( + "fe6478e4-ea33-3346-ac12-ab121484a3fe"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); + relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); + + Map userParam1 = new HashMap<>(); + userParam1.put("name1", "value1"); + + Map userParam2 = new HashMap<>(); + userParam2.put("name2", "value2"); + + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); + request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + + } + + @Test + public void testHack() { + + logger.debug("** HACK **"); + + SORequest request = new SORequest(); + + request.setRequestDetails(new SORequestDetails()); + request.getRequestDetails().setModelInfo(new SOModelInfo()); + request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); + request.getRequestDetails().setRequestInfo(new SORequestInfo()); + request.getRequestDetails().setRequestParameters(new SORequestParameters()); + request.getRequestDetails().getRequestParameters().setUserParams(null); + + request.getRequestDetails().getModelInfo().setModelType("vfModule"); + request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); + request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); + request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); + request.getRequestDetails().getModelInfo().setModelVersion("2.0"); + + request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); + request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); + + request.getRequestDetails().getRequestInfo().setInstanceName( + "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); + request.getRequestDetails().getRequestInfo().setSource("POLICY"); + request.getRequestDetails().getRequestInfo().setSuppressRollback(false); + + SORelatedInstanceListElement relatedInstanceListElement1 = + new SORelatedInstanceListElement(); + SORelatedInstanceListElement relatedInstanceListElement2 = + new SORelatedInstanceListElement(); + relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); + relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); + + String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; + relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); + relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( + "24329a0c-1d57-4210-b1af-a65df64e9d59"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( + "ac642881-8e7e-4217-bd64-16ad41c42e30"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); + relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + + String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; + relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); + relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( + "09fd971e-db5f-475d-997c-cf6704b6b8fe"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( + "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); + relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( + "0d9e0d9d-3527-49f4-b3cb 2"); + + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); + request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); + + logger.debug(Serialization.gsonPretty.toJson(request)); + } + +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java new file mode 100755 index 000000000..d6fd0ad25 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoAsyncRequestStatusTest.java @@ -0,0 +1,78 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDateTime; + +import org.junit.Test; + +public class SoAsyncRequestStatusTest { + + @Test + public void testConstructor() { + SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); + + assertTrue(obj.getCorrelator() == null); + assertTrue(obj.getFinishTime() == null); + assertTrue(obj.getInstanceReferences() == null); + assertTrue(obj.getRequestId() == null); + assertTrue(obj.getRequestScope() == null); + assertTrue(obj.getRequestStatus() == null); + assertTrue(obj.getStartTime() == null); + } + + @Test + public void testSetGet() { + SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); + + obj.setCorrelator("correlator"); + assertEquals("correlator", obj.getCorrelator()); + + LocalDateTime finishTime = LocalDateTime.now(); + obj.setFinishTime(finishTime); + assertEquals(finishTime, obj.getFinishTime()); + + SOInstanceReferences instanceReferences = new SOInstanceReferences(); + obj.setInstanceReferences(instanceReferences); + assertEquals(instanceReferences, obj.getInstanceReferences()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + + obj.setRequestScope("requestScope"); + assertEquals("requestScope", obj.getRequestScope()); + + SORequestStatus requestStatus = new SORequestStatus(); + obj.setRequestStatus(requestStatus); + assertEquals(requestStatus, obj.getRequestStatus()); + + obj.setRequestType("requestType"); + assertEquals("requestType", obj.getRequestType()); + + LocalDateTime startTime = LocalDateTime.now(); + obj.setStartTime(startTime); + assertEquals(startTime, obj.getStartTime()); + + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java new file mode 100755 index 000000000..8b52ae9a2 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoCloudConfigurationTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoCloudConfigurationTest { + + @Test + public void testConstructor() { + SOCloudConfiguration obj = new SOCloudConfiguration(); + + assertTrue(obj.getLcpCloudRegionId() == null); + assertTrue(obj.getTenantId() == null); + } + + @Test + public void testSetGet() { + SOCloudConfiguration obj = new SOCloudConfiguration(); + + obj.setLcpCloudRegionId("lcpCloudRegionId"); + assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId()); + + obj.setTenantId("tenantId"); + assertEquals("tenantId", obj.getTenantId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java new file mode 100644 index 000000000..17f92bcb9 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoDummyServerTest.java @@ -0,0 +1,239 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * ================================================================================ + * Modifications Copyright (C) 2018 AT&T. 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.onap.policy.so; + +import com.google.gson.Gson; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.Response; + +@Path("/SO") +public class SoDummyServerTest { + + private static int postMessagesReceived = 0; + private static int putMessagesReceived = 0; + private static int statMessagesReceived = 0; + private static int getMessagesReceived = 0; + private static int deleteMessagesReceived = 0; + + private static Map ongoingRequestMap = new ConcurrentHashMap<>(); + + /** + * Stats method. + * + * @return response + */ + @GET + @Path("/Stats") + public Response serviceGetStats() { + statMessagesReceived++; + return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); + + } + + /** + * Get stat type. + * + * @param statType the stat type + * @return http response + */ + @GET + @Path("/OneStat/{statType}") + public Response serviceGetStat(@PathParam("statType") final String statType) { + statMessagesReceived++; + return Response.status(200).entity("{\"TYPE\": " + statType + "}").build(); + } + + /** + * Post to service instantiation. + * + * @param jsonString string to send + * @return http response + */ + @POST + @Path("/serviceInstantiation/v7") + public Response servicePostRequest(final String jsonString) { + postMessagesReceived++; + return buildResponse(jsonString); + } + + /** + * Post. + * + * @param serviceInstanceId service instance id + * @param vnfInstanceId vnf instance id + * @param jsonString json body + * @return http response + */ + @POST + @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") + public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) { + postMessagesReceived++; + return buildResponse(jsonString); + } + + /** + * Get instance ID. + * + * @param nsInstanceId node instance id + * @return http response + */ + @GET + @Path("/orchestrationRequests/v5/{nsInstanceId}") + public Response soRequestStatus(@PathParam("nsInstanceId") final String nsInstanceId) { + + SOResponse response = ongoingRequestMap.get(nsInstanceId); + + int iterationsLeft = Integer.valueOf(response.getRequest().getRequestScope()); + if (--iterationsLeft > 0) { + response.getRequest().setRequestScope(new Integer(iterationsLeft).toString()); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()).entity(responseString).build(); + } + + ongoingRequestMap.remove(nsInstanceId); + + if ("ReturnBadAfterWait".equals(response.getRequest().getRequestType())) { + return Response.status(400).build(); + } + + response.getRequest().getRequestStatus().setRequestState("COMPLETE"); + response.getRequest().setRequestScope("0"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()).entity(responseString).build(); + } + + /** + * Delete. + * + * @param serviceInstanceId service instance id + * @param vnfInstanceId vnf instance id + * @param vfModuleInstanceId vf module instance id + * @param jsonString json body + * @return http response + */ + @DELETE + @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") + public Response serviceDeleteRequestVfModules( + @PathParam("serviceInstanceId") final String serviceInstanceId, + @PathParam("vnfInstanceId") final String vnfInstanceId, + @PathParam("vfModuleInstanceId") final String vfModuleInstanceId, + final String jsonString) { + deleteMessagesReceived++; + return buildResponse(jsonString); + } + + private Response buildResponse(String jsonString) { + if (jsonString == null) { + return Response.status(400).build(); + } + + SORequest request = null; + try { + request = new Gson().fromJson(jsonString, SORequest.class); + } catch (Exception e) { + return Response.status(400).build(); + } + + if (request == null) { + return Response.status(400).build(); + } + + if (request.getRequestType() == null) { + return Response.status(400).build(); + } + + if ("ReturnBadJson".equals(request.getRequestType())) { + return Response.status(200) + .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived + + ",\"POST\":" + " , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived + + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); + } + + SOResponse response = new SOResponse(); + response.setRequest(request); + response.setRequestReferences(new SORequestReferences()); + response.getRequestReferences().setRequestId(request.getRequestId().toString()); + + if ("ReturnCompleted".equals(request.getRequestType())) { + response.getRequest().getRequestStatus().setRequestState("COMPLETE"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnFailed".equals(request.getRequestType())) { + response.getRequest().getRequestStatus().setRequestState("FAILED"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnOnging202".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(202); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnOnging200".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + + if ("ReturnBadAfterWait".equals(request.getRequestType())) { + ongoingRequestMap.put(request.getRequestId().toString(), response); + + response.getRequest().getRequestStatus().setRequestState("ONGOING"); + response.setHttpResponseCode(200); + String responseString = new Gson().toJson(response, SOResponse.class); + return Response.status(response.getHttpResponseCode()) + .entity(responseString) + .build(); + } + return null; + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java new file mode 100755 index 000000000..39e37f0cb --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoInstanceReferencesTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoInstanceReferencesTest { + + @Test + public void testConstructor() { + SOInstanceReferences obj = new SOInstanceReferences(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getRequestId() == null); + } + + @Test + public void testSetGet() { + SOInstanceReferences obj = new SOInstanceReferences(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java new file mode 100644 index 000000000..c090513f6 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoManagerTest.java @@ -0,0 +1,404 @@ +/*- + * ============LICENSE_START======================================================= + * TestSOManager + * ================================================================================ + * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2018 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.net.URI; +import java.util.UUID; +import java.util.concurrent.Future; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.drools.core.WorkingMemory; +import org.glassfish.grizzly.http.server.HttpServer; +import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.drools.system.PolicyEngine; + +public class SoManagerTest { + private static final String BASE_URI = "http://localhost:46553/TestSOManager"; + private static final String BASE_SO_URI = BASE_URI + "/SO"; + private static HttpServer server; + + /** + * Set up test class. + */ + @BeforeClass + public static void setUp() throws IOException { + final ResourceConfig rc = new ResourceConfig(SoDummyServerTest.class); + //Grizzly by default doesn't allow payload for HTTP methods (ex: DELETE), for which HTTP spec doesn't + // explicitly state that. + //allow it before starting the server + server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false); + server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); + server.start(); + } + + @AfterClass + public static void tearDown() throws Exception { + server.shutdown(); + } + + @Test + public void testGrizzlyServer() throws ClientProtocolException, IOException { + CloseableHttpClient httpclient = HttpClients.createDefault(); + HttpGet httpGet = new HttpGet("http://localhost:46553/TestSOManager/SO/Stats"); + CloseableHttpResponse response = httpclient.execute(httpGet); + + String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); + assertTrue(returnBody.matches("^\\{\"GET\": [0-9]*,\"STAT\": [0-9]*,\"POST\": [0-9]*,\"PUT\": [0-9]*," + + "\"DELETE\": [0-9]*\\}$")); + } + + @Test + public void testServiceInstantiation() throws IOException { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", + "citizen", null); + assertNull(response); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", null); + assertNull(response); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", new SORequest()); + assertNull(response); + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + + request.setRequestType("ReturnCompleted"); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + request.setRequestType("ReturnFailed"); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNotNull(response); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", + "citizen", request); + assertNull(response); + } + + @Test + public void testVfModuleCreation() throws IOException { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); + PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); + + WorkingMemory wm = new DummyWorkingMemory(); + + SORequest soRequest = new SORequest(); + soRequest.setOperationType(SoOperationType.SCALE_OUT); + PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); + Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, + UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + request.setOperationType(SoOperationType.SCALE_OUT); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnCompleted"); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnFailed"); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + } + + @Test + public void testVfModuleDeletion() { + SOManager manager = new SOManager(); + assertNotNull(manager); + manager.setRestGetTimeout(100); + + PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); + PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); + + WorkingMemory wm = new DummyWorkingMemory(); + + SORequest soRequest = new SORequest(); + soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); + PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); + Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, + UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + SORequest request = new SORequest(); + request.setRequestId(UUID.randomUUID()); + request.setRequestScope("Test"); + request.setRequestType("ReturnBadJson"); + request.setStartTime("2018-03-23 16:31"); + request.setRequestStatus(new SORequestStatus()); + request.getRequestStatus().setRequestState("ONGOING"); + request.setOperationType(SoOperationType.DELETE_VF_MODULE); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnCompleted"); + + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnFailed"); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Use scope to set the number of iterations we'll wait for + + request.setRequestType("ReturnOnging200"); + request.setRequestScope(new Integer(10).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(20).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertNotNull(response.getRequest()); + assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test timeout after 20 attempts for a response + request.setRequestType("ReturnOnging202"); + request.setRequestScope(new Integer(21).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + + // Test bad response after 3 attempts for a response + request.setRequestType("ReturnBadAfterWait"); + request.setRequestScope(new Integer(3).toString()); + asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), + UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); + try { + SOResponse response = asyncRestCallFuture.get(); + assertEquals(999, response.getHttpResponseCode()); + } catch (Exception e) { + fail("test should not throw an exception"); + } + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java new file mode 100755 index 000000000..5898f04f0 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoModelInfoTest.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoModelInfoTest { + + @Test + public void testConstructor() { + SOModelInfo obj = new SOModelInfo(); + + assertTrue(obj.getModelCustomizationId() == null); + assertTrue(obj.getModelCustomizationName() == null); + assertTrue(obj.getModelInvariantId() == null); + assertTrue(obj.getModelName() == null); + assertTrue(obj.getModelType() == null); + assertTrue(obj.getModelVersion() == null); + assertTrue(obj.getModelVersionId() == null); + } + + @Test + public void testSetGet() { + SOModelInfo obj = new SOModelInfo(); + + obj.setModelCustomizationId("modelCustomizationId"); + assertEquals("modelCustomizationId", obj.getModelCustomizationId()); + + obj.setModelCustomizationName("modelCustomizationName"); + assertEquals("modelCustomizationName", obj.getModelCustomizationName()); + + obj.setModelInvariantId("modelInvariantId"); + assertEquals("modelInvariantId", obj.getModelInvariantId()); + + obj.setModelName("modelName"); + assertEquals("modelName", obj.getModelName()); + + obj.setModelType("modelType"); + assertEquals("modelType", obj.getModelType()); + + obj.setModelVersion("modelVersion"); + assertEquals("modelVersion", obj.getModelVersion()); + + obj.setModelVersionId("modelVersionId"); + assertEquals("modelVersionId", obj.getModelVersionId()); + + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java new file mode 100755 index 000000000..2dea68d8f --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoPolicyExceptionHolderTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoPolicyExceptionHolderTest { + + @Test + public void testConstructor() { + SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); + + assertTrue(obj.getMessageId() == null); + assertTrue(obj.getText() == null); + } + + @Test + public void testSetGet() { + SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); + + obj.setMessageId("messageId"); + assertEquals("messageId", obj.getMessageId()); + + obj.setText("text"); + assertEquals("text", obj.getText()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java new file mode 100755 index 000000000..4c549361a --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceListElementTest.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRelatedInstanceListElementTest { + + @Test + public void testConstructor() { + SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); + + assertTrue(obj.getRelatedInstance() == null); + } + + @Test + public void testSetGet() { + SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); + + SORelatedInstance relatedInstance = new SORelatedInstance(); + obj.setRelatedInstance(relatedInstance); + assertEquals(relatedInstance, obj.getRelatedInstance()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java new file mode 100755 index 000000000..aa137e19f --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRelatedInstanceTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRelatedInstanceTest { + + @Test + public void testConstructor() { + SORelatedInstance obj = new SORelatedInstance(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getInstanceName() == null); + assertTrue(obj.getModelInfo() == null); + } + + @Test + public void testSetGet() { + SORelatedInstance obj = new SORelatedInstance(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setInstanceName("instanceName"); + assertEquals("instanceName", obj.getInstanceName()); + + SOModelInfo modelInfo = new SOModelInfo(); + obj.setModelInfo(modelInfo); + assertEquals(modelInfo, obj.getModelInfo()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java new file mode 100755 index 000000000..71ae7ca66 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestDetailsTest.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 Ericsson. 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class SoRequestDetailsTest { + + @Test + public void testConstructor() { + SORequestDetails obj = new SORequestDetails(); + + assertTrue(obj.getCloudConfiguration() == null); + assertTrue(obj.getModelInfo() == null); + assertTrue(obj.getRequestInfo() == null); + assertTrue(obj.getRequestParameters() == null); + assertTrue(obj.getSubscriberInfo() == null); + + assertTrue(obj.getRelatedInstanceList() != null); + assertEquals(0, obj.getRelatedInstanceList().size()); + } + + @Test + public void testSetGet() { + SORequestDetails obj = new SORequestDetails(); + + SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); + obj.setCloudConfiguration(cloudConfiguration); + assertEquals(cloudConfiguration, obj.getCloudConfiguration()); + + SOModelInfo modelInfo = new SOModelInfo(); + obj.setModelInfo(modelInfo); + assertEquals(modelInfo, obj.getModelInfo()); + + SORequestInfo requestInfo = new SORequestInfo(); + obj.setRequestInfo(requestInfo); + assertEquals(requestInfo, obj.getRequestInfo()); + + SORequestParameters requestParameters = new SORequestParameters(); + obj.setRequestParameters(requestParameters); + assertEquals(requestParameters, obj.getRequestParameters()); + + SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); + obj.setSubscriberInfo(subscriberInfo); + assertEquals(subscriberInfo, obj.getSubscriberInfo()); + } + + @Test + public void testSoMRequestDetailsMethods() { + SORequestDetails details = new SORequestDetails(); + assertNotNull(details); + assertNotEquals(0, details.hashCode()); + + SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); + details.setCloudConfiguration(cloudConfiguration); + assertEquals(cloudConfiguration, details.getCloudConfiguration()); + assertNotEquals(0, details.hashCode()); + + SOModelInfo modelInfo = new SOModelInfo(); + details.setModelInfo(modelInfo); + assertEquals(modelInfo, details.getModelInfo()); + assertNotEquals(0, details.hashCode()); + + List relatedInstanceList = new ArrayList<>(); + details.setRelatedInstanceList(relatedInstanceList); + assertEquals(relatedInstanceList, details.getRelatedInstanceList()); + assertNotEquals(0, details.hashCode()); + + SORequestInfo requestInfo = new SORequestInfo(); + details.setRequestInfo(requestInfo); + assertEquals(requestInfo, details.getRequestInfo()); + assertNotEquals(0, details.hashCode()); + + SORequestParameters requestParameters = new SORequestParameters(); + details.setRequestParameters(requestParameters); + assertEquals(requestParameters, details.getRequestParameters()); + assertNotEquals(0, details.hashCode()); + + SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); + details.setSubscriberInfo(subscriberInfo); + assertEquals(subscriberInfo, details.getSubscriberInfo()); + assertNotEquals(0, details.hashCode()); + + assertEquals("SORequestDetails [modelInfo=org.onap.policy.so", details.toString().substring(0, 46)); + + SORequestDetails copiedDetails = new SORequestDetails(details); + + assertTrue(details.equals(details)); + assertTrue(details.equals(copiedDetails)); + assertFalse(details.equals(null)); + assertFalse(details.equals("Hello")); + + details.setCloudConfiguration(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setCloudConfiguration(null); + assertTrue(details.equals(copiedDetails)); + details.setCloudConfiguration(cloudConfiguration); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setCloudConfiguration(cloudConfiguration); + assertTrue(details.equals(copiedDetails)); + + details.setModelInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setModelInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setModelInfo(modelInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setModelInfo(modelInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRequestInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setRequestInfo(requestInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestInfo(requestInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRequestParameters(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestParameters(null); + assertTrue(details.equals(copiedDetails)); + details.setRequestParameters(requestParameters); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRequestParameters(requestParameters); + assertTrue(details.equals(copiedDetails)); + + details.setSubscriberInfo(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setSubscriberInfo(null); + assertTrue(details.equals(copiedDetails)); + details.setSubscriberInfo(subscriberInfo); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setSubscriberInfo(subscriberInfo); + assertTrue(details.equals(copiedDetails)); + + details.setRelatedInstanceList(null); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRelatedInstanceList(null); + assertTrue(details.equals(copiedDetails)); + details.setRelatedInstanceList(relatedInstanceList); + assertFalse(details.equals(copiedDetails)); + copiedDetails.setRelatedInstanceList(relatedInstanceList); + assertTrue(details.equals(copiedDetails)); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java new file mode 100755 index 000000000..f700fbc70 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestErrorTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestErrorTest { + + @Test + public void testConstructor() { + SORequestError obj = new SORequestError(); + + assertTrue(obj.getPolicyException() == null); + assertTrue(obj.getServiceException() == null); + } + + @Test + public void testSetGet() { + SORequestError obj = new SORequestError(); + + SOPolicyExceptionHolder policyException = new SOPolicyExceptionHolder(); + obj.setPolicyException(policyException); + assertEquals(policyException, obj.getPolicyException()); + + SOServiceExceptionHolder serviceException = new SOServiceExceptionHolder(); + obj.setServiceException(serviceException); + assertEquals(serviceException, obj.getServiceException()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java new file mode 100755 index 000000000..c09da54dc --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestInfoTest.java @@ -0,0 +1,81 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestInfoTest { + + @Test + public void testConstructor() { + SORequestInfo obj = new SORequestInfo(); + + assertTrue(obj.getBillingAccountNumber() == null); + assertTrue(obj.getCallbackUrl() == null); + assertTrue(obj.getCorrelator() == null); + assertTrue(obj.getInstanceName() == null); + assertTrue(obj.getOrderNumber() == null); + assertTrue(obj.getOrderVersion() == null); + assertTrue(obj.getProductFamilyId() == null); + assertTrue(obj.getRequestorId() == null); + assertTrue(obj.getSource() == null); + assertTrue(obj.isSuppressRollback() == false); + } + + @Test + public void testSetGet() { + SORequestInfo obj = new SORequestInfo(); + + obj.setBillingAccountNumber("billingAccountNumber"); + assertEquals("billingAccountNumber", obj.getBillingAccountNumber()); + + obj.setCallbackUrl("callbackUrl"); + assertEquals("callbackUrl", obj.getCallbackUrl()); + + obj.setCorrelator("correlator"); + assertEquals("correlator", obj.getCorrelator()); + + obj.setInstanceName("instanceName"); + assertEquals("instanceName", obj.getInstanceName()); + + obj.setOrderNumber("orderNumber"); + assertEquals("orderNumber", obj.getOrderNumber()); + + int orderVersion = 2008; + obj.setOrderVersion(orderVersion); + assertEquals((Integer) orderVersion, obj.getOrderVersion()); + + obj.setProductFamilyId("productFamilyId"); + assertEquals("productFamilyId", obj.getProductFamilyId()); + + obj.setRequestorId("requestorId"); + assertEquals("requestorId", obj.getRequestorId()); + + obj.setSource("source"); + assertEquals("source", obj.getSource()); + + obj.setSuppressRollback(true); + assertEquals(true, obj.isSuppressRollback()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java new file mode 100755 index 000000000..db93988c9 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestParametersTest.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestParametersTest { + + @Test + public void testConstructor() { + SORequestParameters obj = new SORequestParameters(); + + assertTrue(obj.getSubscriptionServiceType() == null); + assertTrue(obj.getUserParams() != null); + assertEquals(0, obj.getUserParams().size()); + } + + @Test + public void testSetGet() { + SORequestParameters obj = new SORequestParameters(); + + obj.setSubscriptionServiceType("subscriptionServiceType"); + assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java new file mode 100755 index 000000000..5d6ff2090 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestReferencesTest.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestReferencesTest { + + @Test + public void testConstructor() { + SORequestReferences obj = new SORequestReferences(); + + assertTrue(obj.getInstanceId() == null); + assertTrue(obj.getRequestId() == null); + } + + @Test + public void testSetGet() { + SORequestReferences obj = new SORequestReferences(); + + obj.setInstanceId("instanceId"); + assertEquals("instanceId", obj.getInstanceId()); + + obj.setRequestId("requestId"); + assertEquals("requestId", obj.getRequestId()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java new file mode 100755 index 000000000..cd3e1b58a --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestStatusTest.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoRequestStatusTest { + + @Test + public void testConstructor() { + SORequestStatus obj = new SORequestStatus(); + + assertEquals(0, obj.getPercentProgress()); + assertTrue(obj.getRequestState() == null); + assertTrue(obj.getTimestamp() == null); + assertFalse(obj.isWasRolledBack()); + } + + @Test + public void testSetGet() { + SORequestStatus obj = new SORequestStatus(); + + obj.setPercentProgress(2008); + assertEquals(2008, obj.getPercentProgress()); + + obj.setRequestState("requestState"); + assertEquals("requestState", obj.getRequestState()); + + obj.setTimestamp("timestamp"); + assertEquals("timestamp", obj.getTimestamp()); + + obj.setWasRolledBack(true); + assertTrue(obj.isWasRolledBack()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java new file mode 100755 index 000000000..c09c58471 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoRequestTest.java @@ -0,0 +1,75 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.time.LocalDateTime; +import java.util.UUID; + +import org.junit.Test; + +public class SoRequestTest { + + @Test + public void testConstructor() { + SORequest obj = new SORequest(); + + assertTrue(obj.getFinishTime() == null); + assertTrue(obj.getRequestDetails() == null); + assertTrue(obj.getRequestId() == null); + assertTrue(obj.getRequestScope() == null); + assertTrue(obj.getRequestStatus() == null); + assertTrue(obj.getRequestType() == null); + assertTrue(obj.getStartTime() == null); + } + + @Test + public void testSetGet() { + SORequest obj = new SORequest(); + + LocalDateTime finishTime = LocalDateTime.now(); + obj.setFinishTime(finishTime); + assertEquals(finishTime, obj.getFinishTime()); + + UUID uuid = UUID.randomUUID(); + obj.setRequestId(uuid); + assertEquals(uuid, obj.getRequestId()); + + obj.setRequestScope("requestScope"); + assertEquals("requestScope", obj.getRequestScope()); + + SORequestStatus requestStatus = new SORequestStatus(); + obj.setRequestStatus(requestStatus); + assertEquals(requestStatus, obj.getRequestStatus()); + + obj.setRequestType("requestType"); + assertEquals("requestType", obj.getRequestType()); + + obj.setOperationType(SoOperationType.DELETE_VF_MODULE); + assertEquals(SoOperationType.DELETE_VF_MODULE, obj.getOperationType()); + + LocalDateTime startTime = LocalDateTime.now(); + obj.setStartTime(startTime.toString()); + assertEquals(startTime.toString(), obj.getStartTime()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java new file mode 100755 index 000000000..cf396561b --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseTest.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoResponseTest { + + @Test + public void testConstructor() { + SOResponse obj = new SOResponse(); + + assertEquals(0, obj.getHttpResponseCode()); + assertTrue(obj.getRequest() == null); + assertTrue(obj.getRequestError() == null); + assertTrue(obj.getRequestReferences() == null); + } + + @Test + public void testSetGet() { + SOResponse obj = new SOResponse(); + + obj.setHttpResponseCode(2008); + assertEquals(2008, obj.getHttpResponseCode()); + + SORequest request = new SORequest(); + obj.setRequest(request); + assertEquals(request, obj.getRequest()); + + SORequestError requestError = new SORequestError(); + obj.setRequestError(requestError); + assertEquals(requestError, obj.getRequestError()); + + SORequestReferences requestReferences = new SORequestReferences(); + obj.setRequestReferences(requestReferences); + assertEquals(requestReferences, obj.getRequestReferences()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java new file mode 100755 index 000000000..181fe2138 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoResponseWrapperTest.java @@ -0,0 +1,105 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * Copyright (C) 2018 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +import java.util.UUID; + +import org.junit.Test; + +public class SoResponseWrapperTest { + + @Test + public void testConstructor() { + SOResponse response = new SOResponse(); + SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); + + assertEquals(response, obj.getSoResponse()); + assertEquals("reqID", obj.getRequestID()); + } + + @Test + public void testSetGet() { + SOResponse response = new SOResponse(); + SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); + + SOResponse response2 = new SOResponse(); + response2.setHttpResponseCode(2008); + obj.setSoResponse(response2); + assertEquals(response2, obj.getSoResponse()); + + obj.setRequestID("id2"); + assertEquals("id2", obj.getRequestID()); + } + + @Test + public void testSoResponseWrapperMethods() { + String requestId = UUID.randomUUID().toString(); + SOResponse response = new SOResponse(); + + SOResponseWrapper responseWrapper = new SOResponseWrapper(response, requestId); + assertNotNull(responseWrapper); + assertNotEquals(0, responseWrapper.hashCode()); + + assertEquals(response, responseWrapper.getSoResponse()); + + assertNotEquals(0, responseWrapper.hashCode()); + + assertEquals("SOResponseWrapper [SOResponse=org.onap.policy.", responseWrapper.toString().substring(0, 46)); + + SOResponseWrapper identicalResponseWrapper = new SOResponseWrapper(response, requestId); + + assertEquals(responseWrapper, responseWrapper); + assertEquals(responseWrapper, identicalResponseWrapper); + assertNotEquals(null, responseWrapper); + assertNotEquals("Hello", responseWrapper); + assertFalse(responseWrapper.equals(null)); + assertFalse(responseWrapper.equals("AString")); + + assertEquals(new SOResponseWrapper(null, null), new SOResponseWrapper(null, null)); + assertNotEquals(new SOResponseWrapper(null, null), identicalResponseWrapper); + + assertNotEquals(0, new SOResponseWrapper(null, null).hashCode()); + + identicalResponseWrapper.setSoResponse(new SOResponse()); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setSoResponse(response); + assertEquals(responseWrapper, identicalResponseWrapper); + + identicalResponseWrapper.setRequestID(UUID.randomUUID().toString()); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(requestId); + assertEquals(responseWrapper, identicalResponseWrapper); + + responseWrapper.setRequestID(null); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(null); + assertEquals(responseWrapper, identicalResponseWrapper); + responseWrapper.setRequestID(requestId); + assertNotEquals(responseWrapper, identicalResponseWrapper); + identicalResponseWrapper.setRequestID(requestId); + assertEquals(responseWrapper, identicalResponseWrapper); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java new file mode 100755 index 000000000..b0ce56652 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoServiceExceptionHolderTest.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoServiceExceptionHolderTest { + + @Test + public void testConstructor() { + SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); + + assertTrue(obj.getMessageId() == null); + assertTrue(obj.getText() == null); + assertTrue(obj.getVariables() != null); + assertEquals(0, obj.getVariables().size()); + } + + @Test + public void testSetGet() { + SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); + + obj.setMessageId("messageId"); + assertEquals("messageId", obj.getMessageId()); + + obj.setText("text"); + assertEquals("text", obj.getText()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java new file mode 100755 index 000000000..ea38bd597 --- /dev/null +++ b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/SoSubscriberInfoTest.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * so + * ================================================================================ + * + * ================================================================================ + * 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.onap.policy.so; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class SoSubscriberInfoTest { + + @Test + public void testConstructor() { + SOSubscriberInfo obj = new SOSubscriberInfo(); + + assertTrue(obj.getGlobalSubscriberId() == null); + assertTrue(obj.getSubscriberCommonSiteId() == null); + assertTrue(obj.getSubscriberName() == null); + } + + @Test + public void testSetGet() { + SOSubscriberInfo obj = new SOSubscriberInfo(); + + obj.setGlobalSubscriberId("globalSubscriberId"); + assertEquals("globalSubscriberId", obj.getGlobalSubscriberId()); + + obj.setSubscriberCommonSiteId("subscriberCommonSiteId"); + assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId()); + + obj.setSubscriberName("subscriberName"); + assertEquals("subscriberName", obj.getSubscriberName()); + } +} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java deleted file mode 100644 index 1b2cb697a..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestDemo.java +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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.onap.policy.so; - -import java.util.HashMap; -import java.util.Map; - -import org.junit.Test; -import org.onap.policy.so.SOCloudConfiguration; -import org.onap.policy.so.SOModelInfo; -import org.onap.policy.so.SORelatedInstance; -import org.onap.policy.so.SORelatedInstanceListElement; -import org.onap.policy.so.SORequest; -import org.onap.policy.so.SORequestDetails; -import org.onap.policy.so.SORequestInfo; -import org.onap.policy.so.SORequestParameters; -import org.onap.policy.so.util.Serialization; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class TestDemo { - private static final Logger logger = LoggerFactory.getLogger(TestDemo.class); - - @Test - public void test() { - - SORequest request = new SORequest(); - request.setRequestDetails(new SORequestDetails()); - request.getRequestDetails().setModelInfo(new SOModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SORequestInfo()); - request.getRequestDetails().setRequestParameters(new SORequestParameters()); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("ff5256d2-5a33-55df-13ab-12abad84e7ff"); - request.getRequestDetails().getModelInfo().setModelVersionId("fe6478e5-ea33-3346-ac12-ab121484a3fe"); - request.getRequestDetails().getModelInfo().setModelName("vSAMP12..base..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("1"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("mdt1"); - request.getRequestDetails().getCloudConfiguration().setTenantId("88a6ca3ee0394ade9403f075db23167e"); - - request.getRequestDetails().getRequestInfo().setInstanceName("SOTEST103a-vSAMP12_base_module-0"); - request.getRequestDetails().getRequestInfo().setSource("VID"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(true); - - SORelatedInstanceListElement relatedInstanceListElement1 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement3 = - new SORelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement3.setRelatedInstance(new SORelatedInstance()); - - relatedInstanceListElement1.getRelatedInstance().setInstanceId( - "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c"); - relatedInstanceListElement1.getRelatedInstance().setInstanceName( - "SOTESTVOL103a-vSAMP12_base_module-0_vol"); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("volumeGroup"); - - relatedInstanceListElement2.getRelatedInstance().setInstanceId("serviceInstanceId"); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff3514e3-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6985cd-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName( - "parent service model name"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - - relatedInstanceListElement3.getRelatedInstance().setInstanceId("vnfInstanceId"); - relatedInstanceListElement3.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelInvariantId( - "ff5256d1-5a33-55df-13ab-12abad84e7ff"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersionId( - "fe6478e4-ea33-3346-ac12-ab121484a3fe"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelName("vSAMP12"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelVersion("1.0"); - relatedInstanceListElement3.getRelatedInstance().getModelInfo().setModelCustomizationName("vSAMP12 1"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement3); - - Map userParam1 = new HashMap<>(); - userParam1.put("name1", "value1"); - - Map userParam2 = new HashMap<>(); - userParam2.put("name2", "value2"); - - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam1); - request.getRequestDetails().getRequestParameters().getUserParams().add(userParam2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - - } - - @Test - public void testHack() { - - logger.debug("** HACK **"); - - SORequest request = new SORequest(); - - request.setRequestDetails(new SORequestDetails()); - request.getRequestDetails().setModelInfo(new SOModelInfo()); - request.getRequestDetails().setCloudConfiguration(new SOCloudConfiguration()); - request.getRequestDetails().setRequestInfo(new SORequestInfo()); - request.getRequestDetails().setRequestParameters(new SORequestParameters()); - request.getRequestDetails().getRequestParameters().setUserParams(null); - - request.getRequestDetails().getModelInfo().setModelType("vfModule"); - request.getRequestDetails().getModelInfo().setModelInvariantId("a9c4a35a-de48-451a-9e4e-343f2ac52928"); - request.getRequestDetails().getModelInfo().setModelVersionId("e0d98ad1-238d-4555-b439-023d3f9079f6"); - request.getRequestDetails().getModelInfo().setModelName("0d9e0d9d352749f4B3cb..dnsscaling..module-0"); - request.getRequestDetails().getModelInfo().setModelVersion("2.0"); - - request.getRequestDetails().getCloudConfiguration().setLcpCloudRegionId("DFW"); - request.getRequestDetails().getCloudConfiguration().setTenantId("1015548"); - - request.getRequestDetails().getRequestInfo().setInstanceName( - "Vfmodule_Ete_Name1eScaling63928f-ccdc-4b34-bdef-9bf64109026e"); - request.getRequestDetails().getRequestInfo().setSource("POLICY"); - request.getRequestDetails().getRequestInfo().setSuppressRollback(false); - - SORelatedInstanceListElement relatedInstanceListElement1 = - new SORelatedInstanceListElement(); - SORelatedInstanceListElement relatedInstanceListElement2 = - new SORelatedInstanceListElement(); - relatedInstanceListElement1.setRelatedInstance(new SORelatedInstance()); - relatedInstanceListElement2.setRelatedInstance(new SORelatedInstance()); - - String serviceInstanceId = "98af39ce-6408-466b-921f-c2c7a8f59ed6"; - relatedInstanceListElement1.getRelatedInstance().setInstanceId(serviceInstanceId); - relatedInstanceListElement1.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelType("service"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelInvariantId( - "24329a0c-1d57-4210-b1af-a65df64e9d59"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersionId( - "ac642881-8e7e-4217-bd64-16ad41c42e30"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelName("5116d67e-0b4f-46bf-a46f"); - relatedInstanceListElement1.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - - String vnfInstanceId = "8eb411b8-a936-412f-b01f-9a9a435c0e93"; - relatedInstanceListElement2.getRelatedInstance().setInstanceId(vnfInstanceId); - relatedInstanceListElement2.getRelatedInstance().setModelInfo(new SOModelInfo()); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelType("vnf"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelInvariantId( - "09fd971e-db5f-475d-997c-cf6704b6b8fe"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersionId( - "152ed917-6dcc-46ee-bf8a-a775c5aa5a74"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelName("9e4c31d2-4b25-4d9e-9fb4"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelVersion("2.0"); - relatedInstanceListElement2.getRelatedInstance().getModelInfo().setModelCustomizationName( - "0d9e0d9d-3527-49f4-b3cb 2"); - - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement1); - request.getRequestDetails().getRelatedInstanceList().add(relatedInstanceListElement2); - - logger.debug(Serialization.gsonPretty.toJson(request)); - } - -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java deleted file mode 100755 index 7c50ea097..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoAsyncRequestStatus.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; - -import org.junit.Test; - -public class TestSoAsyncRequestStatus { - - @Test - public void testConstructor() { - SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); - - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getInstanceReferences() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SOAsyncRequestStatus obj = new SOAsyncRequestStatus(); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - SOInstanceReferences instanceReferences = new SOInstanceReferences(); - obj.setInstanceReferences(instanceReferences); - assertEquals(instanceReferences, obj.getInstanceReferences()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SORequestStatus requestStatus = new SORequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime); - assertEquals(startTime, obj.getStartTime()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java deleted file mode 100755 index bab8970bb..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoCloudConfiguration.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoCloudConfiguration { - - @Test - public void testConstructor() { - SOCloudConfiguration obj = new SOCloudConfiguration(); - - assertTrue(obj.getLcpCloudRegionId() == null); - assertTrue(obj.getTenantId() == null); - } - - @Test - public void testSetGet() { - SOCloudConfiguration obj = new SOCloudConfiguration(); - - obj.setLcpCloudRegionId("lcpCloudRegionId"); - assertEquals("lcpCloudRegionId", obj.getLcpCloudRegionId()); - - obj.setTenantId("tenantId"); - assertEquals("tenantId", obj.getTenantId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java deleted file mode 100644 index 2a352b0bf..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoDummyServer.java +++ /dev/null @@ -1,239 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 AT&T. 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.onap.policy.so; - -import com.google.gson.Gson; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.core.Response; - -@Path("/SO") -public class TestSoDummyServer { - - private static int postMessagesReceived = 0; - private static int putMessagesReceived = 0; - private static int statMessagesReceived = 0; - private static int getMessagesReceived = 0; - private static int deleteMessagesReceived = 0; - - private static Map ongoingRequestMap = new ConcurrentHashMap<>(); - - /** - * Stats method. - * - * @return response - */ - @GET - @Path("/Stats") - public Response serviceGetStats() { - statMessagesReceived++; - return Response.status(200).entity("{\"GET\": " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\": " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - - } - - /** - * Get stat type. - * - * @param statType the stat type - * @return http response - */ - @GET - @Path("/OneStat/{statType}") - public Response serviceGetStat(@PathParam("statType") final String statType) { - statMessagesReceived++; - return Response.status(200).entity("{\"TYPE\": " + statType + "}").build(); - } - - /** - * Post to service instantiation. - * - * @param jsonString string to send - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7") - public Response servicePostRequest(final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Post. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param jsonString json body - * @return http response - */ - @POST - @Path("/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/scaleOut") - public Response servicePostRequestVfModules(@PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, final String jsonString) { - postMessagesReceived++; - return buildResponse(jsonString); - } - - /** - * Get instance ID. - * - * @param nsInstanceId node instance id - * @return http response - */ - @GET - @Path("/orchestrationRequests/v5/{nsInstanceId}") - public Response soRequestStatus(@PathParam("nsInstanceId") final String nsInstanceId) { - - SOResponse response = ongoingRequestMap.get(nsInstanceId); - - int iterationsLeft = Integer.valueOf(response.getRequest().getRequestScope()); - if (--iterationsLeft > 0) { - response.getRequest().setRequestScope(new Integer(iterationsLeft).toString()); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - ongoingRequestMap.remove(nsInstanceId); - - if ("ReturnBadAfterWait".equals(response.getRequest().getRequestType())) { - return Response.status(400).build(); - } - - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.getRequest().setRequestScope("0"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()).entity(responseString).build(); - } - - /** - * Delete. - * - * @param serviceInstanceId service instance id - * @param vnfInstanceId vnf instance id - * @param vfModuleInstanceId vf module instance id - * @param jsonString json body - * @return http response - */ - @DELETE - @Path("/serviceInstances/v7/{serviceInstanceId}/vnfs/{vnfInstanceId}/vfModules/{vfModuleInstanceId}") - public Response serviceDeleteRequestVfModules( - @PathParam("serviceInstanceId") final String serviceInstanceId, - @PathParam("vnfInstanceId") final String vnfInstanceId, - @PathParam("vfModuleInstanceId") final String vfModuleInstanceId, - final String jsonString) { - deleteMessagesReceived++; - return buildResponse(jsonString); - } - - private Response buildResponse(String jsonString) { - if (jsonString == null) { - return Response.status(400).build(); - } - - SORequest request = null; - try { - request = new Gson().fromJson(jsonString, SORequest.class); - } catch (Exception e) { - return Response.status(400).build(); - } - - if (request == null) { - return Response.status(400).build(); - } - - if (request.getRequestType() == null) { - return Response.status(400).build(); - } - - if ("ReturnBadJson".equals(request.getRequestType())) { - return Response.status(200) - .entity("{\"GET\": , " + getMessagesReceived + ",\"STAT\": " + statMessagesReceived - + ",\"POST\":" + " , " + postMessagesReceived + ",\"PUT\": " + putMessagesReceived - + ",\"DELETE\": " + deleteMessagesReceived + "}").build(); - } - - SOResponse response = new SOResponse(); - response.setRequest(request); - response.setRequestReferences(new SORequestReferences()); - response.getRequestReferences().setRequestId(request.getRequestId().toString()); - - if ("ReturnCompleted".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("COMPLETE"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnFailed".equals(request.getRequestType())) { - response.getRequest().getRequestStatus().setRequestState("FAILED"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging202".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(202); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnOnging200".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - - if ("ReturnBadAfterWait".equals(request.getRequestType())) { - ongoingRequestMap.put(request.getRequestId().toString(), response); - - response.getRequest().getRequestStatus().setRequestState("ONGOING"); - response.setHttpResponseCode(200); - String responseString = new Gson().toJson(response, SOResponse.class); - return Response.status(response.getHttpResponseCode()) - .entity(responseString) - .build(); - } - return null; - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java deleted file mode 100755 index ee083ae08..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoInstanceReferences.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoInstanceReferences { - - @Test - public void testConstructor() { - SOInstanceReferences obj = new SOInstanceReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SOInstanceReferences obj = new SOInstanceReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java deleted file mode 100644 index 20cb54fca..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoManager.java +++ /dev/null @@ -1,404 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * TestSOManager - * ================================================================================ - * Copyright (C) 2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2018 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.io.IOException; -import java.net.URI; -import java.util.UUID; -import java.util.concurrent.Future; -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.util.EntityUtils; -import org.drools.core.WorkingMemory; -import org.glassfish.grizzly.http.server.HttpServer; -import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; -import org.glassfish.jersey.server.ResourceConfig; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; -import org.onap.policy.drools.system.PolicyEngine; - -public class TestSoManager { - private static final String BASE_URI = "http://localhost:46553/TestSOManager"; - private static final String BASE_SO_URI = BASE_URI + "/SO"; - private static HttpServer server; - - /** - * Set up test class. - */ - @BeforeClass - public static void setUp() throws IOException { - final ResourceConfig rc = new ResourceConfig(TestSoDummyServer.class); - //Grizzly by default doesn't allow payload for HTTP methods (ex: DELETE), for which HTTP spec doesn't - // explicitly state that. - //allow it before starting the server - server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc, false); - server.getServerConfiguration().setAllowPayloadForUndefinedHttpMethods(true); - server.start(); - } - - @AfterClass - public static void tearDown() throws Exception { - server.shutdown(); - } - - @Test - public void testGrizzlyServer() throws ClientProtocolException, IOException { - CloseableHttpClient httpclient = HttpClients.createDefault(); - HttpGet httpGet = new HttpGet("http://localhost:46553/TestSOManager/SO/Stats"); - CloseableHttpResponse response = httpclient.execute(httpGet); - - String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8"); - assertTrue(returnBody.matches("^\\{\"GET\": [0-9]*,\"STAT\": [0-9]*,\"POST\": [0-9]*,\"PUT\": [0-9]*," - + "\"DELETE\": [0-9]*\\}$")); - } - - @Test - public void testServiceInstantiation() throws IOException { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - SOResponse response = manager.createModuleInstance("http:/localhost:99999999", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", null); - assertNull(response); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", new SORequest()); - assertNull(response); - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - request.setRequestType("ReturnCompleted"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnFailed"); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNotNull(response); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - response = manager.createModuleInstance(BASE_SO_URI + "/serviceInstantiation/v7", BASE_SO_URI, "sean", - "citizen", request); - assertNull(response); - } - - @Test - public void testVfModuleCreation() throws IOException { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SORequest soRequest = new SORequest(); - soRequest.setOperationType(SoOperationType.SCALE_OUT); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.SCALE_OUT); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } - - @Test - public void testVfModuleDeletion() { - SOManager manager = new SOManager(); - assertNotNull(manager); - manager.setRestGetTimeout(100); - - PolicyEngine.manager.setEnvironmentProperty("so.username", "sean"); - PolicyEngine.manager.setEnvironmentProperty("so.password", "citizen"); - - WorkingMemory wm = new DummyWorkingMemory(); - - SORequest soRequest = new SORequest(); - soRequest.setOperationType(SoOperationType.DELETE_VF_MODULE); - PolicyEngine.manager.setEnvironmentProperty("so.url", "http:/localhost:99999999"); - Future asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, - UUID.randomUUID().toString(), UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - PolicyEngine.manager.setEnvironmentProperty("so.url", BASE_SO_URI); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), soRequest); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - SORequest request = new SORequest(); - request.setRequestId(UUID.randomUUID()); - request.setRequestScope("Test"); - request.setRequestType("ReturnBadJson"); - request.setStartTime("2018-03-23 16:31"); - request.setRequestStatus(new SORequestStatus()); - request.getRequestStatus().setRequestState("ONGOING"); - request.setOperationType(SoOperationType.DELETE_VF_MODULE); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnCompleted"); - - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnFailed"); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals("FAILED", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Use scope to set the number of iterations we'll wait for - - request.setRequestType("ReturnOnging200"); - request.setRequestScope(new Integer(10).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(20).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertNotNull(response.getRequest()); - assertEquals("COMPLETE", response.getRequest().getRequestStatus().getRequestState()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test timeout after 20 attempts for a response - request.setRequestType("ReturnOnging202"); - request.setRequestScope(new Integer(21).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - - // Test bad response after 3 attempts for a response - request.setRequestType("ReturnBadAfterWait"); - request.setRequestScope(new Integer(3).toString()); - asyncRestCallFuture = manager.asyncSORestCall(UUID.randomUUID().toString(), wm, UUID.randomUUID().toString(), - UUID.randomUUID().toString(), UUID.randomUUID().toString(), request); - try { - SOResponse response = asyncRestCallFuture.get(); - assertEquals(999, response.getHttpResponseCode()); - } catch (Exception e) { - fail("test should not throw an exception"); - } - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java deleted file mode 100755 index 037e82e4c..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoModelInfo.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoModelInfo { - - @Test - public void testConstructor() { - SOModelInfo obj = new SOModelInfo(); - - assertTrue(obj.getModelCustomizationId() == null); - assertTrue(obj.getModelCustomizationName() == null); - assertTrue(obj.getModelInvariantId() == null); - assertTrue(obj.getModelName() == null); - assertTrue(obj.getModelType() == null); - assertTrue(obj.getModelVersion() == null); - assertTrue(obj.getModelVersionId() == null); - } - - @Test - public void testSetGet() { - SOModelInfo obj = new SOModelInfo(); - - obj.setModelCustomizationId("modelCustomizationId"); - assertEquals("modelCustomizationId", obj.getModelCustomizationId()); - - obj.setModelCustomizationName("modelCustomizationName"); - assertEquals("modelCustomizationName", obj.getModelCustomizationName()); - - obj.setModelInvariantId("modelInvariantId"); - assertEquals("modelInvariantId", obj.getModelInvariantId()); - - obj.setModelName("modelName"); - assertEquals("modelName", obj.getModelName()); - - obj.setModelType("modelType"); - assertEquals("modelType", obj.getModelType()); - - obj.setModelVersion("modelVersion"); - assertEquals("modelVersion", obj.getModelVersion()); - - obj.setModelVersionId("modelVersionId"); - assertEquals("modelVersionId", obj.getModelVersionId()); - - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java deleted file mode 100755 index 1c619a8c6..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoPolicyExceptionHolder.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoPolicyExceptionHolder { - - @Test - public void testConstructor() { - SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - } - - @Test - public void testSetGet() { - SOPolicyExceptionHolder obj = new SOPolicyExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java deleted file mode 100755 index 048288377..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstance.java +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRelatedInstance { - - @Test - public void testConstructor() { - SORelatedInstance obj = new SORelatedInstance(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getModelInfo() == null); - } - - @Test - public void testSetGet() { - SORelatedInstance obj = new SORelatedInstance(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - SOModelInfo modelInfo = new SOModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java deleted file mode 100755 index 83f1d5849..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRelatedInstanceListElement.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRelatedInstanceListElement { - - @Test - public void testConstructor() { - SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); - - assertTrue(obj.getRelatedInstance() == null); - } - - @Test - public void testSetGet() { - SORelatedInstanceListElement obj = new SORelatedInstanceListElement(); - - SORelatedInstance relatedInstance = new SORelatedInstance(); - obj.setRelatedInstance(relatedInstance); - assertEquals(relatedInstance, obj.getRelatedInstance()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java deleted file mode 100755 index 2f9bf68bb..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.time.LocalDateTime; -import java.util.UUID; - -import org.junit.Test; - -public class TestSoRequest { - - @Test - public void testConstructor() { - SORequest obj = new SORequest(); - - assertTrue(obj.getFinishTime() == null); - assertTrue(obj.getRequestDetails() == null); - assertTrue(obj.getRequestId() == null); - assertTrue(obj.getRequestScope() == null); - assertTrue(obj.getRequestStatus() == null); - assertTrue(obj.getRequestType() == null); - assertTrue(obj.getStartTime() == null); - } - - @Test - public void testSetGet() { - SORequest obj = new SORequest(); - - LocalDateTime finishTime = LocalDateTime.now(); - obj.setFinishTime(finishTime); - assertEquals(finishTime, obj.getFinishTime()); - - UUID uuid = UUID.randomUUID(); - obj.setRequestId(uuid); - assertEquals(uuid, obj.getRequestId()); - - obj.setRequestScope("requestScope"); - assertEquals("requestScope", obj.getRequestScope()); - - SORequestStatus requestStatus = new SORequestStatus(); - obj.setRequestStatus(requestStatus); - assertEquals(requestStatus, obj.getRequestStatus()); - - obj.setRequestType("requestType"); - assertEquals("requestType", obj.getRequestType()); - - obj.setOperationType(SoOperationType.DELETE_VF_MODULE); - assertEquals(SoOperationType.DELETE_VF_MODULE, obj.getOperationType()); - - LocalDateTime startTime = LocalDateTime.now(); - obj.setStartTime(startTime.toString()); - assertEquals(startTime.toString(), obj.getStartTime()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java deleted file mode 100755 index c4b024593..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestDetails.java +++ /dev/null @@ -1,174 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 Ericsson. 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.Test; - -public class TestSoRequestDetails { - - @Test - public void testConstructor() { - SORequestDetails obj = new SORequestDetails(); - - assertTrue(obj.getCloudConfiguration() == null); - assertTrue(obj.getModelInfo() == null); - assertTrue(obj.getRequestInfo() == null); - assertTrue(obj.getRequestParameters() == null); - assertTrue(obj.getSubscriberInfo() == null); - - assertTrue(obj.getRelatedInstanceList() != null); - assertEquals(0, obj.getRelatedInstanceList().size()); - } - - @Test - public void testSetGet() { - SORequestDetails obj = new SORequestDetails(); - - SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); - obj.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, obj.getCloudConfiguration()); - - SOModelInfo modelInfo = new SOModelInfo(); - obj.setModelInfo(modelInfo); - assertEquals(modelInfo, obj.getModelInfo()); - - SORequestInfo requestInfo = new SORequestInfo(); - obj.setRequestInfo(requestInfo); - assertEquals(requestInfo, obj.getRequestInfo()); - - SORequestParameters requestParameters = new SORequestParameters(); - obj.setRequestParameters(requestParameters); - assertEquals(requestParameters, obj.getRequestParameters()); - - SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); - obj.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, obj.getSubscriberInfo()); - } - - @Test - public void testSoMRequestDetailsMethods() { - SORequestDetails details = new SORequestDetails(); - assertNotNull(details); - assertNotEquals(0, details.hashCode()); - - SOCloudConfiguration cloudConfiguration = new SOCloudConfiguration(); - details.setCloudConfiguration(cloudConfiguration); - assertEquals(cloudConfiguration, details.getCloudConfiguration()); - assertNotEquals(0, details.hashCode()); - - SOModelInfo modelInfo = new SOModelInfo(); - details.setModelInfo(modelInfo); - assertEquals(modelInfo, details.getModelInfo()); - assertNotEquals(0, details.hashCode()); - - List relatedInstanceList = new ArrayList<>(); - details.setRelatedInstanceList(relatedInstanceList); - assertEquals(relatedInstanceList, details.getRelatedInstanceList()); - assertNotEquals(0, details.hashCode()); - - SORequestInfo requestInfo = new SORequestInfo(); - details.setRequestInfo(requestInfo); - assertEquals(requestInfo, details.getRequestInfo()); - assertNotEquals(0, details.hashCode()); - - SORequestParameters requestParameters = new SORequestParameters(); - details.setRequestParameters(requestParameters); - assertEquals(requestParameters, details.getRequestParameters()); - assertNotEquals(0, details.hashCode()); - - SOSubscriberInfo subscriberInfo = new SOSubscriberInfo(); - details.setSubscriberInfo(subscriberInfo); - assertEquals(subscriberInfo, details.getSubscriberInfo()); - assertNotEquals(0, details.hashCode()); - - assertEquals("SORequestDetails [modelInfo=org.onap.policy.so", details.toString().substring(0, 46)); - - SORequestDetails copiedDetails = new SORequestDetails(details); - - assertTrue(details.equals(details)); - assertTrue(details.equals(copiedDetails)); - assertFalse(details.equals(null)); - assertFalse(details.equals("Hello")); - - details.setCloudConfiguration(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(null); - assertTrue(details.equals(copiedDetails)); - details.setCloudConfiguration(cloudConfiguration); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setCloudConfiguration(cloudConfiguration); - assertTrue(details.equals(copiedDetails)); - - details.setModelInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setModelInfo(modelInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setModelInfo(modelInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestInfo(requestInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestInfo(requestInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRequestParameters(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(null); - assertTrue(details.equals(copiedDetails)); - details.setRequestParameters(requestParameters); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRequestParameters(requestParameters); - assertTrue(details.equals(copiedDetails)); - - details.setSubscriberInfo(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(null); - assertTrue(details.equals(copiedDetails)); - details.setSubscriberInfo(subscriberInfo); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setSubscriberInfo(subscriberInfo); - assertTrue(details.equals(copiedDetails)); - - details.setRelatedInstanceList(null); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(null); - assertTrue(details.equals(copiedDetails)); - details.setRelatedInstanceList(relatedInstanceList); - assertFalse(details.equals(copiedDetails)); - copiedDetails.setRelatedInstanceList(relatedInstanceList); - assertTrue(details.equals(copiedDetails)); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java deleted file mode 100755 index a3c19cf41..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestError.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestError { - - @Test - public void testConstructor() { - SORequestError obj = new SORequestError(); - - assertTrue(obj.getPolicyException() == null); - assertTrue(obj.getServiceException() == null); - } - - @Test - public void testSetGet() { - SORequestError obj = new SORequestError(); - - SOPolicyExceptionHolder policyException = new SOPolicyExceptionHolder(); - obj.setPolicyException(policyException); - assertEquals(policyException, obj.getPolicyException()); - - SOServiceExceptionHolder serviceException = new SOServiceExceptionHolder(); - obj.setServiceException(serviceException); - assertEquals(serviceException, obj.getServiceException()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java deleted file mode 100755 index a77fe8bf4..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestInfo.java +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestInfo { - - @Test - public void testConstructor() { - SORequestInfo obj = new SORequestInfo(); - - assertTrue(obj.getBillingAccountNumber() == null); - assertTrue(obj.getCallbackUrl() == null); - assertTrue(obj.getCorrelator() == null); - assertTrue(obj.getInstanceName() == null); - assertTrue(obj.getOrderNumber() == null); - assertTrue(obj.getOrderVersion() == null); - assertTrue(obj.getProductFamilyId() == null); - assertTrue(obj.getRequestorId() == null); - assertTrue(obj.getSource() == null); - assertTrue(obj.isSuppressRollback() == false); - } - - @Test - public void testSetGet() { - SORequestInfo obj = new SORequestInfo(); - - obj.setBillingAccountNumber("billingAccountNumber"); - assertEquals("billingAccountNumber", obj.getBillingAccountNumber()); - - obj.setCallbackUrl("callbackUrl"); - assertEquals("callbackUrl", obj.getCallbackUrl()); - - obj.setCorrelator("correlator"); - assertEquals("correlator", obj.getCorrelator()); - - obj.setInstanceName("instanceName"); - assertEquals("instanceName", obj.getInstanceName()); - - obj.setOrderNumber("orderNumber"); - assertEquals("orderNumber", obj.getOrderNumber()); - - int orderVersion = 2008; - obj.setOrderVersion(orderVersion); - assertEquals((Integer) orderVersion, obj.getOrderVersion()); - - obj.setProductFamilyId("productFamilyId"); - assertEquals("productFamilyId", obj.getProductFamilyId()); - - obj.setRequestorId("requestorId"); - assertEquals("requestorId", obj.getRequestorId()); - - obj.setSource("source"); - assertEquals("source", obj.getSource()); - - obj.setSuppressRollback(true); - assertEquals(true, obj.isSuppressRollback()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java deleted file mode 100755 index 1ebf5d76f..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestParameters.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestParameters { - - @Test - public void testConstructor() { - SORequestParameters obj = new SORequestParameters(); - - assertTrue(obj.getSubscriptionServiceType() == null); - assertTrue(obj.getUserParams() != null); - assertEquals(0, obj.getUserParams().size()); - } - - @Test - public void testSetGet() { - SORequestParameters obj = new SORequestParameters(); - - obj.setSubscriptionServiceType("subscriptionServiceType"); - assertEquals("subscriptionServiceType", obj.getSubscriptionServiceType()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java deleted file mode 100755 index 498a2e00b..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestReferences.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestReferences { - - @Test - public void testConstructor() { - SORequestReferences obj = new SORequestReferences(); - - assertTrue(obj.getInstanceId() == null); - assertTrue(obj.getRequestId() == null); - } - - @Test - public void testSetGet() { - SORequestReferences obj = new SORequestReferences(); - - obj.setInstanceId("instanceId"); - assertEquals("instanceId", obj.getInstanceId()); - - obj.setRequestId("requestId"); - assertEquals("requestId", obj.getRequestId()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java deleted file mode 100755 index 1b8d745fd..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoRequestStatus.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoRequestStatus { - - @Test - public void testConstructor() { - SORequestStatus obj = new SORequestStatus(); - - assertEquals(0, obj.getPercentProgress()); - assertTrue(obj.getRequestState() == null); - assertTrue(obj.getTimestamp() == null); - assertFalse(obj.isWasRolledBack()); - } - - @Test - public void testSetGet() { - SORequestStatus obj = new SORequestStatus(); - - obj.setPercentProgress(2008); - assertEquals(2008, obj.getPercentProgress()); - - obj.setRequestState("requestState"); - assertEquals("requestState", obj.getRequestState()); - - obj.setTimestamp("timestamp"); - assertEquals("timestamp", obj.getTimestamp()); - - obj.setWasRolledBack(true); - assertTrue(obj.isWasRolledBack()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java deleted file mode 100755 index cf9a85e83..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponse.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoResponse { - - @Test - public void testConstructor() { - SOResponse obj = new SOResponse(); - - assertEquals(0, obj.getHttpResponseCode()); - assertTrue(obj.getRequest() == null); - assertTrue(obj.getRequestError() == null); - assertTrue(obj.getRequestReferences() == null); - } - - @Test - public void testSetGet() { - SOResponse obj = new SOResponse(); - - obj.setHttpResponseCode(2008); - assertEquals(2008, obj.getHttpResponseCode()); - - SORequest request = new SORequest(); - obj.setRequest(request); - assertEquals(request, obj.getRequest()); - - SORequestError requestError = new SORequestError(); - obj.setRequestError(requestError); - assertEquals(requestError, obj.getRequestError()); - - SORequestReferences requestReferences = new SORequestReferences(); - obj.setRequestReferences(requestReferences); - assertEquals(requestReferences, obj.getRequestReferences()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java deleted file mode 100755 index d7ef9708d..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoResponseWrapper.java +++ /dev/null @@ -1,105 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * Copyright (C) 2018 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.UUID; - -import org.junit.Test; - -public class TestSoResponseWrapper { - - @Test - public void testConstructor() { - SOResponse response = new SOResponse(); - SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); - - assertEquals(response, obj.getSoResponse()); - assertEquals("reqID", obj.getRequestID()); - } - - @Test - public void testSetGet() { - SOResponse response = new SOResponse(); - SOResponseWrapper obj = new SOResponseWrapper(response, "reqID"); - - SOResponse response2 = new SOResponse(); - response2.setHttpResponseCode(2008); - obj.setSoResponse(response2); - assertEquals(response2, obj.getSoResponse()); - - obj.setRequestID("id2"); - assertEquals("id2", obj.getRequestID()); - } - - @Test - public void testSoResponseWrapperMethods() { - String requestId = UUID.randomUUID().toString(); - SOResponse response = new SOResponse(); - - SOResponseWrapper responseWrapper = new SOResponseWrapper(response, requestId); - assertNotNull(responseWrapper); - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals(response, responseWrapper.getSoResponse()); - - assertNotEquals(0, responseWrapper.hashCode()); - - assertEquals("SOResponseWrapper [SOResponse=org.onap.policy.", responseWrapper.toString().substring(0, 46)); - - SOResponseWrapper identicalResponseWrapper = new SOResponseWrapper(response, requestId); - - assertEquals(responseWrapper, responseWrapper); - assertEquals(responseWrapper, identicalResponseWrapper); - assertNotEquals(null, responseWrapper); - assertNotEquals("Hello", responseWrapper); - assertFalse(responseWrapper.equals(null)); - assertFalse(responseWrapper.equals("AString")); - - assertEquals(new SOResponseWrapper(null, null), new SOResponseWrapper(null, null)); - assertNotEquals(new SOResponseWrapper(null, null), identicalResponseWrapper); - - assertNotEquals(0, new SOResponseWrapper(null, null).hashCode()); - - identicalResponseWrapper.setSoResponse(new SOResponse()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setSoResponse(response); - assertEquals(responseWrapper, identicalResponseWrapper); - - identicalResponseWrapper.setRequestID(UUID.randomUUID().toString()); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - - responseWrapper.setRequestID(null); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(null); - assertEquals(responseWrapper, identicalResponseWrapper); - responseWrapper.setRequestID(requestId); - assertNotEquals(responseWrapper, identicalResponseWrapper); - identicalResponseWrapper.setRequestID(requestId); - assertEquals(responseWrapper, identicalResponseWrapper); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java deleted file mode 100755 index 7c802efaf..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoServiceExceptionHolder.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoServiceExceptionHolder { - - @Test - public void testConstructor() { - SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); - - assertTrue(obj.getMessageId() == null); - assertTrue(obj.getText() == null); - assertTrue(obj.getVariables() != null); - assertEquals(0, obj.getVariables().size()); - } - - @Test - public void testSetGet() { - SOServiceExceptionHolder obj = new SOServiceExceptionHolder(); - - obj.setMessageId("messageId"); - assertEquals("messageId", obj.getMessageId()); - - obj.setText("text"); - assertEquals("text", obj.getText()); - } -} diff --git a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java b/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java deleted file mode 100755 index b0662fa30..000000000 --- a/controlloop/common/model-impl/so/src/test/java/org/onap/policy/so/TestSoSubscriberInfo.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * so - * ================================================================================ - * - * ================================================================================ - * 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.onap.policy.so; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -public class TestSoSubscriberInfo { - - @Test - public void testConstructor() { - SOSubscriberInfo obj = new SOSubscriberInfo(); - - assertTrue(obj.getGlobalSubscriberId() == null); - assertTrue(obj.getSubscriberCommonSiteId() == null); - assertTrue(obj.getSubscriberName() == null); - } - - @Test - public void testSetGet() { - SOSubscriberInfo obj = new SOSubscriberInfo(); - - obj.setGlobalSubscriberId("globalSubscriberId"); - assertEquals("globalSubscriberId", obj.getGlobalSubscriberId()); - - obj.setSubscriberCommonSiteId("subscriberCommonSiteId"); - assertEquals("subscriberCommonSiteId", obj.getSubscriberCommonSiteId()); - - obj.setSubscriberName("subscriberName"); - assertEquals("subscriberName", obj.getSubscriberName()); - } -} -- cgit 1.2.3-korg