aboutsummaryrefslogtreecommitdiffstats
path: root/models-base
diff options
context:
space:
mode:
authoruj426b <uj426b@att.com>2020-07-31 12:06:01 -0400
committerPamela Dragosh <pdragosh@research.att.com>2020-08-20 12:23:26 +0000
commitdbb37442ecf243d3bcaf50f908691ad6f810ccfc (patch)
tree98663790800976a1785b1d127a9fb677712c0759 /models-base
parente88e4b3281fa4881093ccd1dfae8f826a5e9ff5a (diff)
Sonar Fixes policy/models, removing model-yaml
Change-Id: Icd82ea1aef90e4d638b13958519aac5ed5a53f73 Issue-ID: POLICY-2714 Signed-off-by: uj426b <uj426b@att.com>
Diffstat (limited to 'models-base')
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java11
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java9
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfKeyUseTest.java12
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfModelTest.java5
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java22
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java9
-rw-r--r--models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java5
7 files changed, 39 insertions, 34 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
index 3ae3ba8e5..062f6f953 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfConceptContainerTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -24,6 +24,7 @@ package org.onap.policy.models.base;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
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;
@@ -119,19 +120,19 @@ public class PfConceptContainerTest {
assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null))
.isInstanceOf(NullPointerException.class);
- assertFalse(container.compareTo(null) == 0);
+ assertNotEquals(0, container.compareTo(null));
assertEquals(0, container.compareTo(container));
- assertFalse(container.compareTo(conceptKey) == 0);
+ assertNotEquals(0, container.compareTo(conceptKey));
DummyPfConceptContainer testContainer = new DummyPfConceptContainer(container);
testContainer.getKey().setVersion("0.0.2");
- assertFalse(container.compareTo(testContainer) == 0);
+ assertNotEquals(0, container.compareTo(testContainer));
testContainer.getKey().setVersion(container.getKey().getVersion());
assertEquals(0, container.compareTo(testContainer));
PfConceptKey testConceptKey = new PfConceptKey("TestKey", VERSION0_0_1);
testContainer.getConceptMap().put(testConceptKey, new DummyPfConcept(testConceptKey));
- assertFalse(container.compareTo(testContainer) == 0);
+ assertNotEquals(0, container.compareTo(testContainer));
final DummyPfConceptContainer container3 = container;
assertThatThrownBy(() -> container3.validate(null))
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java
index c756d1e06..8ff5e509c 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
import static org.assertj.core.api.Assertions.assertThatThrownBy;
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;
@@ -137,9 +138,9 @@ public class PfKeyImplTest {
assertEquals(0, someKey0.compareTo(someKey0));
assertEquals(-36, someKey0.compareTo(new DummyPfKey()));
- assertFalse(someKey0.equals(null));
- assertTrue(someKey0.equals(someKey0));
- assertFalse(someKey0.equals(new DummyPfKey()));
+ assertNotEquals(someKey0, null);
+ assertEquals(someKey0, someKey0);
+ assertNotEquals(someKey0, new DummyPfKey());
MyKey someKey8 = new MyKey();
someKey8.setVersion(VERSION001);
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyUseTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyUseTest.java
index 46a00664f..e4933b2b9 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyUseTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyUseTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -71,12 +71,12 @@ public class PfKeyUseTest {
PfKeyUse clonedKeyUse = new PfKeyUse(keyUse);
assertEquals("PfKeyUse(usedKey=PfConceptKey(name=Key, version=0.0.1))", clonedKeyUse.toString());
- assertFalse(keyUse.hashCode() == 0);
+ assertNotEquals(0, keyUse.hashCode());
- assertTrue(keyUse.equals(keyUse));
- assertTrue(keyUse.equals(clonedKeyUse));
- assertFalse(keyUse.equals("Hello"));
- assertTrue(keyUse.equals(new PfKeyUse(key)));
+ assertEquals(keyUse, keyUse);
+ assertEquals(keyUse, clonedKeyUse);
+ assertNotEquals(keyUse, (Object) "Hello");
+ assertEquals(keyUse, new PfKeyUse(key));
assertEquals(0, keyUse.compareTo(keyUse));
assertEquals(0, keyUse.compareTo(clonedKeyUse));
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfModelTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfModelTest.java
index c124393fe..9e4e350a1 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfModelTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfModelTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -24,6 +24,7 @@ package org.onap.policy.models.base;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
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;
@@ -65,7 +66,7 @@ public class PfModelTest {
assertEquals(0, dpm.compareTo(dpmClone));
assertEquals(-1, dpm.compareTo(null));
assertEquals(0, dpm.compareTo(dpm));
- assertFalse(dpm.compareTo(dpm.getKey()) == 0);
+ assertNotEquals(0, dpm.compareTo(dpm.getKey()));
}
@Test
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
index dd5c205a7..c1c13c8b3 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceKeyTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -103,16 +103,16 @@ public class PfReferenceKeyTest {
assertEquals("PfReferenceKey(parentKeyName=NPKN, parentKeyVersion=0.0.1, parentLocalName=NPKLN, localName=NLN)",
clonedReferenceKey.toString());
- assertFalse(testReferenceKey.hashCode() == 0);
+ assertNotEquals(0, testReferenceKey.hashCode());
- assertTrue(testReferenceKey.equals(testReferenceKey));
- assertTrue(testReferenceKey.equals(clonedReferenceKey));
- assertFalse(testReferenceKey.equals("Hello"));
- assertFalse(testReferenceKey.equals(new PfReferenceKey("PKN", VERSION002, "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new PfReferenceKey("NPKN", VERSION002, "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new PfReferenceKey("NPKN", VERSION001, "PLN", "LN")));
- assertFalse(testReferenceKey.equals(new PfReferenceKey("NPKN", VERSION001, "NPLN", "LN")));
- assertTrue(testReferenceKey.equals(new PfReferenceKey("NPKN", VERSION001, NPKLN, "NLN")));
+ assertEquals(testReferenceKey, testReferenceKey);
+ assertEquals(testReferenceKey, clonedReferenceKey);
+ assertNotEquals(testReferenceKey, (Object) "Hello");
+ assertNotEquals(testReferenceKey, new PfReferenceKey("PKN", VERSION002, "PLN", "LN"));
+ assertNotEquals(testReferenceKey, new PfReferenceKey("NPKN", VERSION002, "PLN", "LN"));
+ assertNotEquals(testReferenceKey, new PfReferenceKey("NPKN", VERSION001, "PLN", "LN"));
+ assertNotEquals(testReferenceKey, new PfReferenceKey("NPKN", VERSION001, "NPLN", "LN"));
+ assertEquals(testReferenceKey, new PfReferenceKey("NPKN", VERSION001, NPKLN, "NLN"));
assertEquals(0, testReferenceKey.compareTo(testReferenceKey));
assertEquals(0, testReferenceKey.compareTo(clonedReferenceKey));
@@ -123,7 +123,7 @@ public class PfReferenceKeyTest {
assertNotEquals(0, testReferenceKey.compareTo(new PfReferenceKey("NPKN", VERSION001, "NPLN", "LN")));
assertEquals(0, testReferenceKey.compareTo(new PfReferenceKey("NPKN", VERSION001, NPKLN, "NLN")));
- assertFalse(testReferenceKey.equals(null));
+ assertNotEquals(testReferenceKey, null);
assertThatThrownBy(() -> new PfReferenceKey((PfReferenceKey) null)).isInstanceOf(NullPointerException.class);
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
index 8659b4cea..f5f5ad002 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/PfUtilsTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Nordix Foundation.
- * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019-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.
@@ -24,6 +24,7 @@ package org.onap.policy.models.base;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
import java.util.Arrays;
@@ -48,7 +49,7 @@ public class PfUtilsTest {
assertEquals(0, PfUtils.compareObjects(null, null));
assertEquals(-1, PfUtils.compareObjects(HELLO, null));
assertEquals(1, PfUtils.compareObjects(null, HELLO));
- assertFalse(PfUtils.compareObjects(HELLO, "goodbye") == 0);
+ assertNotEquals(PfUtils.compareObjects(HELLO, "goodbye"), 0);
assertEquals(0, PfUtils.compareObjects(HELLO, HELLO));
}
@@ -91,12 +92,12 @@ public class PfUtilsTest {
@Test
public void testMakeCopy() {
assertNull(PfUtils.makeCopy((MyObject) null));
-
+ NoCopyConstructor noCopyConstructor = new NoCopyConstructor();
MyObject origObject = new MyObject();
origObject.name = HELLO;
assertEquals(origObject.toString(), PfUtils.makeCopy(origObject).toString());
- assertThatThrownBy(() -> PfUtils.makeCopy(new NoCopyConstructor())).isInstanceOf(PfModelRuntimeException.class);
+ assertThatThrownBy(() -> PfUtils.makeCopy(noCopyConstructor)).isInstanceOf(PfModelRuntimeException.class);
}
@Getter
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
index 64612238b..5d1367028 100644
--- a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
+++ b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Models
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -149,9 +149,10 @@ public class ValidatedTest {
assertTrue(msg.getMessage().contains("name invalid-null"));
assertTrue(it.next().getMessage().contains("version invalid-null"));
+ PfValidationResult pfValidationResult = new PfValidationResult();
final PfConceptKey key2 = key;
assertThatThrownBy(() -> validated.validateNotNull(key2, null)).isInstanceOf(NullPointerException.class);
- assertThatThrownBy(() -> validated.validateNotNull(null, new PfValidationResult()))
+ assertThatThrownBy(() -> validated.validateNotNull(null, pfValidationResult))
.isInstanceOf(NullPointerException.class);
}