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.appc/src | |
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.appc/src')
4 files changed, 66 insertions, 66 deletions
diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java index 5d9ce0d7a..eda2ab586 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcActorTest.java @@ -21,19 +21,19 @@ package org.onap.policy.controlloop.actor.appc; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.stream.Stream; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.policy.controlloop.actor.test.BasicActor; -@RunWith(MockitoJUnitRunner.class) -public class AppcActorTest extends BasicActor { +@ExtendWith(MockitoExtension.class) + class AppcActorTest extends BasicActor { @Test - public void testConstructor() { + void testConstructor() { AppcActor prov = new AppcActor(); assertEquals(0, prov.getSequenceNumber()); @@ -45,7 +45,7 @@ public class AppcActorTest extends BasicActor { } @Test - public void testActorService() { + void testActorService() { // verify that it all plugs into the ActorService verifyActorService(AppcActor.NAME, "service.yaml"); } diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java index b6e9b34e7..caa190f71 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcOperationTest.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,21 +22,21 @@ package org.onap.policy.controlloop.actor.appc; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; import java.util.Arrays; import java.util.Collections; import java.util.Map; import java.util.TreeMap; -import org.junit.After; -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.AfterEach; +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.appc.CommonHeader; import org.onap.policy.appc.Request; import org.onap.policy.appc.ResponseCode; @@ -46,46 +46,46 @@ import org.onap.policy.controlloop.actorserviceprovider.impl.BidirectionalTopicO import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; -@RunWith(MockitoJUnitRunner.class) -public class AppcOperationTest extends BasicAppcOperation { +@ExtendWith(MockitoExtension.class) + class AppcOperationTest extends BasicAppcOperation { private AppcOperation oper; - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { // use same topic name for both sides initBeforeClass(MY_SINK, MY_SINK); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } /** * Sets up. */ - @Before + @BeforeEach @Override - public void setUp() throws Exception { + void setUp() throws Exception { super.setUp(); oper = new MyOper(params, config); } - @After + @AfterEach @Override - public void tearDown() { + void tearDown() { super.tearDown(); } @Test - public void testConstructor() { + void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(DEFAULT_OPERATION, oper.getName()); } @Test - public void testMakeRequest() { + void testMakeRequest() { oper.generateSubRequestId(2); String subreq = oper.getSubRequestId(); assertNotNull(subreq); @@ -111,7 +111,7 @@ public class AppcOperationTest extends BasicAppcOperation { } @Test - public void testConvertPayload() { + void testConvertPayload() { Request request = oper.makeRequest(genvnf); // @formatter:off @@ -164,7 +164,7 @@ public class AppcOperationTest extends BasicAppcOperation { } @Test - public void testGetExpectedKeyValues() { + void testGetExpectedKeyValues() { oper.generateSubRequestId(2); Request request = oper.makeRequest(genvnf); assertEquals(Arrays.asList(request.getCommonHeader().getSubRequestId()), @@ -172,7 +172,7 @@ public class AppcOperationTest extends BasicAppcOperation { } @Test - public void testDetmStatusStringResponse() { + void testDetmStatusStringResponse() { final ResponseStatus status = response.getStatus(); // null status (i.e., it's a Request, not a Response) @@ -204,7 +204,7 @@ public class AppcOperationTest extends BasicAppcOperation { } @Test - public void testSetOutcome() { + void testSetOutcome() { final ResponseStatus status = response.getStatus(); // null status @@ -233,7 +233,7 @@ public class AppcOperationTest extends BasicAppcOperation { private class MyOper extends AppcOperation { - public MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) { + MyOper(ControlLoopOperationParams params, BidirectionalTopicConfig config) { super(params, config, Collections.emptyList()); } diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java index 25993d385..b934d8659 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/BasicAppcOperation.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 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. @@ -20,16 +21,15 @@ package org.onap.policy.controlloop.actor.appc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; import java.util.Map; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import java.util.function.BiConsumer; import org.onap.aai.domain.yang.GenericVnf; import org.onap.policy.appc.Request; @@ -86,7 +86,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio /** * Initializes mocks and sets up. */ - public void setUp() throws Exception { + void setUp() throws Exception { super.setUpBasic(); response = new Response(); @@ -100,7 +100,7 @@ public abstract class BasicAppcOperation extends BasicBidirectionalTopicOperatio genvnf.setVnfId(MY_VNF); } - public void tearDown() { + void tearDown() { super.tearDownBasic(); } diff --git a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java index e42811191..fad504434 100644 --- a/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java +++ b/models-interactions/model-actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/ModifyConfigOperationTest.java @@ -22,55 +22,55 @@ package org.onap.policy.controlloop.actor.appc; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import java.util.List; -import org.junit.After; -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.AfterEach; +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.appc.Request; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicParams; -@RunWith(MockitoJUnitRunner.class) -public class ModifyConfigOperationTest extends BasicAppcOperation { +@ExtendWith(MockitoExtension.class) + class ModifyConfigOperationTest extends BasicAppcOperation { private ModifyConfigOperation oper; - public ModifyConfigOperationTest() { + ModifyConfigOperationTest() { super(DEFAULT_ACTOR, ModifyConfigOperation.NAME); } - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { // use same topic name for both sides initBeforeClass(MY_SINK, MY_SINK); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } - @Before + @BeforeEach @Override - public void setUp() throws Exception { + void setUp() throws Exception { super.setUp(); oper = new ModifyConfigOperation(params, config); } - @After + @AfterEach @Override - public void tearDown() { + void tearDown() { super.tearDown(); } @@ -78,7 +78,7 @@ public class ModifyConfigOperationTest extends BasicAppcOperation { * Tests "success" case with simulator. */ @Test - public void testSuccess() throws Exception { + void testSuccess() throws Exception { BidirectionalTopicParams opParams = BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SINK).build(); config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, AppcOperation.SELECTOR_KEYS); @@ -96,18 +96,18 @@ public class ModifyConfigOperationTest extends BasicAppcOperation { } @Test - public void testConstructor() { + void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(ModifyConfigOperation.NAME, oper.getName()); } @Test - public void testGetPropertyNames() { + void testGetPropertyNames() { assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.AAI_RESOURCE_VNF)); } @Test - public void testMakeRequest() throws CoderException { + void testMakeRequest() throws CoderException { oper.setProperty(OperationProperties.AAI_RESOURCE_VNF, genvnf); oper.generateSubRequestId(2); |