summaryrefslogtreecommitdiffstats
path: root/runtime/src/test/java
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2021-06-16 12:08:01 +0100
committerliamfallon <liam.fallon@est.tech>2021-06-17 15:51:34 +0100
commit2d186df9e3ed47599dbc86c2f435f7884535398c (patch)
treed77b85e48927ad072248e784c7b99b12205f4e0b /runtime/src/test/java
parent17f5d3c97e47064407452122bc6cb801e43df5f9 (diff)
Clean up CLAMP Sonar and checkstyle issues
This commit cleans up sonar and checkstyle issues identified in the CLAMP repository. Issue-ID: POLICY-3206 Change-Id: I16b61bbe771cc17de15183a24b2a5e82a8d35872 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'runtime/src/test/java')
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java21
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java6
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java7
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java10
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java3
14 files changed, 35 insertions, 33 deletions
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
index 557a2e96c..45d4d64b1 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
@@ -70,6 +70,8 @@ public class AuthorizationControllerItCase {
public static void setupBefore() {
sc.setAuthentication(new Authentication() {
+ private static final long serialVersionUID = -6282526745791629050L;
+
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return Arrays.asList(new SimpleGrantedAuthority(
@@ -121,7 +123,7 @@ public class AuthorizationControllerItCase {
@Test
public void testIsUserPermitted() {
- assertEquals(AuthorizationController.getPrincipalName(sc), "admin");
+ assertEquals("admin", AuthorizationController.getPrincipalName(sc));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "dev", "read")));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage", "dev", "DEPLOY")));
assertTrue(auth.isUserPermitted(
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
index 017881ba7..ad7efed36 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
@@ -67,11 +67,13 @@ public class RobotItCase {
public void robotTests() throws Exception {
File robotFolder = new File(getClass().getClassLoader().getResource("robotframework").getFile());
Volume testsVolume = new Volume("/opt/robotframework/tests");
- DockerClient client = DockerClientBuilder
- .getInstance()
- .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
- .build();
-
+ // @formatter:off
+ DockerClient client =
+ DockerClientBuilder
+ .getInstance()
+ .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
+ .build();
+ // @formatter:on
BuildImageResultCallback callback = new BuildImageResultCallback() {
@Override
@@ -82,14 +84,17 @@ public class RobotItCase {
};
String imageId = client.buildImageCmd(robotFolder).exec(callback).awaitImageId();
- CreateContainerResponse createContainerResponse = client.createContainerCmd(imageId)
+ // @formatter:off
+ CreateContainerResponse createContainerResponse =
+ client
+ .createContainerCmd(imageId)
.withVolumes(testsVolume)
- .withBinds(
- new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
+ .withBinds(new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
.withEnv("CLAMP_PORT=" + httpPort)
.withStopTimeout(TIMEOUT_S)
.withNetworkMode("host")
.exec();
+ // @formatter:on
String id = createContainerResponse.getId();
client.startContainerCmd(id).exec();
InspectContainerResponse exec;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
index 08e425abf..423876ede 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
@@ -55,7 +55,6 @@ public class CsarHandlerTest {
private static final String SERVICE_UUID = "serviceUUID";
private static final String RESOURCE1_UUID = "resource1UUID";
private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
- private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
private static final String BLUEPRINT2_NAME = "FOI.Simfoimap223S0112.event_proc_bp2.yaml";
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
index 6f6f5c104..9cf7cee6b 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
@@ -47,9 +47,10 @@ public class ArrayFieldTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
ArrayField arrayParser = new ArrayField((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
JsonArray toTest = arrayParser.deploy();
String reference = "[1,\"String\",5.5,true]";
assertEquals(reference, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
index 493ee992c..06a8bdac8 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
@@ -48,6 +48,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get value array.
*/
+ @SuppressWarnings("unchecked")
public void testGetValuesArray() {
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("timeout");
JsonTemplate jsonTemplate = jsonTemplateManager.getJsonSchemaTemplates().get("integer");
@@ -70,6 +71,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get Specific length.
*/
+ @SuppressWarnings("unchecked")
public void testGetSpecificLength() {
//Test for string type, same process for array
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("id");
@@ -88,6 +90,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get limit value.
*/
+ @SuppressWarnings("unchecked")
public void testGetLimitValue() {
//Test for array type, same process for string
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("description");
@@ -102,5 +105,4 @@ public class ConstraintTest extends TestCase {
toTest = resultProcess.get("maxItems").getAsInt();
assertEquals(7, toTest);
}
-
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
index 5652fa9cd..c43b84a66 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
@@ -50,6 +50,7 @@ public class ToscaElementPropertyTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
JsonArray toTest =
toscaElementProperty.parseArray((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
assertNotNull(toTest);
@@ -60,6 +61,7 @@ public class ToscaElementPropertyTest extends TestCase {
*
* @throws IOException In case of failure
*/
+ @SuppressWarnings("unchecked")
public void testAddConstraintsAsJson() throws IOException {
JsonTemplateManager jsonTemplateManager = new JsonTemplateManager(
ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
@@ -76,4 +78,4 @@ public class ToscaElementPropertyTest extends TestCase {
String test = "{\"enum\":[\"error\",\"timeout\",\"retries\",\"guard\",\"exception\"]}";
assertEquals(test, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
index ab6a41bca..4b93ed7be 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
@@ -132,7 +132,7 @@ public class LoggingUtilsTest {
assertEquals(targetServiceName, mdc.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME));
}
- private boolean checkMapKeys(Map map, String[] keys) {
+ private boolean checkMapKeys(Map<String, String> map, String[] keys) {
return Arrays.stream(keys).allMatch(key -> map.get(key) != null);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
index 622fd5999..1cc7e9032 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
@@ -24,7 +24,6 @@
package org.onap.policy.clamp.flow;
-import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -74,8 +73,8 @@ public class FlowLogOperationTest {
// then
String entity = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_ENTITY);
String serviceName = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME);
- assertEquals(entity, mockEntity);
- assertEquals(serviceName, mockServiceName);
+ assertThat(entity).isEqualTo(mockEntity);
+ assertThat(serviceName).isEqualTo(mockServiceName);
}
@Test
@@ -99,4 +98,4 @@ public class FlowLogOperationTest {
// then
assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
index 6728d292c..54ecaa639 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
@@ -104,8 +104,7 @@ public class LoopControllerTestItCase {
+ "\"success\":\"\",\"failure\":\"\",\"failure_timeout\":\"\",\"failure_retries\":\"\","
+ "\"failure_exception\":\"\",\"failure_guard\":\"\",\"target\":{\"type\":\"VNF\","
+ "\"resourceID\":\"vFW_PG_T1\"}}]}}}]";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonArray arr = ele.getAsJsonArray();
Loop loop = loopController.updateOperationalPolicies(EXAMPLE_LOOP_NAME, arr);
assertThat(loop.getOperationalPolicies()).hasSize(1);
@@ -126,8 +125,7 @@ public class LoopControllerTestItCase {
+ "\"cbs_host\":\"config-binding-service\",\"cbs_port\":\"10000\",\"external_port\":\"32012\","
+ "\"policy_model_id\":\"onap.policies.monitoring.cdap.tca.hi.lo.app\","
+ "\"policy_id\":\"tca_k8s_CLTCA_v1_0_vFW_PG_T10_k8s-tca-clamp-policy-05162019\"}}";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonObject obj = ele.getAsJsonObject();
loopController.updateGlobalPropertiesJson(EXAMPLE_LOOP_NAME, obj);
Loop loop = loopController.getLoop(EXAMPLE_LOOP_NAME);
@@ -170,6 +168,6 @@ public class LoopControllerTestItCase {
loopController.removeOperationalPolicy(EXAMPLE_LOOP_NAME, "testPolicyModel", "1.0.0");
Loop newLoop2 = loopController.getLoop(EXAMPLE_LOOP_NAME);
- assertThat(newLoop2.getOperationalPolicies().size()).isEqualTo(0);
+ assertThat(newLoop2.getOperationalPolicies().size()).isZero();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
index 7b0ab8614..ab256eafb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
@@ -47,7 +47,6 @@ public class LoopLogServiceTestItCase {
private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}";
private static final String CLAMP_COMPONENT = "CLAMP";
private static final String SAMPLE_LOG_MESSAGE = "Sample log";
- private static final String BLUEPRINT = "blueprint";
@Autowired
LoopService loopService;
@@ -93,4 +92,4 @@ public class LoopLogServiceTestItCase {
assertThat(log.getId()).isEqualTo(id);
Assertions.assertThat(log.getLoop()).isEqualTo(testLoop);
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
index 30d4ebe28..03cd89aeb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
@@ -26,7 +26,6 @@ package org.onap.policy.clamp.policy.pdpgroup;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.BeforeClass;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
index f3c3fc6cd..ce695ec6f 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
import org.junit.Test;
-import org.onap.policy.clamp.policy.pdpgroup.PdpGroupPayloadException;
import org.onap.policy.common.utils.test.ExceptionsTester;
public class PdpGroupPayloadExceptionTest extends ExceptionsTester {
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
index 34674e3ec..b07d3869c 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
@@ -70,6 +70,6 @@ public class PdpGroupPayloadTest {
JsonObject listOfOperations = new JsonObject();
listOfOperations.add(PdpGroupPayload.PDP_ACTIONS, operations);
- PdpGroupPayload pdpGroupPayload = new PdpGroupPayload(listOfOperations);
+ new PdpGroupPayload(listOfOperations);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
index be7a9d674..733e3734e 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
@@ -23,9 +23,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Arrays;
import org.junit.BeforeClass;