diff options
author | 2024-06-13 09:24:00 +0100 | |
---|---|---|
committer | 2024-06-24 16:30:48 +0100 | |
commit | 7b11ab5c03a438aa29ff2242fa06bb8ff28c2867 (patch) | |
tree | 2c76324c1d60b761f09b82fb1786e4633510dbb9 /models-interactions/model-impl/rest | |
parent | bacd5a6f57e79f26d447644329b585991f989123 (diff) |
Convert models to JUnit 5
Review for models-impl
Issue-ID: POLICY-5042
Change-Id: I22ff90b12da3fb2ba4d0eead7afb9282eac6921f
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions/model-impl/rest')
2 files changed, 36 insertions, 25 deletions
diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java index 8579bf1bd..23c9cea3b 100644 --- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java +++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/HttpDeleteWithBodyTest.java @@ -3,7 +3,7 @@ * rest * ================================================================================ * Copyright (C) 2018 Amdocs. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,18 +21,18 @@ package org.onap.policy.rest; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class HttpDeleteWithBodyTest { +class HttpDeleteWithBodyTest { private static final String NO_URI = "BlahBlah"; @Test - public void testGetMethod() { + void testGetMethod() { HttpDeleteWithBody deleteWithBody = new HttpDeleteWithBody(NO_URI); assertEquals("DELETE", deleteWithBody.getMethod()); - assertEquals(NO_URI, deleteWithBody.getURI().toString()); + assertEquals(deleteWithBody.getURI().toString(), NO_URI); } }
\ No newline at end of file diff --git a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java index e6c819153..28136e667 100644 --- a/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java +++ b/models-interactions/model-impl/rest/src/test/java/org/onap/policy/rest/RestTest.java @@ -3,7 +3,7 @@ * rest * ================================================================================ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2020, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019-2020, 2023-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,9 +21,10 @@ package org.onap.policy.rest; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; @@ -43,9 +44,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.apache.commons.lang3.tuple.Pair; -import org.junit.AfterClass; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.onap.policy.common.endpoints.http.server.HttpServletServer; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.utils.network.NetworkUtil; @@ -79,7 +80,7 @@ public class RestTest { /** * Sets server endpoint for the tests. */ - @BeforeClass + @BeforeAll public static void setUp() throws Exception { port = NetworkUtil.allocPort(); @@ -105,39 +106,49 @@ public class RestTest { * * @throws Exception if there is a problem */ - @AfterClass + @AfterAll public static void tearDown() throws Exception { HttpServletServerFactoryInstance.getServerFactory().destroy(); } - @Test(expected = NullPointerException.class) + @Test public void testGetUrlNull() { RestManager mgr = new RestManager(); - mgr.get(null, "user", null, null); + assertThrows(NullPointerException.class, () -> { + mgr.get(null, "user", null, null); + }); } - @Test(expected = NullPointerException.class) + @Test public void testPutUrlNull() { RestManager mgr = new RestManager(); - mgr.put(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); + assertThrows(NullPointerException.class, () -> { + mgr.put(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); + }); } - @Test(expected = NullPointerException.class) + @Test public void testPostUrlNull() { RestManager mgr = new RestManager(); - mgr.post(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); + assertThrows(NullPointerException.class, () -> { + mgr.post(null, "user", null, null, MediaType.TEXT_PLAIN, PAYLOAD); + }); } - @Test(expected = NullPointerException.class) + @Test public void testDeleteUrlNull() { RestManager mgr = new RestManager(); - mgr.delete(null, "user", null, null, null, null); + assertThrows(NullPointerException.class, () -> { + mgr.delete(null, "user", null, null, null, null); + }); } - @Test(expected = NullPointerException.class) + @Test public void testPatchUrlNull() { RestManager mgr = new RestManager(); - mgr.patch(null, "user", null, null, PAYLOAD); + assertThrows(NullPointerException.class, () -> { + mgr.patch(null, "user", null, null, PAYLOAD); + }); } @Test |