X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=main%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Fservice%2FTestPolicyService.java;h=6820ad3fe7abe98582380aec6b8691def9cd7f5a;hb=9b0780e59376d20ae9044575ce9921fb7e6b519f;hp=f9baf76a4a860edaff6b44220b4fc1534678c0e0;hpb=535f62b4b4870505d2351ed098415d8d643b2ace;p=policy%2Fapi.git diff --git a/main/src/test/java/org/onap/policy/api/main/service/TestPolicyService.java b/main/src/test/java/org/onap/policy/api/main/service/TestPolicyService.java index f9baf76a..6820ad3f 100644 --- a/main/src/test/java/org/onap/policy/api/main/service/TestPolicyService.java +++ b/main/src/test/java/org/onap/policy/api/main/service/TestPolicyService.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. @@ -22,26 +23,37 @@ package org.onap.policy.api.main.service; import static org.assertj.core.api.Assertions.assertThatCode; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.MockitoAnnotations; import org.onap.policy.api.main.repository.PolicyRepository; import org.onap.policy.models.base.PfConceptKey; -@RunWith(MockitoJUnitRunner.class) -public class TestPolicyService { +class TestPolicyService { @Mock private PolicyRepository policyRepository; - @InjectMocks + @Mock private PolicyService policyService; + AutoCloseable autoCloseable; + + @BeforeEach + void before() { + autoCloseable = MockitoAnnotations.openMocks(this); + } + + @AfterEach + void after() throws Exception { + autoCloseable.close(); + } + @Test - public void testDeletePolicy() { + void testDeletePolicy() { PfConceptKey id = new PfConceptKey("dummy", "1.0.0"); Mockito.doNothing().when(policyRepository).deleteById(id); assertThatCode(() -> policyService.deletePolicy(id)).doesNotThrowAnyException();