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.sdnr/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.sdnr/src')
3 files changed, 47 insertions, 45 deletions
diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java index 64e88aa6e..ee9a3a1f2 100644 --- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.java +++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/BasicSdnrOperation.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,9 +21,9 @@ package org.onap.policy.controlloop.actor.sdnr; -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; @@ -45,14 +46,14 @@ import org.onap.policy.sdnr.util.StatusCodeEnum; import org.onap.policy.simulators.SdnrTopicServer; import org.onap.policy.simulators.TopicServer; -public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation<PciMessage> { +abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperation<PciMessage> { protected PciMessage response; /** * Constructs the object using a default actor and operation name. */ - public BasicSdnrOperation() { + BasicSdnrOperation() { super(); } @@ -62,14 +63,14 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio * @param actor actor name * @param operation operation name */ - public BasicSdnrOperation(String actor, String operation) { + BasicSdnrOperation(String actor, String operation) { super(actor, operation); } /** * Initializes mocks and sets up. */ - public void setUp() throws Exception { + void setUp() throws Exception { super.setUpBasic(); response = new PciMessage(); @@ -86,7 +87,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio status.setValue(StatusCodeEnum.SUCCESS.toString()); } - public void tearDown() { + void tearDown() { super.tearDownBasic(); } @@ -101,7 +102,7 @@ public abstract class BasicSdnrOperation extends BasicBidirectionalTopicOperatio * @param operation operation to run */ protected void verifyOperation(SdnrOperation operation) - throws InterruptedException, ExecutionException, TimeoutException { + throws InterruptedException, ExecutionException, TimeoutException { CompletableFuture<OperationOutcome> future2 = operation.start(); executor.runAll(100); diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java index 0f023ff55..68a81bb14 100644 --- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java +++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrActorTest.java @@ -3,6 +3,7 @@ * ================================================================================ * Copyright (C) 2018 Wipro Limited Intellectual Property. All rights reserved. * Modifications Copyright (C) 2019-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,20 +21,20 @@ package org.onap.policy.controlloop.actor.sdnr; -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.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.onap.policy.controlloop.actor.test.BasicActor; import org.onap.policy.controlloop.actorserviceprovider.Operator; -public class SdnrActorTest extends BasicActor { +class SdnrActorTest extends BasicActor { @Test - public void testConstructor() { + void testConstructor() { SdnrActor prov = new SdnrActor(); assertEquals(0, prov.getSequenceNumber()); @@ -45,13 +46,13 @@ public class SdnrActorTest extends BasicActor { } @Test - public void testActorService() { + void testActorService() { // verify that it all plugs into the ActorService verifyActorService(SdnrActor.NAME, "service.yaml"); } @Test - public void testGetOperator() { + void testGetOperator() { SdnrActor sp = new SdnrActor(); // should always return the same operator regardless of the name diff --git a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java index 4ad19452a..e16ad1177 100644 --- a/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java +++ b/models-interactions/model-actors/actor.sdnr/src/test/java/org/onap/policy/controlloop/actor/sdnr/SdnrOperationTest.java @@ -23,18 +23,18 @@ package org.onap.policy.controlloop.actor.sdnr; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalStateException; -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.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.controlloop.actor.test.BasicBidirectionalTopicOperation; import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; @@ -46,52 +46,52 @@ import org.onap.policy.sdnr.PciMessage; import org.onap.policy.sdnr.PciRequest; import org.onap.policy.sdnr.util.StatusCodeEnum; -@RunWith(MockitoJUnitRunner.class) -public class SdnrOperationTest extends BasicSdnrOperation { +@ExtendWith(MockitoExtension.class) + class SdnrOperationTest extends BasicSdnrOperation { private SdnrOperation operation; - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { BasicBidirectionalTopicOperation.initBeforeClass(MY_SINK, MY_SOURCE); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } /** * Setup. */ - @Before + @BeforeEach @Override - public void setUp() throws Exception { + void setUp() throws Exception { super.setUp(); operation = new SdnrOperation(params, config); operation.setProperty(OperationProperties.EVENT_PAYLOAD, "my payload"); } - @After + @AfterEach @Override - public void tearDown() { + void tearDown() { super.tearDown(); } @Test - public void testSdnrOperation() { + void testSdnrOperation() { assertEquals(DEFAULT_ACTOR, operation.getActorName()); assertEquals(DEFAULT_OPERATION, operation.getName()); } @Test - public void testGetPropertyNames() { + void testGetPropertyNames() { assertThat(operation.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD)); } @Test - public void testMakeRequest() { + void testMakeRequest() { operation.generateSubRequestId(1); PciMessage request = operation.makeRequest(1); @@ -114,7 +114,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { * Tests makeRequest() when a property is missing. */ @Test - public void testMakeRequestMissingProperty() { + void testMakeRequestMissingProperty() { operation = new SdnrOperation(params, config); operation.generateSubRequestId(1); @@ -125,7 +125,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { } @Test - public void testGetExpectedKeyValues() { + void testGetExpectedKeyValues() { operation.generateSubRequestId(1); PciMessage request = operation.makeRequest(1); @@ -137,7 +137,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { * Tests "success" case with simulator. */ @Test - public void testSuccess() throws Exception { + void testSuccess() throws Exception { BidirectionalTopicParams opParams = BidirectionalTopicParams.builder().sinkTopic(MY_SINK).sourceTopic(MY_SOURCE).build(); config = new BidirectionalTopicConfig(blockingExecutor, opParams, topicMgr, SdnrOperation.SELECTOR_KEYS); @@ -154,7 +154,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { } @Test - public void testDetmStatusStringResponse() { + void testDetmStatusStringResponse() { final org.onap.policy.sdnr.Status status = response.getBody().getOutput().getStatus(); // null status @@ -193,7 +193,7 @@ public class SdnrOperationTest extends BasicSdnrOperation { } @Test - public void testSetOutcome() { + void testSetOutcome() { // with a status value checkOutcome(); assertEquals(StatusCodeEnum.SUCCESS.toString(), outcome.getMessage()); |