diff options
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc')
5 files changed, 81 insertions, 79 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java index 4619fee50..3510c4a67 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BandwidthOnDemandOperationTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020-2021 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. @@ -23,16 +23,16 @@ package org.onap.policy.controlloop.actor.sdnc; 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.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import java.util.List; -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.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; @@ -40,8 +40,8 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; import org.onap.policy.sdnc.SdncResponse; -@RunWith(MockitoJUnitRunner.class) -public class BandwidthOnDemandOperationTest extends BasicSdncOperation { +@ExtendWith(MockitoExtension.class) +class BandwidthOnDemandOperationTest extends BasicSdncOperation { private static final String MY_SERVICE = "my-service"; private static final String MY_VNF = "my-vnf"; private static final String MY_BANDWIDTH = "my-bandwidth"; @@ -49,17 +49,17 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { private BandwidthOnDemandOperation oper; - public BandwidthOnDemandOperationTest() { + BandwidthOnDemandOperationTest() { super(DEFAULT_ACTOR, BandwidthOnDemandOperation.NAME); } - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { initBeforeClass(); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } @@ -67,20 +67,20 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { * Set up. */ @Override - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { super.setUp(); oper = new BandwidthOnDemandOperation(params, config); } @Test - public void testConstructor() { + void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(BandwidthOnDemandOperation.NAME, oper.getName()); } @Test - public void testGetPropertyNames() { + void testGetPropertyNames() { // @formatter:off assertThat(oper.getPropertyNames()).isEqualTo( List.of( @@ -96,7 +96,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { * Tests "success" case with simulator. */ @Test - public void testSuccess() throws Exception { + void testSuccess() throws Exception { HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT) .path("GENERIC-RESOURCE-API:vf-module-topology-operation").build(); config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory()); @@ -111,11 +111,11 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { outcome = oper.start().get(); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof SdncResponse); + assertInstanceOf(SdncResponse.class, outcome.getResponse()); } @Test - public void testMakeRequest() throws Exception { + void testMakeRequest() throws Exception { oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE); oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH); oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME); @@ -129,7 +129,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { */ @Test - public void testMakeRequestMissingBandwidth() throws Exception { + void testMakeRequestMissingBandwidth() throws Exception { oper = new BandwidthOnDemandOperation(params, config); oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE); oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH_CHANGE_TIME, MY_CHANGE_TIME); @@ -143,7 +143,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { } @Test - public void testMakeRequestMissingBandwidthChangeTime() throws Exception { + void testMakeRequestMissingBandwidthChangeTime() throws Exception { oper = new BandwidthOnDemandOperation(params, config); oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE); oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH); @@ -157,7 +157,7 @@ public class BandwidthOnDemandOperationTest extends BasicSdncOperation { } @Test - public void testMakeRequestMissingVnfId() throws Exception { + void testMakeRequestMissingVnfId() throws Exception { oper = new BandwidthOnDemandOperation(params, config); oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE); oper.setProperty(OperationProperties.ENRICHMENT_BANDWIDTH, MY_BANDWIDTH); diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java index a88bb0231..cfdec987d 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/BasicSdncOperation.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,17 +21,17 @@ package org.onap.policy.controlloop.actor.sdnc; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -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.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import org.mockito.Mockito; import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; @@ -47,7 +48,7 @@ import org.onap.policy.simulators.Util; /** * Superclass for various operator tests. */ -public abstract class BasicSdncOperation extends BasicHttpOperation { +abstract class BasicSdncOperation extends BasicHttpOperation { /** * Fields to be ignored when comparing requests with JSON. */ @@ -58,7 +59,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { /** * Constructs the object using a default actor and operation name. */ - public BasicSdncOperation() { + BasicSdncOperation() { super(); } @@ -68,7 +69,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { * @param actor actor name * @param operation operation name */ - public BasicSdncOperation(String actor, String operation) { + BasicSdncOperation(String actor, String operation) { super(actor, operation); } @@ -92,7 +93,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { /** * Initializes mocks and sets up. */ - public void setUp() throws Exception { + void setUp() throws Exception { super.setUpBasic(); response = new SdncResponse(); @@ -101,7 +102,7 @@ public abstract class BasicSdncOperation extends BasicHttpOperation { response.setResponseOutput(output); output.setResponseCode("200"); - when(rawResponse.readEntity(String.class)).thenReturn(new StandardCoder().encode(response)); + Mockito.lenient().when(rawResponse.readEntity(String.class)).thenReturn(new StandardCoder().encode(response)); } /** diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java index df12ad520..5ef4b771a 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/RerouteOperationTest.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,16 +22,16 @@ package org.onap.policy.controlloop.actor.sdnc; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import java.util.List; -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.OperationProperties; import org.onap.policy.controlloop.actorserviceprovider.OperationResult; @@ -39,24 +39,24 @@ import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpParams; import org.onap.policy.sdnc.SdncResponse; -@RunWith(MockitoJUnitRunner.class) -public class RerouteOperationTest extends BasicSdncOperation { +@ExtendWith(MockitoExtension.class) +class RerouteOperationTest extends BasicSdncOperation { private static final String MY_SERVICE = "my-service"; private static final String MY_NETWORK = "my-network"; private RerouteOperation oper; - public RerouteOperationTest() { + RerouteOperationTest() { super(DEFAULT_ACTOR, RerouteOperation.NAME); } - @BeforeClass - public static void setUpBeforeClass() throws Exception { + @BeforeAll + static void setUpBeforeClass() throws Exception { initBeforeClass(); } - @AfterClass - public static void tearDownAfterClass() { + @AfterAll + static void tearDownAfterClass() { destroyAfterClass(); } @@ -64,8 +64,8 @@ public class RerouteOperationTest extends BasicSdncOperation { * Set up. */ @Override - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { super.setUp(); oper = new RerouteOperation(params, config); } @@ -74,7 +74,7 @@ public class RerouteOperationTest extends BasicSdncOperation { * Tests "success" case with simulator. */ @Test - public void testSuccess() throws Exception { + void testSuccess() throws Exception { HttpParams opParams = HttpParams.builder().clientName(MY_CLIENT) .path("GENERIC-RESOURCE-API:network-topology-operation").build(); config = new HttpConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory()); @@ -87,17 +87,17 @@ public class RerouteOperationTest extends BasicSdncOperation { outcome = oper.start().get(); assertEquals(OperationResult.SUCCESS, outcome.getResult()); - assertTrue(outcome.getResponse() instanceof SdncResponse); + assertInstanceOf(SdncResponse.class, outcome.getResponse()); } @Test - public void testConstructor() { + void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(RerouteOperation.NAME, oper.getName()); } @Test - public void testGetPropertyNames() { + void testGetPropertyNames() { // @formatter:off assertThat(oper.getPropertyNames()).isEqualTo( List.of( @@ -107,7 +107,7 @@ public class RerouteOperationTest extends BasicSdncOperation { } @Test - public void testMakeRequest() throws Exception { + void testMakeRequest() throws Exception { oper.setProperty(OperationProperties.ENRICHMENT_SERVICE_ID, MY_SERVICE); oper.setProperty(OperationProperties.ENRICHMENT_NETWORK_ID, MY_NETWORK); diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java index f0f280cb6..b7b209db2 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018-2019 Huawei. All rights reserved. * Modifications Copyright (C) 2018-2020 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,18 @@ package org.onap.policy.controlloop.actor.sdnc; -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 SdncActorTest extends BasicActor { +class SdncActorTest extends BasicActor { @Test - public void testSdncActor() { + void testSdncActor() { final SdncActor prov = new SdncActor(); // verify that it has the operators we expect diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java index 7c9cbb150..12b6db0e5 100644 --- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.java +++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncOperationTest.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,21 +21,21 @@ package org.onap.policy.controlloop.actor.sdnc; -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 java.util.Collections; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +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.sdnc.SdncHealRequest; import org.onap.policy.sdnc.SdncHealRequestHeaderInfo; import org.onap.policy.sdnc.SdncRequest; -@RunWith(MockitoJUnitRunner.class) -public class SdncOperationTest extends BasicSdncOperation { +@ExtendWith(MockitoExtension.class) + class SdncOperationTest extends BasicSdncOperation { private static final String MY_URI = "my-uri"; @@ -46,8 +46,8 @@ public class SdncOperationTest extends BasicSdncOperation { * Sets up. */ @Override - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { super.setUp(); request = new SdncRequest(); @@ -69,18 +69,18 @@ public class SdncOperationTest extends BasicSdncOperation { } @Test - public void testSdncOperator() { + void testSdncOperator() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(DEFAULT_OPERATION, oper.getName()); } @Test - public void testStartOperationAsync_testStartRequestAsync() throws Exception { + void testStartOperationAsync_testStartRequestAsync() throws Exception { verifyOperation(oper); } @Test - public void testIsSuccess() { + void testIsSuccess() { // success case response.getResponseOutput().setResponseCode("200"); assertTrue(oper.isSuccess(null, response)); |