diff options
author | 2025-01-10 11:50:41 +0000 | |
---|---|---|
committer | 2025-01-10 11:51:51 +0000 | |
commit | b60fb4d0e5ad3603f967029a2682484cbdd81cec (patch) | |
tree | 5918b072b3219512bd8d60c777e7891bddaabbef /models-base | |
parent | 7cfbbcb1f16ab8b358c06a1f77fc94a203a53212 (diff) |
Fix sonar issues
- fixing sonar issues on code to generate new models-* artifacts
with parent new dependencies.
Issue-ID: POLICY-5240
Change-Id: I41e01ededbc20c9b389be1167691aeb4e03cd0fb
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-base')
-rw-r--r-- | models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java | 32 | ||||
-rw-r--r-- | models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java | 12 |
2 files changed, 22 insertions, 22 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java index 62418d9ef..c0af351c8 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfReferenceTimestampKeyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021, 2024 Nordix Foundation. + * Copyright (C) 2021, 2024-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ class PfReferenceTimestampKeyTest { private static final String LOCAL_NAME = "LocalName"; private static final String VERSION002 = "0.0.2"; private static final String VERSION001 = "0.0.1"; - private static final long timeStamp = 1613152081L; + private static final long TIME_STAMP = 1613152081L; private static final Instant DEFAULT_TIMESTAMP = Instant.EPOCH; @Test @@ -49,16 +49,16 @@ class PfReferenceTimestampKeyTest { assertNotNull(new PfReferenceTimestampKey(new PfReferenceTimestampKey()).getTimeStamp()); assertEquals(LOCAL_NAME, - new PfReferenceTimestampKey(new PfReferenceKey(), LOCAL_NAME, Instant.ofEpochSecond(timeStamp)) + new PfReferenceTimestampKey(new PfReferenceKey(), LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP)) .getReferenceKey().getLocalName()); - assertEquals(Date.from(Instant.ofEpochSecond(timeStamp)), new PfReferenceTimestampKey(new PfConceptKey(), - PARENT_LOCAL_NAME, LOCAL_NAME, Instant.ofEpochSecond(timeStamp)).getTimeStamp()); + assertEquals(Date.from(Instant.ofEpochSecond(TIME_STAMP)), new PfReferenceTimestampKey(new PfConceptKey(), + PARENT_LOCAL_NAME, LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP)).getTimeStamp()); assertThat(new PfReferenceTimestampKey("ParentKeyName", VERSION001, PARENT_LOCAL_NAME, LOCAL_NAME, - Instant.ofEpochSecond(timeStamp))).isInstanceOf(PfReferenceTimestampKey.class); + Instant.ofEpochSecond(TIME_STAMP))).isInstanceOf(PfReferenceTimestampKey.class); assertThat( - new PfReferenceTimestampKey("ParentKeyName", VERSION001, LOCAL_NAME, Instant.ofEpochSecond(timeStamp)) + new PfReferenceTimestampKey("ParentKeyName", VERSION001, LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP)) .getReferenceKey().getParentLocalName()).isEqualTo(PfKey.NULL_KEY_NAME); assertEquals(PfReferenceTimestampKey.getNullKey().getKey(), PfReferenceTimestampKey.getNullKey()); @@ -71,8 +71,8 @@ class PfReferenceTimestampKeyTest { PfReferenceTimestampKey testNullKey = new PfReferenceTimestampKey(); assertTrue(testNullKey.isNullKey()); - String id = "NULL:0.0.0:NULL:NULL:" + timeStamp; - assertThat(new PfReferenceTimestampKey(id).getTimeStamp().getTime()).isEqualTo(timeStamp); + String id = "NULL:0.0.0:NULL:NULL:" + TIME_STAMP; + assertThat(new PfReferenceTimestampKey(id).getTimeStamp().getTime()).isEqualTo(TIME_STAMP); } @Test @@ -124,17 +124,17 @@ class PfReferenceTimestampKeyTest { assertEquals(testReferenceKey, clonedReferenceKey); assertNotEquals(testReferenceKey, new PfReferenceTimestampKey("PKN", VERSION001, "PLN", - "LN", Instant.ofEpochSecond(timeStamp))); - testReferenceKey.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp))); + "LN", Instant.ofEpochSecond(TIME_STAMP))); + testReferenceKey.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP))); assertEquals(testReferenceKey, new PfReferenceTimestampKey("PKN", VERSION001, PARENT_LOCAL_NAME, "LN", - Instant.ofEpochSecond(timeStamp))); + Instant.ofEpochSecond(TIME_STAMP))); assertNotEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey())); assertNotEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey("PKN", VERSION002, - "PLN", "LN", Instant.ofEpochSecond(timeStamp)))); + "PLN", "LN", Instant.ofEpochSecond(TIME_STAMP)))); assertEquals(0, testReferenceKey.compareTo(new PfReferenceTimestampKey("PKN", VERSION001, PARENT_LOCAL_NAME, - "LN", Instant.ofEpochSecond(timeStamp)))); + "LN", Instant.ofEpochSecond(TIME_STAMP)))); assertThatThrownBy(() -> new PfReferenceTimestampKey((PfReferenceTimestampKey) null)) .isInstanceOf(NullPointerException.class); @@ -146,13 +146,13 @@ class PfReferenceTimestampKeyTest { @Test void testNewerKey() { PfReferenceTimestampKey key1 = new PfReferenceTimestampKey("ParentKeyName", VERSION001, PARENT_LOCAL_NAME, - LOCAL_NAME, Instant.ofEpochSecond(timeStamp)); + LOCAL_NAME, Instant.ofEpochSecond(TIME_STAMP)); PfReferenceTimestampKey key2 = new PfReferenceTimestampKey(key1); assertFalse(key2.isNewerThan(key1)); assertThatThrownBy(() -> key1.isNewerThan((PfKey) null)).isInstanceOf(NullPointerException.class) .hasMessageMatching("^otherKey is marked .*on.*ull but is null$"); - key2.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp).plusSeconds(80))); + key2.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP).plusSeconds(80))); assertTrue(key2.isNewerThan(key1)); } diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java index 90eacca0d..81d0c08b0 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfTimestampKeyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021, 2024 Nordix Foundation. + * Copyright (C) 2019-2021, 2024-2025 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ class PfTimestampKeyTest { private static final String CONCEPT_IS_NULL = "^copyConcept is marked .*on.*ull but is null$"; private static final String NAME_IS_NULL = "^name is marked .*on.*ull but is null$"; private static final String VERSION_IS_NULL = "^version is marked .*on.*ull but is null$"; - private static final long timeStamp = 1574832537641L; + private static final long TIME_STAMP = 1574832537641L; @Test void testTimestampKey() { @@ -45,14 +45,14 @@ class PfTimestampKeyTest { assertEquals("PfTimestampKey(name=NULL, version=0.0.0, timeStamp=" + Date.from(Instant.EPOCH) + ")", someKey0.toString()); - PfTimestampKey someKey1 = new PfTimestampKey("my-name", VERSION001, Instant.ofEpochSecond(timeStamp)); + PfTimestampKey someKey1 = new PfTimestampKey("my-name", VERSION001, Instant.ofEpochSecond(TIME_STAMP)); PfTimestampKey someKey2 = new PfTimestampKey(someKey1); PfTimestampKey someKey3 = new PfTimestampKey(someKey1.getId()); assertEquals(someKey1, someKey2); assertEquals(someKey1, someKey3); assertFalse(someKey1.isNullVersion()); assertEquals("PfTimestampKey(name=my-name, version=0.0.1, timeStamp=" - + Date.from(Instant.ofEpochSecond(timeStamp)) + ")", someKey1.toString()); + + Date.from(Instant.ofEpochSecond(TIME_STAMP)) + ")", someKey1.toString()); assertEquals("my-name", someKey1.getName()); assertEquals(VERSION001, someKey1.getVersion()); @@ -69,7 +69,7 @@ class PfTimestampKeyTest { assertFalse(someKey1.isNewerThan(someKey2)); assertThatThrownBy(() -> someKey1.isNewerThan((PfKey) null)).isInstanceOf(NullPointerException.class) .hasMessageMatching("^otherKey is marked .*on.*ull but is null$"); - someKey2.setTimeStamp(Date.from(Instant.ofEpochSecond(timeStamp).plusMillis(90))); + someKey2.setTimeStamp(Date.from(Instant.ofEpochSecond(TIME_STAMP).plusMillis(90))); assertTrue(someKey2.isNewerThan(someKey1)); someKey3.setName("my-name3"); assertTrue(someKey3.isNewerThan(someKey1)); @@ -79,7 +79,7 @@ class PfTimestampKeyTest { assertThatThrownBy(() -> someKey1.compareTo((PfConcept) null)).isInstanceOf(NullPointerException.class) .hasMessageMatching("^otherObj is marked .*on.*ull but is null$"); - PfTimestampKey someKey4 = new PfTimestampKey("NULL", "0.0.0", Instant.ofEpochSecond(timeStamp)); + PfTimestampKey someKey4 = new PfTimestampKey("NULL", "0.0.0", Instant.ofEpochSecond(TIME_STAMP)); assertFalse(someKey4.isNullKey()); assertFalse(someKey1.isNullKey()); } |