diff options
author | waynedunican <wayne.dunican@est.tech> | 2024-06-13 09:19:14 +0100 |
---|---|---|
committer | waynedunican <wayne.dunican@est.tech> | 2024-06-20 12:24:23 +0100 |
commit | 9e8684c88435734cb2e142208436cec647cde887 (patch) | |
tree | b06334cdf8309d36ceba948797ff071d14a2e82d /models-interactions/model-actors/actor.vfc | |
parent | 8236c8bab1a27bd721586550f8ba879abcba3239 (diff) |
Convert models to JUnit 5
Review for models-actors
Issue-ID: POLICY-5042
Change-Id: Ica07b9fbda1eca24a8a432d57a2d9af52c84625d
Signed-off-by: waynedunican <wayne.dunican@est.tech>
Diffstat (limited to 'models-interactions/model-actors/actor.vfc')
5 files changed, 55 insertions, 60 deletions
diff --git a/models-interactions/model-actors/actor.vfc/pom.xml b/models-interactions/model-actors/actor.vfc/pom.xml index 84eb7c553..1644aab47 100644 --- a/models-interactions/model-actors/actor.vfc/pom.xml +++ b/models-interactions/model-actors/actor.vfc/pom.xml @@ -85,10 +85,5 @@ <version>${project.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> </dependencies> </project> diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java index d83fd8ba8..945acabd6 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/BasicVfcOperation.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -32,10 +32,10 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingCo import org.onap.policy.simulators.Util; import org.onap.policy.vfc.VfcResponse; -public abstract class BasicVfcOperation extends BasicHttpOperation { - public static final String POLL_PATH = "my-path-get/"; - public static final int MAX_POLLS = 3; - public static final int POLL_WAIT_SEC = 20; +abstract class BasicVfcOperation extends BasicHttpOperation { + static final String POLL_PATH = "my-path-get/"; + static final int MAX_POLLS = 3; + static final int POLL_WAIT_SEC = 20; @Mock protected HttpPollingConfig config; @@ -45,7 +45,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation { /** * Constructs the object using a default actor and operation name. */ - public BasicVfcOperation() { + BasicVfcOperation() { super(); } @@ -55,7 +55,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation { * @param actor actor name * @param operation operation name */ - public BasicVfcOperation(String actor, String operation) { + BasicVfcOperation(String actor, String operation) { super(actor, operation); } @@ -66,7 +66,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation { Util.buildVfcSim(); BusTopicParams clientParams = BusTopicParams.builder().clientName(MY_CLIENT).basePath("api/nslcm/v1/") - .hostname("localhost").managed(true).port(Util.VFCSIM_SERVER_PORT).build(); + .hostname("localhost").managed(true).port(Util.VFCSIM_SERVER_PORT).build(); HttpClientFactoryInstance.getClientFactory().build(clientParams); } @@ -78,7 +78,7 @@ public abstract class BasicVfcOperation extends BasicHttpOperation { /** * Initializes mocks and sets up. */ - public void setUp() throws Exception { + void setUp() throws Exception { super.setUpBasic(); response = new VfcResponse(); diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java index ca7cefd93..4474693cc 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/RestartTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -22,19 +22,19 @@ package org.onap.policy.controlloop.actor.vfc; import static org.assertj.core.api.Assertions.assertThat; -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.assertTrue; import java.util.List; import java.util.concurrent.CompletableFuture; import org.apache.commons.lang3.tuple.Pair; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; @@ -44,8 +44,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingPa import org.onap.policy.vfc.VfcRequest; import org.onap.policy.vfc.VfcResponse; -@RunWith(MockitoJUnitRunner.class) -public class RestartTest extends BasicVfcOperation { +@ExtendWith(MockitoExtension.class) + class RestartTest extends BasicVfcOperation { private static final String TEST_SERVICE_INSTANCE_ID = "test-service-instance-id"; private static final String TEST_VSERVER_ID = "test-vserver-id"; private static final String TEST_VSERVER_NAME = "test-vserver-name"; @@ -54,21 +54,21 @@ public class RestartTest extends BasicVfcOperation { private Restart restartOper; - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { initBeforeClass(); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } /** * setup restart operation. */ - @Before - public void setup() throws Exception { + @BeforeEach + void setup() throws Exception { super.setUp(); restartOper = new Restart(params, config); @@ -80,7 +80,7 @@ public class RestartTest extends BasicVfcOperation { * Tests "success" case with simulator. */ @Test - public void testSuccess() throws Exception { + void testSuccess() throws Exception { HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT).path("ns").pollPath("jobs") .maxPolls(1).build(); config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory()); @@ -98,14 +98,14 @@ public class RestartTest extends BasicVfcOperation { } @Test - public void testConstructor() { + void testConstructor() { CompletableFuture<OperationOutcome> futureRes = restartOper.startOperationAsync(1, outcome); assertNotNull(futureRes); assertEquals(0, restartOper.getPollCount()); } @Test - public void testGetPropertyNames() { + void testGetPropertyNames() { // @formatter:off assertThat(restartOper.getPropertyNames()).isEqualTo( List.of( @@ -117,7 +117,7 @@ public class RestartTest extends BasicVfcOperation { } @Test - public void testMakeRequest() { + void testMakeRequest() { Pair<String, VfcRequest> resultPair = restartOper.makeRequest(); assertNotNull(resultPair.getLeft()); assertNotNull(resultPair.getRight()); diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java index 08ce8e194..88176a283 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcActorTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2018-2019 AT&T Corp. 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. @@ -22,17 +22,17 @@ package org.onap.policy.controlloop.actor.vfc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.controlloop.actor.test.BasicActor; -public class VfcActorTest extends BasicActor { +class VfcActorTest extends BasicActor { @Test - public void testConstructor() { + void testConstructor() { VfcActor prov = new VfcActor(); assertEquals(0, prov.getSequenceNumber()); @@ -44,7 +44,7 @@ public class VfcActorTest extends BasicActor { } @Test - public void testActorService() { + void testActorService() { // verify that it all plugs into the ActorService verifyActorService(VfcActor.NAME, "service.yaml"); } diff --git a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java index aee9b323e..920e79984 100644 --- a/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java +++ b/models-interactions/model-actors/actor.vfc/src/test/java/org/onap/policy/controlloop/actor/vfc/VfcOperationTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023 Nordix Foundation. + * Modifications Copyright (C) 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,31 +21,31 @@ package org.onap.policy.controlloop.actor.vfc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertSame; -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.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.vfc.VfcResponse; import org.onap.policy.vfc.VfcResponseDescriptor; -@RunWith(MockitoJUnitRunner.class) -public class VfcOperationTest extends BasicVfcOperation { +@ExtendWith(MockitoExtension.class) + class VfcOperationTest extends BasicVfcOperation { private VfcOperation oper; /** * setUp. */ - @Before + @BeforeEach @Override - public void setUp() throws Exception { + void setUp() throws Exception { super.setUp(); initConfig(); @@ -54,7 +54,7 @@ public class VfcOperationTest extends BasicVfcOperation { } @Test - public void testConstructor() { + void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(DEFAULT_OPERATION, oper.getName()); assertSame(config, oper.getConfig()); @@ -62,13 +62,13 @@ public class VfcOperationTest extends BasicVfcOperation { } @Test - public void testResetPollCount() { + void testResetPollCount() { oper.resetPollCount(); assertEquals(0, oper.getPollCount()); } @Test - public void testGetRequestState() { + void testGetRequestState() { VfcResponse mockResponse = Mockito.mock(VfcResponse.class); Mockito.when(mockResponse.getResponseDescriptor()).thenReturn(null); assertNull(oper.getRequestState(mockResponse)); @@ -82,7 +82,7 @@ public class VfcOperationTest extends BasicVfcOperation { } @Test - public void testIsSuccess() { + void testIsSuccess() { assertTrue(oper.isSuccess(rawResponse, response)); } } |