diff options
author | Jim Hahn <jrh3@att.com> | 2019-06-13 10:39:55 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-06-17 10:50:16 -0400 |
commit | d37c71292d9cbdd892f328d63f49a8027b1f13c4 (patch) | |
tree | 615a8af45285d1032a02af1214c76b938c58044d /models-interactions/model-actors/actor.appc | |
parent | f59ec395bf1e41df894f884e70ff3185280668c0 (diff) |
Fix simple sonar issues in models
Added @FunctionalInterface where needed.
Replaced anonymous classes with lambda expressions.
Replaced duplicate strings with a constant.
Removed unused BeforeClass & AfterClass test methods.
Removed some trailing spaces.
Fixed:
aai
actor.appc
actor.appclcm
actor.sdnc
actor.sdnr
actor.so
actor.vfc
actorServiceProvider
appc
appclcm
cds
events
Change-Id: I0e21cbb10db6d1217bbd0e00e6dd4fac3eb84e31
Issue-ID: POLICY-1791
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.appc')
-rw-r--r-- | models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java index b917406cd..553dfde9b 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java @@ -24,12 +24,10 @@ package org.onap.policy.controlloop.actor.appc; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.time.Instant; import java.util.HashMap; import java.util.UUID; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -51,6 +49,12 @@ import org.slf4j.LoggerFactory; public class AppcServiceProviderTest { + private static final String GENERIC_VNF_ID = "generic-vnf.vnf-id"; + + private static final String MODIFY_CONFIG = "ModifyConfig"; + + private static final String JSON_OUTPUT = "JSON Output: \n"; + private static final Logger logger = LoggerFactory.getLogger(AppcServiceProviderTest.class); private static final VirtualControlLoopEvent onsetEvent; @@ -85,7 +89,7 @@ public class AppcServiceProviderTest { /* Construct an operation with an APPC actor and ModifyConfig operation. */ operation = new ControlLoopOperation(); operation.setActor("APPC"); - operation.setOperation("ModifyConfig"); + operation.setOperation(MODIFY_CONFIG); operation.setTarget("VNF"); operation.setEnd(Instant.now()); operation.setSubRequestId("1"); @@ -97,7 +101,7 @@ public class AppcServiceProviderTest { policy.setActor("APPC"); policy.setTarget(new Target(TargetType.VNF)); policy.getTarget().setResourceID("Eace933104d443b496b8.nodes.heat.vpg"); - policy.setRecipe("ModifyConfig"); + policy.setRecipe(MODIFY_CONFIG); policy.setPayload(null); policy.setRetry(2); policy.setTimeout(300); @@ -106,14 +110,11 @@ public class AppcServiceProviderTest { /** * Set up before test class. + * @throws Exception if the A&AI simulator cannot be started */ @BeforeClass - public static void setUpSimulator() { - try { - Util.buildAaiSim(); - } catch (Exception e) { - fail(e.getMessage()); - } + public static void setUpSimulator() throws Exception { + Util.buildAaiSim(); } /** @@ -142,12 +143,12 @@ public class AppcServiceProviderTest { /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); - assertEquals("ModifyConfig", appcRequest.getAction()); + assertEquals(MODIFY_CONFIG, appcRequest.getAction()); /* A payload is required and cannot be null */ assertNotNull(appcRequest.getPayload()); - assertTrue(appcRequest.getPayload().containsKey("generic-vnf.vnf-id")); - assertNotNull(appcRequest.getPayload().get("generic-vnf.vnf-id")); + assertTrue(appcRequest.getPayload().containsKey(GENERIC_VNF_ID)); + assertNotNull(appcRequest.getPayload().get(GENERIC_VNF_ID)); assertTrue(appcRequest.getPayload().containsKey(KEY1)); assertTrue(appcRequest.getPayload().containsKey(KEY2)); @@ -155,14 +156,14 @@ public class AppcServiceProviderTest { /* Print out request as json to make sure serialization works */ String jsonRequest = Serialization.gsonPretty.toJson(appcRequest); - logger.debug("JSON Output: \n" + jsonRequest); + logger.debug(JSON_OUTPUT + jsonRequest); /* The JSON string must contain the following fields */ assertTrue(jsonRequest.contains("CommonHeader")); assertTrue(jsonRequest.contains("Action")); - assertTrue(jsonRequest.contains("ModifyConfig")); + assertTrue(jsonRequest.contains(MODIFY_CONFIG)); assertTrue(jsonRequest.contains("Payload")); - assertTrue(jsonRequest.contains("generic-vnf.vnf-id")); + assertTrue(jsonRequest.contains(GENERIC_VNF_ID)); assertTrue(jsonRequest.contains(KEY1)); assertTrue(jsonRequest.contains(KEY2)); assertTrue(jsonRequest.contains(SUBKEY)); @@ -173,7 +174,7 @@ public class AppcServiceProviderTest { appcResponse.getStatus().setDescription("AppC success"); /* Print out request as json to make sure serialization works */ String jsonResponse = Serialization.gsonPretty.toJson(appcResponse); - logger.debug("JSON Output: \n" + jsonResponse); + logger.debug(JSON_OUTPUT + jsonResponse); } @Test @@ -191,32 +192,32 @@ public class AppcServiceProviderTest { /* An action is required and cannot be null */ assertNotNull(appcRequest.getAction()); - assertEquals("ModifyConfig", appcRequest.getAction()); + assertEquals(MODIFY_CONFIG, appcRequest.getAction()); /* A payload is required and cannot be null */ assertNotNull(appcRequest.getPayload()); - assertTrue(appcRequest.getPayload().containsKey("generic-vnf.vnf-id")); - assertNotNull(appcRequest.getPayload().get("generic-vnf.vnf-id")); + assertTrue(appcRequest.getPayload().containsKey(GENERIC_VNF_ID)); + assertNotNull(appcRequest.getPayload().get(GENERIC_VNF_ID)); logger.debug("APPC Request: \n" + appcRequest.toString()); /* Print out request as json to make sure serialization works */ String jsonRequest = Serialization.gsonPretty.toJson(appcRequest); - logger.debug("JSON Output: \n" + jsonRequest); + logger.debug(JSON_OUTPUT + jsonRequest); /* The JSON string must contain the following fields */ assertTrue(jsonRequest.contains("CommonHeader")); assertTrue(jsonRequest.contains("Action")); - assertTrue(jsonRequest.contains("ModifyConfig")); + assertTrue(jsonRequest.contains(MODIFY_CONFIG)); assertTrue(jsonRequest.contains("Payload")); - assertTrue(jsonRequest.contains("generic-vnf.vnf-id")); + assertTrue(jsonRequest.contains(GENERIC_VNF_ID)); Response appcResponse = new Response(appcRequest); appcResponse.getStatus().setCode(ResponseCode.SUCCESS.getValue()); appcResponse.getStatus().setDescription("AppC success"); /* Print out request as json to make sure serialization works */ String jsonResponse = Serialization.gsonPretty.toJson(appcResponse); - logger.debug("JSON Output: \n" + jsonResponse); + logger.debug(JSON_OUTPUT + jsonResponse); } @Test |