diff options
author | zhaoyh6 <zhaoyh6@asiainfo.com> | 2022-03-01 14:58:07 +0800 |
---|---|---|
committer | Ajith Sreekumar <ajith.sreekumar@bell.ca> | 2022-03-10 15:09:32 +0000 |
commit | 448c221502fac54c52e088caca56b9aa45797ef7 (patch) | |
tree | d7504ea0c277055042b91cd2cb61b820e5c8eecd /models-interactions/model-actors/actor.so/src/test | |
parent | bf4c0bd31b6045a25ecf24b9508bc256cb724b20 (diff) |
Closed loop operation guarantee for ccvpn
Issue-ID: REQ-1074
Signed-off-by: zhaoyh6 <zhaoyh6@asiainfo.com>
Change-Id: Ib2c60a1e5ebd1fda5e04e75c265e863733caa278
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/test')
3 files changed, 135 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java new file mode 100644 index 000000000..1c8920368 --- /dev/null +++ b/models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2022 CTC, Inc. and others. All rights reserved. + * ================================================================================ + * 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.assertj.core.api.Assertions.assertThatIllegalStateException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.List; +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.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 ModifyCllTest extends BasicSoOperation { + + private ModifyCll oper; + + + public ModifyCllTest() { + super(DEFAULT_ACTOR, ModifyCll.NAME); + } + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + initBeforeClass(); + } + + @AfterClass + public static void tearDownAfterClass() { + destroyAfterClass(); + } + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + oper = new ModifyCll(params, config); + } + + @Test + public void testSuccess() throws Exception { + HttpPollingParams opParams = HttpPollingParams.builder().clientName(MY_CLIENT) + .path("infra/serviceIntent/v1/modify") + .pollPath("orchestrationRequests/v5/").maxPolls(2).build(); + config = new HttpPollingConfig(blockingExecutor, opParams, HttpClientFactoryInstance.getClientFactory()); + params = params.toBuilder().retry(0).timeoutSec(50).executor(blockingExecutor).build(); + + oper = new ModifyCll(params, config); + oper.setProperty(OperationProperties.EVENT_PAYLOAD, getPayload()); + outcome = oper.start().get(); + + assertEquals(OperationResult.SUCCESS, outcome.getResult()); + assertTrue(outcome.getResponse() instanceof SoResponse); + } + + @Test + public void testConstructor() { + assertEquals(DEFAULT_ACTOR, oper.getActorName()); + assertEquals(ModifyCll.NAME, oper.getName()); + assertFalse(oper.isUsePolling()); + + params = params.toBuilder().targetType(null).build(); + assertThatIllegalArgumentException().isThrownBy(() -> new ModifyCll(params, config)) + .withMessageContaining("Target information"); + } + + @Test + public void testGetPropertyNames() { + assertThat(oper.getPropertyNames()).isEqualTo(List.of(OperationProperties.EVENT_PAYLOAD)); + } + + private String getPayload() { + return ResourceUtils.getResourceAsString("src/test/resources/ModifyCll.json"); + } + + /** + * Tests makeRequest() when a property is missing. + */ + @Test + public void testMakeRequestMissingProperty() throws Exception { + oper = new ModifyCll(params, config); + + assertThatIllegalStateException().isThrownBy(() -> oper.makeRequest()) + .withMessageContaining("missing event payload"); + } + +} diff --git a/models-interactions/model-actors/actor.so/src/test/resources/ModifyCll.json b/models-interactions/model-actors/actor.so/src/test/resources/ModifyCll.json new file mode 100644 index 000000000..03c048474 --- /dev/null +++ b/models-interactions/model-actors/actor.so/src/test/resources/ModifyCll.json @@ -0,0 +1,16 @@ +{ + "name": "cloud-leased-line-101", + "globalSubscriberId": "IBNCustomer", + "subscriptionServiceType": "IBN", + "serviceType": "CLL", + "serviceInstanceID": "cll-instance-01", + "additionalProperties": { + "modifyAction": "bandwdith", + "enableSdnc": "true", + "transportNetworks": [ + { "id": "cll-101-network-001", + "sla": + { "latency": 2, "maxBandwidth": 8000 } + }] + } +} 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 81b0f2e26..11197e933 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 @@ -3,6 +3,7 @@ # ONAP # =============================================================================== # Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. +# Modifications Copyright (C) 2022 CTC, Inc. and others. # =============================================================================== # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -36,3 +37,5 @@ actors: path: serviceInstances/v7 Modify NSSI: path: 3gppservices/v7/modify + ModifyCloudLeasedLine: + path: infra/serviceIntent/v1/modify
\ No newline at end of file |