diff options
author | krishnaa96 <krishna.moorthy6@wipro.com> | 2020-08-26 14:59:04 +0530 |
---|---|---|
committer | krishnaa96 <krishna.moorthy6@wipro.com> | 2020-09-01 19:00:35 +0530 |
commit | 0690ef13433cb30d3d6c475990a818a714f0538d (patch) | |
tree | bb0ec20c49777f224057b2bb929b64aa79c6b456 /models-interactions/model-actors/actor.so/src/test | |
parent | b13f57c283bf7e90db88e159d0e3e8bd6ba6f698 (diff) |
Add Modify NSSI operation in SO actor
Issue-ID: POLICY-2586
Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com>
Change-Id: I6ac184a6e731767f06401a0ac984c6b448c5d82f
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/test')
7 files changed, 149 insertions, 4 deletions
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java new file mode 100644 index 000000000..21d7229a3 --- /dev/null +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyNssiTest.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2020 Wipro Limited. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.controlloop.actor.so; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; +import java.util.Map; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; +import org.onap.policy.common.utils.coder.CoderException; +import org.onap.policy.common.utils.coder.StandardCoder; +import org.onap.policy.common.utils.resources.ResourceUtils; +import org.onap.policy.controlloop.actorserviceprovider.OperationProperties; +import org.onap.policy.controlloop.actorserviceprovider.OperationResult; +import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig; +import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingParams; +import org.onap.policy.so.SoResponse; + +public class ModifyNssiTest extends BasicSoOperation { + + private ModifyNssi oper; + + private static StandardCoder coder = new StandardCoder(); + + public ModifyNssiTest() { + super(DEFAULT_ACTOR, ModifyNssi.NAME); + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + initBeforeClass(); + } + + @AfterClass + public static void tearDownAfterClass() { + destroyAfterClass(); + } + + @Before + public void setUp() throws Exception { + super.setUp(); + oper = new ModifyNssi(params, config); + } + + @Test + public void testSuccess() throws Exception { + HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT) + .path("3gppservices/v7/modify").pollPath("orchestrationRequests/v5/") + .maxPolls(2).build(); + config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory()); + params = params.toBuilder().retry(0).timeoutSec(5).executor(blockingExecutor).build(); + + oper = new ModifyNssi(params, config); + + outcome = oper.start().get(); + + assertEquals(OperationResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof SoResponse); + } + + @Test + public void testConstructor() { + assertEquals(DEFAULT_ACTOR, oper.getActorName()); + assertEquals(ModifyNssi.NAME, oper.getName()); + assertFalse(oper.isUsePolling()); + + params = params.toBuilder().targetType(null).build(); + assertThatIllegalArgumentException().isThrownBy(() -> new ModifyNssi(params, config)) + .withMessageContaining("Target information"); + } + + @Test + public void testGetPropertyNames() { + assertThat(oper.getPropertyNames()).isEqualTo( + List.of( + OperationProperties.AAI_SERVICE, + OperationProperties.EVENT_PAYLOAD)); + } + + @Override + protected Map<String, Object> makePayload() { + String payloadString = ResourceUtils + .getResourceAsString("src/test/resources/ModifyNSSI.json"); + + try { + return coder.decode(payloadString, Map.class); + } catch (CoderException e) { + throw new IllegalArgumentException("invalid payload value: " + payloadString, e); + } + } +} diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java index b42b3f8dd..79b9944d3 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoActorTest.java @@ -5,6 +5,7 @@ * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2018-2020 AT&T. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2020 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,8 +37,8 @@ public class SoActorTest extends BasicActor { SoActor prov = new SoActor(); // verify that it has the operators we expect - var expected = Arrays.asList(VfModuleCreate.NAME, VfModuleDelete.NAME).stream().sorted() - .collect(Collectors.toList()); + var expected = Arrays.asList(VfModuleCreate.NAME, VfModuleDelete.NAME, ModifyNssi.NAME).stream() + .sorted().collect(Collectors.toList()); var actual = prov.getOperationNames().stream().sorted().collect(Collectors.toList()); assertEquals(expected.toString(), actual.toString()); diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java index 464e5d162..e9a49545e 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/SoOperationTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +82,7 @@ public class SoOperationTest extends BasicSoOperation { initConfig(); - oper = new SoOperation(params, config, PROP_NAMES) {}; + oper = new SoOperation(params, config, PROP_NAMES, params.getTargetEntityIds()) {}; } @Test @@ -89,7 +90,6 @@ public class SoOperationTest extends BasicSoOperation { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(DEFAULT_OPERATION, oper.getName()); assertSame(config, oper.getConfig()); - assertTrue(oper.isUsePolling()); // check when Target is null params = params.toBuilder().targetType(null).build(); diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java index f1741d677..9d4d00908 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleCreateTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,6 +63,8 @@ import org.onap.policy.so.SoRequest; import org.onap.policy.so.SoResponse; public class VfModuleCreateTest extends BasicSoOperation { + + private static final String MODEL_NAME2 = "my-model-name-B"; private static final String MODEL_VERS2 = "my-model-version-B"; private static final String SVC_INSTANCE_ID = "my-service-instance-id"; @@ -158,6 +161,7 @@ public class VfModuleCreateTest extends BasicSoOperation { public void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(VfModuleCreate.NAME, oper.getName()); + assertTrue(oper.isUsePolling()); // verify that target validation is done params = params.toBuilder().targetType(null).build(); diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java index 2ab1dbe83..300d73b53 100644 --- a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/VfModuleDeleteTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2020 Wipro Limited. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,6 +180,7 @@ public class VfModuleDeleteTest extends BasicSoOperation { public void testConstructor() { assertEquals(DEFAULT_ACTOR, oper.getActorName()); assertEquals(VfModuleDelete.NAME, oper.getName()); + assertTrue(oper.isUsePolling()); // verify that target validation is done params = params.toBuilder().targetType(null).build(); diff --git a/models-interactions/model-actors/actor.so/src/test/resources/ModifyNSSI.json b/models-interactions/model-actors/actor.so/src/test/resources/ModifyNSSI.json new file mode 100644 index 000000000..50dbbcbec --- /dev/null +++ b/models-interactions/model-actors/actor.so/src/test/resources/ModifyNSSI.json @@ -0,0 +1,19 @@ +{ + "name": "eMBB-001", + "globalSubscriberId": "5GCustomer", + "subscriptionServiceType": "5G", + "networkType": "an", + "serviceInstanceID": "02328c27-bb1a-4b0d-a437-111dc7087665", + "additionalProperties": { + "modifyAction": "allocate", + "snssaiList": [ + "001-100001" + ], + "sliceProfileId": "", + "nsiInfo": { + "nsiId": "NSI-M-001-HDBNJ-NSMF-01-A-ZX", + "nsiName": "eMBB-001" + }, + "scriptName": "AN1" + } +} diff --git a/models-interactions/model-actors/actor.so/src/test/resources/service.yaml b/models-interactions/model-actors/actor.so/src/test/resources/service.yaml index e16e7d74a..81b0f2e26 100644 --- a/models-interactions/model-actors/actor.so/src/test/resources/service.yaml +++ b/models-interactions/model-actors/actor.so/src/test/resources/service.yaml @@ -34,3 +34,5 @@ actors: path: serviceInstantiation/v7/serviceInstances VF Module Delete: path: serviceInstances/v7 + Modify NSSI: + path: 3gppservices/v7/modify |