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;fp=main%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fapi%2Fmain%2Fservice%2FTestPolicyService.java;h=d512e777abb03d50c2cfc44423a90bf42c4c2922;hb=6438ef61e253f5071a5539c0c8de8890260d4f58;hp=f9baf76a4a860edaff6b44220b4fc1534678c0e0;hpb=22d211f6df78363d61192057d7cd03534ff7d1c9;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..d512e777 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,40 @@ package org.onap.policy.api.main.service; import static org.assertj.core.api.Assertions.assertThatCode; -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.Mockito; +import org.mockito.MockitoAnnotations; import org.mockito.junit.MockitoJUnitRunner; 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();