aboutsummaryrefslogtreecommitdiffstats
path: root/policy-management/src
diff options
context:
space:
mode:
authorTaka Cho <takamune.cho@att.com>2020-06-18 14:15:16 -0400
committerTaka Cho <takamune.cho@att.com>2020-06-19 08:39:17 -0400
commitf86386eb1a0a785abe20147d6321536acaed4002 (patch)
tree42d2ed138dcc9ef842c30c3065e023eaab245dc6 /policy-management/src
parent1fdba85a145be36060262d4575995a7752d7a396 (diff)
drools-pdp sonar issue fixes
fix all assert statements to comply with sonar issue Issue-ID: POLICY-2616 Change-Id: Ia36e3eab7c74d8dfb1ab3fa1395b1f64b173e09a Signed-off-by: Taka Cho <takamune.cho@att.com>
Diffstat (limited to 'policy-management/src')
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java6
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java40
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java8
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java2
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java27
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java6
-rw-r--r--policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java3
7 files changed, 46 insertions, 46 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
index ec761ebf..743de8f9 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/NullDroolsControllerTest.java
@@ -95,12 +95,12 @@ public class NullDroolsControllerTest {
@Test
public void getRecentSourceEvents() {
- Assert.assertTrue(new NullDroolsController().getRecentSourceEvents().length == 0);
+ Assert.assertEquals(0, new NullDroolsController().getRecentSourceEvents().length);
}
@Test
public void getRecentSinkEvents() {
- Assert.assertTrue(new NullDroolsController().getRecentSinkEvents().length == 0);
+ Assert.assertEquals(0, new NullDroolsController().getRecentSinkEvents().length);
}
@Test
@@ -145,7 +145,7 @@ public class NullDroolsControllerTest {
@Test
public void factCount() {
- Assert.assertTrue(new NullDroolsController().factCount(null) == 0);
+ Assert.assertEquals(0, new NullDroolsController().factCount(null));
}
@Test
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
index 9c38e7e7..7a5ed2c0 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2020 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.
@@ -159,17 +159,17 @@ public class ProtocolCoderToolsetTest {
}
CoderFilters coderFilters = coderToolset.getCoder(Triple.class.getName());
- Assert.assertTrue(coderFilters.getCodedClass() == Triple.class.getName());
- Assert.assertTrue(coderFilters.getFilter() == protocolFilter);
- Assert.assertTrue(coderFilters.getFilter().getRule() != null);
+ Assert.assertSame(coderFilters.getCodedClass(), Triple.class.getName());
+ Assert.assertSame(coderFilters.getFilter(), protocolFilter);
+ Assert.assertNotNull(coderFilters.getFilter().getRule());
coderFilters.getFilter().setRule("[?($.second =~ /^v2$/ && $.third =~ /.*v3.*/)]");
tripleDecoded = (Triple<String, String, String>) coderToolset.decode(tripleEncoded);
- Assert.assertTrue(tripleDecoded.first().equals(triple.first()));
- Assert.assertTrue(tripleDecoded.second().equals(triple.second()));
- Assert.assertTrue(tripleDecoded.third().equals(triple.third()));
+ Assert.assertEquals(triple.first(), tripleDecoded.first());
+ Assert.assertEquals(triple.second(), tripleDecoded.second());
+ Assert.assertEquals(triple.third(), tripleDecoded.third());
coderFilters.getFilter().setRule(null);
Assert.assertEquals("[?($ =~ /.*/)]", coderFilters.getFilter().getRule());
@@ -192,37 +192,37 @@ public class ProtocolCoderToolsetTest {
private void addRemoveCoder(ProtocolCoderToolset coderToolset) {
coderToolset.addCoder(this.getClass().getName(),
new JsonProtocolFilter("[?($.second =~ /.*/)]"), 654321);
- Assert.assertTrue(coderToolset.getCoders().size() == 2);
+ Assert.assertEquals(2, coderToolset.getCoders().size());
coderToolset.removeCoders(this.getClass().getName());
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
}
private void updateCoderFilterRule(ProtocolCoderToolset coderToolset) {
coderToolset.addCoder(Triple.class.getName(), new JsonProtocolFilter("[?($.third =~ /.*/)]"), 654321);
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
- Assert.assertTrue(coderToolset.getCoder(Triple.class.getName()).getModelClassLoaderHash() == 654321);
+ Assert.assertEquals(654321, coderToolset.getCoder(Triple.class.getName()).getModelClassLoaderHash());
- Assert.assertTrue(
+ Assert.assertNotNull(
coderToolset.getCoder(
- Triple.class.getName()).getFilter().getRule() != null);
+ Triple.class.getName()).getFilter().getRule());
- Assert.assertTrue("[?($.third =~ /.*/)]".equals(coderToolset.getCoder(Triple.class.getName())
- .getFilter().getRule()));
+ Assert.assertEquals("[?($.third =~ /.*/)]", coderToolset.getCoder(Triple.class.getName())
+ .getFilter().getRule());
}
private void validateInitialization(JsonProtocolFilter protocolFilter, ProtocolCoderToolset coderToolset) {
- Assert.assertTrue(CONTROLLER_ID.equals(coderToolset.getControllerId()));
- Assert.assertTrue(releaseId.getGroupId().equals(coderToolset.getGroupId()));
- Assert.assertTrue(releaseId.getArtifactId().equals(coderToolset.getArtifactId()));
+ Assert.assertEquals(CONTROLLER_ID, coderToolset.getControllerId());
+ Assert.assertEquals(releaseId.getGroupId(), coderToolset.getGroupId());
+ Assert.assertEquals(releaseId.getArtifactId(), coderToolset.getArtifactId());
Assert.assertNull(coderToolset.getCustomCoder());
- Assert.assertTrue(coderToolset.getCoders().size() == 1);
+ Assert.assertEquals(1, coderToolset.getCoders().size());
CoderFilters coderFilters = coderToolset.getCoder(CONTROLLER_ID);
- Assert.assertTrue(coderFilters == null);
+ Assert.assertNull(coderFilters);
coderFilters = coderToolset.getCoder(Triple.class.getName());
Assert.assertNotNull(coderFilters);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
index 29650bf0..3741e71a 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Configuration Test
- * ================================================================================
+ * Configuration Test * ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,6 +21,7 @@ package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import java.util.Properties;
@@ -66,8 +66,8 @@ public class ControllerConfigurationTest {
ControllerConfiguration controllerConfig = new ControllerConfiguration(NAME, OPERATION, DROOLS_CONFIG);
- assertTrue(controllerConfig.equals(controllerConfig));
- assertFalse(controllerConfig.equals(new Object()));
+ assertEquals(controllerConfig, controllerConfig);
+ assertNotEquals(controllerConfig, new Object());
ControllerConfiguration controllerConfig2 = new ControllerConfiguration();
controllerConfig2.setName(NAME2);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
index a085c950..92726f89 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java
@@ -56,7 +56,7 @@ public class DroolsConfigurationTest {
additionalProperties.put(ADDITIONAL_PROPERTY_KEY, ADDITIONAL_PROPERTY_VALUE);
final DroolsConfiguration droolsConfig = new DroolsConfiguration(ARTIFACT, GROUPID, VERSION);
- assertTrue(droolsConfig.equals(droolsConfig));
+ assertEquals(droolsConfig, droolsConfig);
droolsConfig.set(ARTIFACT_ID_STRING, "foobar");
assertEquals("foobar", droolsConfig.get(ARTIFACT_ID_STRING));
diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
index 5da8e2e5..352d8ce1 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java
@@ -21,8 +21,7 @@
package org.onap.policy.drools.protocol.configuration;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotEquals;
import java.io.IOException;
import java.util.ArrayList;
@@ -75,8 +74,8 @@ public class PdpdConfigurationTest {
drools.set("version", VERSION);
drools.set(PROPERTY1, VALUE1);
- assertTrue(drools.equals(drools));
- assertFalse(drools.equals(new Object()));
+ assertEquals(drools, drools);
+ assertNotEquals(drools, new Object());
logger.info("Drools HashCode {}", drools.hashCode());
@@ -94,7 +93,7 @@ public class PdpdConfigurationTest {
drools2.set(PROPERTY1, drools.get(PROPERTY1));
- assertTrue(drools.equals(drools2));
+ assertEquals(drools, drools2);
//
// with methods
@@ -102,7 +101,7 @@ public class PdpdConfigurationTest {
drools2.withArtifactId(ARTIFACT2).withGroupId(GROUPID2).withVersion(VERSION2)
.withAdditionalProperty(PROPERTY2, VALUE2);
- assertFalse(drools.equals(drools2));
+ assertNotEquals(drools, drools2);
//
// Test get additional properties
@@ -132,8 +131,8 @@ public class PdpdConfigurationTest {
controller.set("drools", drools);
controller.set(PROPERTY1, VALUE1);
- assertTrue(controller.equals(controller));
- assertFalse(controller.equals(new Object()));
+ assertEquals(controller, controller);
+ assertNotEquals(controller, new Object());
logger.info("Controller HashCode {}", controller.hashCode());
@@ -151,7 +150,7 @@ public class PdpdConfigurationTest {
controller2.set(PROPERTY1, controller.get(PROPERTY1));
- assertTrue(controller.equals(controller2));
+ assertEquals(controller, controller2);
//
// test with methods
@@ -160,7 +159,7 @@ public class PdpdConfigurationTest {
controller2.withDrools(drools2).withName(NAME2)
.withOperation(OPERATION2).withAdditionalProperty(PROPERTY2, VALUE2);
- assertFalse(controller.equals(controller2));
+ assertNotEquals(controller, controller2);
//
// Test additional properties
@@ -195,8 +194,8 @@ public class PdpdConfigurationTest {
config.set("controllers", controllers);
config.set(PROPERTY1, VALUE1);
- assertTrue(config.equals(config));
- assertFalse(config.equals(new Object()));
+ assertEquals(config, config);
+ assertNotEquals(config, new Object());
logger.info("Config HashCode {}", config.hashCode());
@@ -215,7 +214,7 @@ public class PdpdConfigurationTest {
config2.set(PROPERTY1, config.get(PROPERTY1));
- assertTrue(config.equals(config2));
+ assertEquals(config, config2);
//
// Test with methods
@@ -224,7 +223,7 @@ public class PdpdConfigurationTest {
controllers2.add(controller2);
config2.withRequestId(REQUEST_ID2).withEntity(ENTITY2).withController(controllers2);
- assertFalse(config.equals(config2));
+ assertNotEquals(config, config2);
//
// Test additional properties
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
index 81714cfd..a999c718 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java
@@ -347,7 +347,7 @@ public class PolicyEngineManagerTest {
verify(prov1).beforeBoot(mgr, args);
verify(prov2).beforeBoot(mgr, args);
- assertTrue(globalInitArgs == args);
+ assertSame(globalInitArgs, args);
verify(prov1).afterBoot(mgr);
verify(prov2).afterBoot(mgr);
@@ -369,7 +369,7 @@ public class PolicyEngineManagerTest {
(prov, flag) -> when(prov.afterBoot(mgr)).thenReturn(flag),
() -> mgr.boot(args),
prov -> verify(prov).beforeBoot(mgr, args),
- () -> assertTrue(globalInitArgs == args),
+ () -> assertSame(globalInitArgs, args),
prov -> verify(prov).afterBoot(mgr));
}
@@ -392,7 +392,7 @@ public class PolicyEngineManagerTest {
mgr.setEnvironment(props2);
- assertTrue(mgr.getEnvironment() == env);
+ assertSame(mgr.getEnvironment(), env);
// new env should have a union of the properties
props1.putAll(props2);
diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
index ad0f4148..2864d5de 100644
--- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
+++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.drools.system;
import static org.awaitility.Awaitility.await;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -240,7 +241,7 @@ public class PolicyEngineTest {
controllerProperties.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProperties);
- assertTrue(PolicyControllerConstants.getFactory().inventory().size() == 1);
+ assertEquals(1, PolicyControllerConstants.getFactory().inventory().size());
gson.compareGson(PolicyEngineConstants.getManager(),
new File(PolicyEngineTest.class.getSimpleName() + "Add.json"));