From 57867d108c2f4db22379f5148c9dbab85a29662f Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Thu, 15 Feb 2018 16:04:12 +0100 Subject: Code refactoring Code refactoring, mainly Classes/Methods name renaming Issue-ID: CLAMP-85 Change-Id: I12bd190576e324ed33f057dc1a4ad32c16fcb6c2 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/AbstractItCase.java | 4 +- .../clds/it/CldsReferencePropertiesItCase.java | 63 ++++++++++++++++++++++ .../clamp/clds/it/HolmesPolicyDelegateItCase.java | 4 +- .../clamp/clds/it/OperationPolicyReqItCase.java | 6 +-- .../org/onap/clamp/clds/it/PolicyClientItCase.java | 8 +-- .../java/org/onap/clamp/clds/it/RefPropItCase.java | 63 ---------------------- .../clamp/clds/it/SdcCatalogServicesItCase.java | 54 +++++++++---------- .../java/org/onap/clamp/clds/it/SdcReqItCase.java | 8 +-- .../clamp/clds/it/TcaRequestFormatterItCase.java | 2 +- .../clamp/clds/model/prop/CustomModelElement.java | 4 ++ .../clds/model/prop/CustomModelElementTest.java | 1 + .../clamp/clds/model/prop/ModelPropertiesTest.java | 4 ++ src/test/resources/http-cache/start_http_cache.sh | 2 +- 13 files changed, 116 insertions(+), 107 deletions(-) create mode 100644 src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java delete mode 100644 src/test/java/org/onap/clamp/clds/it/RefPropItCase.java (limited to 'src/test') diff --git a/src/test/java/org/onap/clamp/clds/AbstractItCase.java b/src/test/java/org/onap/clamp/clds/AbstractItCase.java index 2903248b..7e290884 100644 --- a/src/test/java/org/onap/clamp/clds/AbstractItCase.java +++ b/src/test/java/org/onap/clamp/clds/AbstractItCase.java @@ -25,7 +25,7 @@ package org.onap.clamp.clds; import org.junit.BeforeClass; import org.onap.clamp.clds.client.req.policy.PolicyClient; -import org.onap.clamp.clds.model.refprop.RefProp; +import org.onap.clamp.clds.config.CldsReferenceProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ActiveProfiles; @@ -33,7 +33,7 @@ import org.springframework.test.context.ActiveProfiles; public abstract class AbstractItCase { @Autowired - protected RefProp refProp; + protected CldsReferenceProperties refProp; @Autowired protected PolicyClient policyClient; diff --git a/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java new file mode 100644 index 00000000..6c94fc16 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/it/CldsReferencePropertiesItCase.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2017-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============================================ + * =================================================================== + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ + +package org.onap.clamp.clds.it; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.IOException; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.clamp.clds.AbstractItCase; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +/** + * Test corg.onap.clamp.ClampDesigner.model.refprop package using RefProp. + */ +@RunWith(SpringRunner.class) +@SpringBootTest +public class CldsReferencePropertiesItCase extends AbstractItCase { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsReferencePropertiesItCase.class); + + /** + * Test getting prop value as a JSON Node / template. + * + * @throws IOException + * when JSON parsing fails + */ + @Test + public void testJsonTemplate() throws IOException { + ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template"); + root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"); + ObjectMapper mapper = new ObjectMapper(); + String jsonText = mapper.writeValueAsString(root); + logger.error("Exception caught IllegalArgumentException as expected"); + // assertEquals(topicsJson, ref.getTopicsToJson()); + } +} diff --git a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java index 6f5c24d5..c530a059 100644 --- a/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/HolmesPolicyDelegateItCase.java @@ -31,8 +31,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.HolmesPolicyDelegate; -import org.onap.clamp.clds.model.prop.Holmes; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; diff --git a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java index 9013e0c4..873b0192 100644 --- a/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/OperationPolicyReqItCase.java @@ -38,9 +38,9 @@ import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.policy.api.AttributeType; import org.onap.policy.controlloop.policy.builder.BuilderException; diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java index 71bd2d52..0e8a2177 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java @@ -37,10 +37,10 @@ import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.policy.OperationalPolicyReq; import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; -import org.onap.clamp.clds.model.prop.Policy; -import org.onap.clamp.clds.model.prop.PolicyChain; -import org.onap.clamp.clds.model.prop.Tca; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.PolicyChain; +import org.onap.clamp.clds.model.properties.Tca; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.policy.api.AttributeType; import org.springframework.boot.test.context.SpringBootTest; diff --git a/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java b/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java deleted file mode 100644 index 8f76b182..00000000 --- a/src/test/java/org/onap/clamp/clds/it/RefPropItCase.java +++ /dev/null @@ -1,63 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-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============================================ - * =================================================================== - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ - -package org.onap.clamp.clds.it; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.IOException; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.clamp.clds.AbstractItCase; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Test corg.onap.clamp.ClampDesigner.model.refprop package using RefProp. - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class RefPropItCase extends AbstractItCase { - - protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefPropItCase.class); - - /** - * Test getting prop value as a JSON Node / template. - * - * @throws IOException - * when JSON parsing fails - */ - @Test - public void testJsonTemplate() throws IOException { - ObjectNode root = (ObjectNode) refProp.getJsonTemplate("tca.template"); - root.put("closedLoopControlName", "ClosedLoop-FRWL-SIG-1582f840-2881-11e6-b4ec-005056a9d756"); - ObjectMapper mapper = new ObjectMapper(); - String jsonText = mapper.writeValueAsString(root); - logger.error("Exception caught IllegalArgumentException as expected"); - // assertEquals(topicsJson, ref.getTopicsToJson()); - } -} diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java index 548212ef..7f962215 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java @@ -35,10 +35,10 @@ import org.mockito.Mockito; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices; import org.onap.clamp.clds.model.CldsAlarmCondition; -import org.onap.clamp.clds.model.CldsSdcResource; -import org.onap.clamp.clds.model.CldsSdcResourceBasicInfo; -import org.onap.clamp.clds.model.CldsSdcServiceInfo; import org.onap.clamp.clds.model.CldsServiceData; +import org.onap.clamp.clds.model.sdc.SdcResource; +import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo; +import org.onap.clamp.clds.model.sdc.SdcServiceInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @@ -55,33 +55,33 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateServicesTest() { - CldsSdcServiceInfo service1a = new CldsSdcServiceInfo(); + SdcServiceInfo service1a = new SdcServiceInfo(); service1a.setName("service1"); service1a.setVersion("1.0"); service1a.setInvariantUUID("invariantUUID1.0"); - List rawCldsSdcServiceList = new LinkedList<>(); + List rawCldsSdcServiceList = new LinkedList<>(); rawCldsSdcServiceList.add(service1a); rawCldsSdcServiceList.add(service1a); - CldsSdcServiceInfo service1b = new CldsSdcServiceInfo(); + SdcServiceInfo service1b = new SdcServiceInfo(); service1b.setName("service1"); service1b.setVersion("1.1"); service1b.setInvariantUUID("invariantUUID1.1"); rawCldsSdcServiceList.add(service1b); - CldsSdcServiceInfo service1c = new CldsSdcServiceInfo(); + SdcServiceInfo service1c = new SdcServiceInfo(); service1c.setName("service1"); service1c.setVersion("1.2"); service1c.setInvariantUUID("invariantUUID1.2"); rawCldsSdcServiceList.add(service1c); - CldsSdcServiceInfo service2 = new CldsSdcServiceInfo(); + SdcServiceInfo service2 = new SdcServiceInfo(); service2.setName("service2"); service2.setVersion("1.0"); service2.setInvariantUUID("invariantUUID2.0"); rawCldsSdcServiceList.add(service2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList); + List resultList = catalogServices.removeDuplicateServices(rawCldsSdcServiceList); assertTrue(resultList.size() == 2); - CldsSdcServiceInfo res1; - CldsSdcServiceInfo res2; + SdcServiceInfo res1; + SdcServiceInfo res2; if ("service1".equals(resultList.get(0).getName())) { res1 = resultList.get(0); res2 = resultList.get(1); @@ -97,27 +97,27 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateSdcResourceInstancesTest() { - List rawCldsSdcResourceList = new LinkedList<>(); - CldsSdcResource sdcResource1a = new CldsSdcResource(); + List rawCldsSdcResourceList = new LinkedList<>(); + SdcResource sdcResource1a = new SdcResource(); sdcResource1a.setResourceInstanceName("resource1"); sdcResource1a.setResourceVersion("1.0"); rawCldsSdcResourceList.add(sdcResource1a); - CldsSdcResource sdcResource1b = new CldsSdcResource(); + SdcResource sdcResource1b = new SdcResource(); sdcResource1b.setResourceInstanceName("resource1"); sdcResource1b.setResourceVersion("1.1"); rawCldsSdcResourceList.add(sdcResource1b); - CldsSdcResource sdcResource1c = new CldsSdcResource(); + SdcResource sdcResource1c = new SdcResource(); sdcResource1c.setResourceInstanceName("resource1"); sdcResource1c.setResourceVersion("1.2"); rawCldsSdcResourceList.add(sdcResource1c); - CldsSdcResource sdcResource2 = new CldsSdcResource(); + SdcResource sdcResource2 = new SdcResource(); sdcResource2.setResourceInstanceName("resource2"); sdcResource2.setResourceVersion("1.0"); rawCldsSdcResourceList.add(sdcResource2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); - CldsSdcResource res1; - CldsSdcResource res2; + List resultList = catalogServices.removeDuplicateSdcResourceInstances(rawCldsSdcResourceList); + SdcResource res1; + SdcResource res2; if ("resource1".equals(resultList.get(0).getResourceInstanceName())) { res1 = resultList.get(0); res2 = resultList.get(1); @@ -133,28 +133,28 @@ public class SdcCatalogServicesItCase extends AbstractItCase { @Test public void removeDuplicateSdcResourceBasicInfoTest() { - List rawCldsSdcResourceList = new LinkedList<>(); - CldsSdcResourceBasicInfo sdcResource1a = new CldsSdcResourceBasicInfo(); + List rawCldsSdcResourceList = new LinkedList<>(); + SdcResourceBasicInfo sdcResource1a = new SdcResourceBasicInfo(); sdcResource1a.setName("resource1"); sdcResource1a.setVersion("1.0"); rawCldsSdcResourceList.add(sdcResource1a); - CldsSdcResourceBasicInfo sdcResource1b = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource1b = new SdcResourceBasicInfo(); sdcResource1b.setName("resource1"); sdcResource1b.setVersion("1.1"); rawCldsSdcResourceList.add(sdcResource1b); - CldsSdcResourceBasicInfo sdcResource1c = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource1c = new SdcResourceBasicInfo(); sdcResource1c.setName("resource1"); sdcResource1c.setVersion("1.2"); rawCldsSdcResourceList.add(sdcResource1c); - CldsSdcResourceBasicInfo sdcResource2 = new CldsSdcResourceBasicInfo(); + SdcResourceBasicInfo sdcResource2 = new SdcResourceBasicInfo(); sdcResource2.setName("resource2"); sdcResource2.setVersion("1.0"); rawCldsSdcResourceList.add(sdcResource2); SdcCatalogServices catalogServices = new SdcCatalogServices(); - List resultList = catalogServices + List resultList = catalogServices .removeDuplicateSdcResourceBasicInfo(rawCldsSdcResourceList); - CldsSdcResourceBasicInfo res1; - CldsSdcResourceBasicInfo res2; + SdcResourceBasicInfo res1; + SdcResourceBasicInfo res2; if ("resource1".equals(resultList.get(0).getName())) { res1 = resultList.get(0); res2 = resultList.get(1); diff --git a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java index afff9dd7..2efc5286 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcReqItCase.java @@ -36,9 +36,9 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; -import org.onap.clamp.clds.client.req.sdc.SdcReq; +import org.onap.clamp.clds.client.req.sdc.SdcRequests; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.beans.factory.annotation.Autowired; @@ -50,7 +50,7 @@ import org.springframework.test.context.junit4.SpringRunner; public class SdcReqItCase extends AbstractItCase { @Autowired - private SdcReq sdcReq; + private SdcRequests sdcReq; private String modelBpmnProp; private String modelBpmn; private String modelName; @@ -98,7 +98,7 @@ public class SdcReqItCase extends AbstractItCase { @Test public void getSdcReqUrlsListTest() throws GeneralSecurityException, DecoderException { - List listUrls = sdcReq.getSdcReqUrlsList(modelProperties, refProp.getStringValue("sdc.serviceUrl")); + List listUrls = sdcReq.getSdcReqUrlsList(modelProperties); assertNotNull(listUrls); assertTrue(listUrls.size() == 1); assertTrue(listUrls.get(0).contains( diff --git a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java index 419bfde2..c290a386 100644 --- a/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/TcaRequestFormatterItCase.java @@ -35,7 +35,7 @@ import org.junit.runner.RunWith; import org.onap.clamp.clds.AbstractItCase; import org.onap.clamp.clds.client.req.tca.TcaRequestFormatter; import org.onap.clamp.clds.model.CldsEvent; -import org.onap.clamp.clds.model.prop.ModelProperties; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; import org.skyscreamer.jsonassert.JSONAssert; import org.springframework.boot.test.context.SpringBootTest; diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java index 138d727c..d3694aea 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java @@ -25,6 +25,10 @@ package org.onap.clamp.clds.model.prop; import com.fasterxml.jackson.databind.JsonNode; +import org.onap.clamp.clds.model.properties.AbstractModelElement; +import org.onap.clamp.clds.model.properties.ModelBpmn; +import org.onap.clamp.clds.model.properties.ModelProperties; + /** * A CustomModelElement to test the capability to add new elements on the fly. */ diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java index 46c70e55..851556a6 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElementTest.java @@ -27,6 +27,7 @@ import java.io.IOException; import org.junit.Assert; import org.junit.Test; +import org.onap.clamp.clds.model.properties.ModelProperties; import org.onap.clamp.clds.util.ResourceFileUtil; public class CustomModelElementTest { diff --git a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java index 7bb11a9e..a7ab94c5 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java @@ -32,6 +32,10 @@ import java.io.IOException; import org.junit.Before; import org.junit.Test; import org.onap.clamp.clds.model.CldsModel; +import org.onap.clamp.clds.model.properties.Holmes; +import org.onap.clamp.clds.model.properties.ModelProperties; +import org.onap.clamp.clds.model.properties.Policy; +import org.onap.clamp.clds.model.properties.Tca; import org.onap.clamp.clds.util.ResourceFileUtil; /** diff --git a/src/test/resources/http-cache/start_http_cache.sh b/src/test/resources/http-cache/start_http_cache.sh index 591fd504..f318256a 100755 --- a/src/test/resources/http-cache/start_http_cache.sh +++ b/src/test/resources/http-cache/start_http_cache.sh @@ -34,4 +34,4 @@ fi echo 'Installing requests packages for Python' pip install requests echo 'Executing the Http proxy in Cache mode only' -python sdc_proxy.py --port 8080 --root /usr/src/http-cache-app/data-cache \ No newline at end of file +python sdc_proxy.py --port 2080 --root /usr/src/http-cache-app/data-cache -- cgit 1.2.3-korg