X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Fservice%2FTestPdpGroupService.java;fp=main%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Fservice%2FTestPdpGroupService.java;h=6ad8ee4abb72e011829035ce941f4fd84d3af1ff;hb=6438ef61e253f5071a5539c0c8de8890260d4f58;hp=4c04a08e7e2a49256011edc56aa8fd6813e2eed3;hpb=22d211f6df78363d61192057d7cd03534ff7d1c9;p=policy%2Fapi.git diff --git a/main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java b/main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java index 4c04a08e..6ad8ee4a 100644 --- a/main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java +++ b/main/src/test/java/org/onap/policy/api/main/service/TestPdpGroupService.java @@ -1,6 +1,7 @@ /* * ============LICENSE_START======================================================= - * Copyright (C) 2022 Bell Canada. All rights reserved. + * Copyright (C) 2022 Bell Canada. 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. @@ -26,11 +27,13 @@ import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.List; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; import org.onap.policy.api.main.repository.PdpGroupRepository; import org.onap.policy.common.utils.coder.CoderException; @@ -40,7 +43,7 @@ import org.onap.policy.models.pdp.concepts.PdpGroups; import org.onap.policy.models.pdp.persistence.concepts.JpaPdpGroup; @RunWith(MockitoJUnitRunner.class) -public class TestPdpGroupService { +class TestPdpGroupService { @Mock private PdpGroupRepository pdpGroupRepository; @@ -48,12 +51,16 @@ public class TestPdpGroupService { @InjectMocks private PdpGroupService pdpGroupService; + AutoCloseable closeable; + /** * Test setup. + * * @throws CoderException decode errors */ - @Before + @BeforeEach public void setUp() throws CoderException { + closeable = MockitoAnnotations.openMocks(this); var pdpGroups = new StandardCoder().decode(ResourceUtils.getResourceAsString("pdpgroups/PdpGroups.json"), PdpGroups.class).getGroups(); List jpaPdpGroupList = new ArrayList<>(); @@ -62,8 +69,13 @@ public class TestPdpGroupService { when(pdpGroupRepository.findAll()).thenReturn(jpaPdpGroupList); } + @AfterEach + void tearDown() throws Exception { + closeable.close(); + } + @Test - public void testAssertPolicyTypeNotSupportedInPdpGroup() { + void testAssertPolicyTypeNotSupportedInPdpGroup() { assertThatCode(() -> pdpGroupService.assertPolicyTypeNotSupportedInPdpGroup("policy_type_not_supported", "1.0.0")).doesNotThrowAnyException(); @@ -73,7 +85,7 @@ public class TestPdpGroupService { } @Test - public void testAssertPolicyNotDeployedInPdpGroup() { + void testAssertPolicyNotDeployedInPdpGroup() { assertThatCode(() -> pdpGroupService.assertPolicyNotDeployedInPdpGroup("policy_not_deployed", "1.0.0")) .doesNotThrowAnyException();