diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-07-27 10:12:59 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-09-22 12:58:53 +0100 |
commit | 938005505883cf7a636a8840e20e3dc8a0ad9176 (patch) | |
tree | f2820c1f44c458e95e565943b04b697cb5c88c12 /models-base/src/test | |
parent | d19537308cbdce440c1faf819eb586983d0a67c9 (diff) |
Java 17 Upgrade
Issue-ID: POLICY-4669
Change-Id: I0157ae0ea7151658308c7e6d429098f16824c190
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-base/src/test')
8 files changed, 43 insertions, 35 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java index 52d17e74f..b92aed487 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/ExceptionsTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019, 2021 Nordix Foundation. + * Copyright (C) 2019, 2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,9 +24,9 @@ package org.onap.policy.models.base; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.Response.Status; import java.io.IOException; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; import org.junit.Test; import org.onap.policy.models.errors.concepts.ErrorResponse; @@ -44,7 +44,7 @@ public class ExceptionsTest { String key = "A String"; PfModelException ae = - new PfModelException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key); + new PfModelException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key); ErrorResponse errorResponse = ae.getErrorResponse(); assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails())); assertEquals(key, ae.getObject()); @@ -56,10 +56,10 @@ public class ExceptionsTest { String rkey = "A String"; PfModelRuntimeException re = new PfModelRuntimeException(Response.Status.OK, "Runtime Message", - new IOException("IO runtime exception message"), rkey); + new IOException("IO runtime exception message"), rkey); errorResponse = re.getErrorResponse(); assertEquals("Runtime Message\nIO runtime exception message", - String.join("\n", errorResponse.getErrorDetails())); + String.join("\n", errorResponse.getErrorDetails())); assertEquals(key, re.getObject()); PfModelRuntimeException pfre = new PfModelRuntimeException(ae); 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 f5c6e3a9b..c526b231a 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,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -65,18 +65,18 @@ public class PfConceptContainerTest { container = new DummyPfConceptContainer(new PfConceptKey()); assertNotNull(container); - container = new DummyPfConceptContainer(new PfConceptKey(), new TreeMap<PfConceptKey, DummyPfConcept>()); + container = new DummyPfConceptContainer(new PfConceptKey(), new TreeMap<>()); assertNotNull(container); - assertThatThrownBy(() -> new PfConceptContainer((PfConceptKey) null, null)).hasMessageMatching(KEY_IS_NULL); + assertThatThrownBy(() -> new PfConceptContainer(null, null)).hasMessageMatching(KEY_IS_NULL); - assertThatThrownBy(() -> new DummyPfConceptContainer((PfConceptKey) null, null)) + assertThatThrownBy(() -> new DummyPfConceptContainer(null, null)) .hasMessageMatching(KEY_IS_NULL); assertThatThrownBy(() -> new DummyPfConceptContainer(new PfConceptKey(), null)) .hasMessageMatching("^conceptMap is marked .*on.*ull but is null$"); - assertThatThrownBy(() -> new DummyPfConceptContainer(null, new TreeMap<PfConceptKey, DummyPfConcept>())) + assertThatThrownBy(() -> new DummyPfConceptContainer(null, new TreeMap<>())) .hasMessageMatching(KEY_IS_NULL); } @@ -117,8 +117,8 @@ public class PfConceptContainerTest { assertThatThrownBy(() -> new DummyPfConceptContainer((DummyPfConceptContainer) null)) .isInstanceOf(NullPointerException.class); + assertThatThrownBy(() -> container.compareTo(null)).isInstanceOf(NullPointerException.class); - assertNotEquals(0, container.compareTo(null)); assertEquals(0, container.compareTo(container)); assertNotEquals(0, container.compareTo(conceptKey)); @@ -271,7 +271,7 @@ public class PfConceptContainerTest { } @Test(expected = NullPointerException.class) - public void testnullKey() { + public void testNullKey() { PfConceptKey nullKey = null; new DummyPfConceptContainer(nullKey); } diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java index 5cebf1e91..8b6202042 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfModelExceptionInfoTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2020 Nordix Foundation. + * Copyright (C) 2019-2020, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import org.junit.Test; import org.onap.policy.models.errors.concepts.ErrorResponseInfo; diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java index 812916e3c..ed8c138be 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfValidatorTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import jakarta.validation.Valid; +import java.io.Serial; import java.util.concurrent.atomic.AtomicBoolean; -import javax.validation.Valid; import lombok.Getter; import lombok.NonNull; import org.junit.Before; @@ -123,13 +125,13 @@ public class PfValidatorTest { // null key data.key = new PfConceptKey(); assertThat(validator.validateTop("", data).getResult()) - .contains(KEY_FIELD, "NULL:0.0.0", Validated.IS_A_NULL_KEY).doesNotContain("name", "version"); + .contains(KEY_FIELD, "NULL:0.0.0", Validated.IS_A_NULL_KEY).doesNotContain("name", "version"); // invalid version - should invoke verCascade() which will invoke key.validate() data.key = new StandardCoder().decode("{'name':'abc', 'version':'xyzzy'}".replace('\'', '"'), - PfConceptKey.class); + PfConceptKey.class); assertThat(validator.validateTop("", data).getResult()) - .contains(KEY_FIELD, "version", "xyzzy", "regular expression").doesNotContain("name"); + .contains(KEY_FIELD, "version", "xyzzy", "regular expression").doesNotContain("name"); // not a PfKeyImpl - should not check individual fields PfKey pfkey = mock(PfKey.class); @@ -142,18 +144,18 @@ public class PfValidatorTest { // null name data.key = new PfConceptKey(PfKey.NULL_KEY_NAME, "2.3.4"); assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "name", "null") - .doesNotContain("version", "2.3.4"); + .doesNotContain("version", "2.3.4"); // null version data.key = new PfConceptKey(STRING_VALUE, PfKey.NULL_KEY_VERSION); assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "version", "null") - .doesNotContain("name", STRING_VALUE); + .doesNotContain("name", STRING_VALUE); // null name, invalid version - should get two messages data.key = new StandardCoder().decode("{'name':'NULL', 'version':'xyzzy'}".replace('\'', '"'), - PfConceptKey.class); + PfConceptKey.class); assertThat(validator.validateTop("", data).getResult()).contains(KEY_FIELD, "name", "null", "version", "xyzzy", - "regular expression"); + "regular expression"); /* * Tests with all flags set to "false" (i.e., no validations). @@ -165,6 +167,7 @@ public class PfValidatorTest { AtomicBoolean called = new AtomicBoolean(); data2.key = new PfConceptKey() { + @Serial private static final long serialVersionUID = 1L; @Override diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java index 548c26252..25a6cb7ba 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,9 @@ package org.onap.policy.models.base.testconcepts; +import jakarta.persistence.EmbeddedId; +import java.io.Serial; import java.util.List; -import javax.persistence.EmbeddedId; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; @@ -38,6 +39,7 @@ import org.onap.policy.models.base.validation.annotations.VerifyKey; @Data @EqualsAndHashCode(callSuper = false) public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuthorativeConcept> { + @Serial private static final long serialVersionUID = 1L; @EmbeddedId diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java index 8352697e6..b204895c6 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptKeySub.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,7 @@ package org.onap.policy.models.base.testconcepts; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelRuntimeException; diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java index 2c3fd189e..089773d5f 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConceptSub.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,14 @@ package org.onap.policy.models.base.testconcepts; -import javax.ws.rs.core.Response; +import jakarta.ws.rs.core.Response; +import java.io.Serial; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelRuntimeException; public class DummyPfConceptSub extends DummyPfConcept { + @Serial private static final long serialVersionUID = 1L; /** diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java index 015d1a950..594528be8 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019, 2023 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +21,7 @@ package org.onap.policy.models.base.testconcepts; -import java.util.Arrays; +import java.io.Serial; import java.util.List; import lombok.NonNull; import org.onap.policy.common.parameters.BeanValidationResult; @@ -29,6 +29,7 @@ import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfKey; public class DummyPfKey extends PfKey { + @Serial private static final long serialVersionUID = 1L; public DummyPfKey() { @@ -40,7 +41,7 @@ public class DummyPfKey extends PfKey { } @Override - public int compareTo(PfConcept arg0) { + public int compareTo(@NonNull PfConcept arg0) { return 0; } @@ -55,12 +56,12 @@ public class DummyPfKey extends PfKey { } @Override - public Compatibility getCompatibility(PfKey otherKey) { + public Compatibility getCompatibility(@NonNull PfKey otherKey) { return null; } @Override - public boolean isCompatible(PfKey otherKey) { + public boolean isCompatible(@NonNull PfKey otherKey) { return false; } @@ -71,7 +72,7 @@ public class DummyPfKey extends PfKey { @Override public List<PfKey> getKeys() { - return Arrays.asList(getKey()); + return List.of(getKey()); } @Override |