diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-08-17 22:09:58 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-09-22 15:58:23 +0100 |
commit | 42c18ef1c6506e63151b55a96d90362da9fbda63 (patch) | |
tree | 895c7598c35b8daad7ac5e2681bc0feed5a47027 /main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java | |
parent | eb4cf2ad5d004cbfda90a752d10fbc6e91ef8fb4 (diff) |
Java 17 / Spring 6 / Spring Boot 3 Upgrade
Issue-ID: POLICY-4671
Change-Id: I664e5f62b1ad23619888af98589c04875b07f4d3
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java')
-rw-r--r-- | main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java b/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java index 4edb05dc..2846e506 100644 --- a/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java +++ b/main/src/test/java/org/onap/policy/pap/main/service/PdpGroupServiceTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2022 Bell Canada. All rights reserved. - * Modifications Copyright (C) 2022 Nordix Foundation. + * Modifications Copyright (C) 2022-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. @@ -26,8 +26,8 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.Collections; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.resources.ResourceUtils; import org.onap.policy.models.pdp.concepts.Pdp; @@ -40,10 +40,12 @@ import org.onap.policy.models.pdp.enums.PdpState; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.pap.main.rest.CommonPapRestServer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("test") -public class PdpGroupServiceTest extends CommonPapRestServer { +@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) +class PdpGroupServiceTest extends CommonPapRestServer { private static final String FIELD_IS_NULL = "%s is marked non-null but is null"; @@ -62,7 +64,7 @@ public class PdpGroupServiceTest extends CommonPapRestServer { private PdpGroups groupsToCreate; - private StandardCoder coder = new StandardCoder(); + private final StandardCoder coder = new StandardCoder(); /** * Setup before tests. @@ -70,7 +72,7 @@ public class PdpGroupServiceTest extends CommonPapRestServer { * @throws Exception the exception */ @Override - @Before + @BeforeEach public void setUp() throws Exception { super.setUp(); PdpGroups defaultGroup = coder.decode(ResourceUtils.getResourceAsString("e2e/PdpGroups.json"), PdpGroups.class); @@ -79,7 +81,7 @@ public class PdpGroupServiceTest extends CommonPapRestServer { } @Test - public void testPdpGroupsCrudSuccess() { + void testPdpGroupsCrudSuccess() { List<PdpGroup> pdpGroups = pdpGroupService.getPdpGroups(); assertThat(pdpGroups).hasSize(1); @@ -118,7 +120,7 @@ public class PdpGroupServiceTest extends CommonPapRestServer { } @Test - public void testPdpGroupsCrudFailure() { + void testPdpGroupsCrudFailure() { PdpState pdpState = null; assertThatThrownBy(() -> pdpGroupService.getPdpGroups(pdpState)) .hasMessage(String.format(FIELD_IS_NULL, "pdpState")); @@ -140,23 +142,17 @@ public class PdpGroupServiceTest extends CommonPapRestServer { } @Test - public void testUpdatePdp() { + void testUpdatePdp() { + assertThatThrownBy(() -> pdpGroupService.updatePdp(null, null, new Pdp())) + .hasMessage(String.format(FIELD_IS_NULL, "pdpGroupName")); - assertThatThrownBy(() -> { - pdpGroupService.updatePdp(null, null, new Pdp()); - }).hasMessage(String.format(FIELD_IS_NULL, "pdpGroupName")); + assertThatThrownBy(() -> pdpGroupService.updatePdp(NAME, null, new Pdp())) + .hasMessage(String.format(FIELD_IS_NULL, "pdpSubGroup")); - assertThatThrownBy(() -> { - pdpGroupService.updatePdp(NAME, null, new Pdp()); - }).hasMessage(String.format(FIELD_IS_NULL, "pdpSubGroup")); + assertThatThrownBy(() -> pdpGroupService.updatePdp(NAME, TYPE, null)) + .hasMessage(String.format(FIELD_IS_NULL, "pdp")); - assertThatThrownBy(() -> { - pdpGroupService.updatePdp(NAME, TYPE, null); - }).hasMessage(String.format(FIELD_IS_NULL, "pdp")); - - assertThatThrownBy(() -> { - pdpGroupService.updatePdp(NAME, TYPE, new Pdp()); - }).hasMessage(LOCALNAME_IS_NULL); + assertThatThrownBy(() -> pdpGroupService.updatePdp(NAME, TYPE, new Pdp())).hasMessage(LOCALNAME_IS_NULL); pdpGroupService.createPdpGroups(groupsToCreate.getGroups()); assertThat(pdpGroupService.getPdpGroups()).hasSize(2); @@ -174,18 +170,15 @@ public class PdpGroupServiceTest extends CommonPapRestServer { } @Test - public void testUpdateSubGroup() { - assertThatThrownBy(() -> { - pdpGroupService.updatePdpSubGroup(null, null); - }).hasMessage(String.format(FIELD_IS_NULL, "pdpGroupName")); - - assertThatThrownBy(() -> { - pdpGroupService.updatePdpSubGroup(NAME, null); - }).hasMessage(String.format(FIELD_IS_NULL, "pdpSubGroup")); - - assertThatThrownBy(() -> { - pdpGroupService.updatePdpSubGroup(NAME, new PdpSubGroup()); - }).hasMessage(LOCALNAME_IS_NULL); + void testUpdateSubGroup() { + assertThatThrownBy(() -> pdpGroupService.updatePdpSubGroup(null, null)) + .hasMessage(String.format(FIELD_IS_NULL, "pdpGroupName")); + + assertThatThrownBy(() -> pdpGroupService.updatePdpSubGroup(NAME, null)) + .hasMessage(String.format(FIELD_IS_NULL, "pdpSubGroup")); + + assertThatThrownBy(() -> pdpGroupService.updatePdpSubGroup(NAME, new PdpSubGroup())) + .hasMessage(LOCALNAME_IS_NULL); pdpGroupService.createPdpGroups(groupsToCreate.getGroups()); assertThat(pdpGroupService.getPdpGroups()).hasSize(2); |