summaryrefslogtreecommitdiffstats
path: root/models-interactions
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyCll.java79
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java2
-rw-r--r--models-interactions/model-actors/actor.so/src/test/java/org/onap/policy/controlloop/actor/so/ModifyCllTest.java116
-rw-r--r--models-interactions/model-actors/actor.so/src/test/resources/ModifyCll.json16
-rw-r--r--models-interactions/model-actors/actor.so/src/test/resources/service.yaml3
-rw-r--r--models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestCll.java44
-rw-r--r--models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestCllTest.java48
-rw-r--r--models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java9
-rw-r--r--models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.cll.success.json5
-rw-r--r--models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java28
10 files changed, 350 insertions, 0 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyCll.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyCll.java
new file mode 100644
index 000000000..48e20e309
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyCll.java
@@ -0,0 +1,79 @@
+/*-
+ * ============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 java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import org.onap.policy.common.endpoints.event.comm.Topic;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.so.SoRequestCll;
+
+public class ModifyCll extends SoOperation {
+ public static final String NAME = "ModifyCloudLeasedLine";
+
+ private static final List<String> PROPERTY_NAMES = List.of(
+ OperationProperties.EVENT_PAYLOAD);
+
+ /**
+ * Constructs the object.
+ *
+ * @param params operation parameters
+ * @param config configuration for this operation
+ */
+ public ModifyCll(ControlLoopOperationParams params, HttpPollingConfig config) {
+ super(params, config, PROPERTY_NAMES);
+ }
+
+ @Override
+ protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
+
+ SoRequestCll soRequest = makeRequest();
+
+ String path = getPath();
+ String url = getClient().getBaseUrl() + path;
+
+ String strRequest = prettyPrint(soRequest);
+ logMessage(NetLoggerUtil.EventType.OUT, Topic.CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
+ Map<String, Object> headers = createSimpleHeaders();
+
+ return handleResponse(outcome, url, callback -> getClient().put(callback, path, entity, headers));
+ }
+
+ protected SoRequestCll makeRequest() {
+
+ String payload = getRequiredProperty(OperationProperties.EVENT_PAYLOAD, "event payload");
+ try {
+ return getCoder().convert(payload, SoRequestCll.class);
+ } catch (CoderException e) {
+ throw new IllegalArgumentException("invalid payload value: " + payload, e);
+ }
+ }
+}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
index 195fbcb96..f1505ed46 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
@@ -5,6 +5,7 @@
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020 Wipro Limited.
+ * 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.
@@ -38,5 +39,6 @@ public class SoActor extends HttpActor<HttpPollingActorParams> {
addOperator(new HttpPollingOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
addOperator(new HttpPollingOperator(NAME, VfModuleDelete.NAME, VfModuleDelete::new));
addOperator(new HttpPollingOperator(NAME, ModifyNssi.NAME, ModifyNssi::new));
+ addOperator(new HttpPollingOperator(NAME, ModifyNssi.NAME, ModifyCll::new));
}
}
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
diff --git a/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestCll.java b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestCll.java
new file mode 100644
index 000000000..452d46faf
--- /dev/null
+++ b/models-interactions/model-impl/so/src/main/java/org/onap/policy/so/SoRequestCll.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2022 CTC Intellectual Property. 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.so;
+
+import com.google.gson.annotations.SerializedName;
+import java.io.Serializable;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class SoRequestCll implements Serializable {
+
+ private static final long serialVersionUID = -3283942659786236032L;
+
+ private String name;
+
+ @SerializedName("serviceInstanceID")
+ private String serviceInstanceId;
+
+ private String globalSubscriberId;
+ private String subscriptionServiceType;
+ private String serviceType;
+ private Map<String, Object> additionalProperties;
+}
diff --git a/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestCllTest.java b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestCllTest.java
new file mode 100644
index 000000000..3d3168656
--- /dev/null
+++ b/models-interactions/model-impl/so/src/test/java/org/onap/policy/so/SoRequestCllTest.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2022 CTC Intellectual Property. 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.so;
+
+import com.openpojo.reflection.PojoClass;
+import com.openpojo.reflection.impl.PojoClassFactory;
+import com.openpojo.validation.Validator;
+import com.openpojo.validation.ValidatorBuilder;
+import com.openpojo.validation.rule.impl.GetterMustExistRule;
+import com.openpojo.validation.rule.impl.SetterMustExistRule;
+import com.openpojo.validation.test.impl.GetterTester;
+import com.openpojo.validation.test.impl.SetterTester;
+import org.junit.Test;
+
+public class SoRequestCllTest {
+
+ @Test
+ public void testSetGet() {
+ PojoClass pojoClass = PojoClassFactory.getPojoClass(SoRequestCll.class);
+ Validator validator = ValidatorBuilder
+ .create()
+ .with(new SetterMustExistRule())
+ .with(new GetterMustExistRule())
+ .with(new SetterTester())
+ .with(new GetterTester())
+ .build();
+
+ validator.validate(pojoClass);
+ }
+}
diff --git a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
index 3d2187895..948529fab 100644
--- a/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
+++ b/models-interactions/model-simulators/src/main/java/org/onap/policy/simulators/SoSimulatorJaxRs.java
@@ -5,6 +5,7 @@
* Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020 Wipro Limited.
+ * 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.
@@ -134,6 +135,14 @@ public class SoSimulatorJaxRs {
return ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.3gpp.success.json");
}
+ @PUT
+ @Path("/infra/serviceIntent/v1/modify")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces("application/json")
+ public String soPostModifyCll(@ApiParam(required = true) SoRequest3gpp request) {
+ return ResourceUtils.getResourceAsString("org/onap/policy/simulators/so/so.cll.success.json");
+ }
+
private String makeStarted() {
var requestId = UUID.randomUUID().toString();
diff --git a/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.cll.success.json b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.cll.success.json
new file mode 100644
index 000000000..98f045503
--- /dev/null
+++ b/models-interactions/model-simulators/src/main/resources/org/onap/policy/simulators/so/so.cll.success.json
@@ -0,0 +1,5 @@
+{
+ "jobId": "db245365e79c47ed88fcd60caa8f6549",
+ "status": "In progress",
+ "statusDescription": {}
+}
diff --git a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
index 7654e0053..31b76270c 100644
--- a/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
+++ b/models-interactions/model-simulators/src/test/java/org/onap/policy/simulators/SoSimulatorTest.java
@@ -5,6 +5,7 @@
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2020 Wipro Limited.
+ * 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.
@@ -42,6 +43,7 @@ import org.onap.policy.so.SoRelatedInstance;
import org.onap.policy.so.SoRelatedInstanceListElement;
import org.onap.policy.so.SoRequest;
import org.onap.policy.so.SoRequest3gpp;
+import org.onap.policy.so.SoRequestCll;
import org.onap.policy.so.SoRequestDetails;
import org.onap.policy.so.SoRequestInfo;
import org.onap.policy.so.SoRequestParameters;
@@ -248,6 +250,32 @@ public class SoSimulatorTest {
return request;
}
+ @Test
+ public void testModifyCll() {
+ SoSimulatorJaxRs.setRequirePolling(false);
+ String request = Serialization.gsonPretty.toJson(this.createCllRequest());
+ Pair<Integer, String> httpDetails = new RestManager().put(
+ "http://localhost:6667/infra/serviceIntent/v1/modify",
+ "username",
+ "password", new HashMap<>(), "application/json", request);
+ assertNotNull(httpDetails);
+ assertEquals(200, httpDetails.getLeft().intValue());
+ assertThat(httpDetails.getRight()).contains("jobId").contains("status");
+ }
+
+ private SoRequestCll createCllRequest() {
+ SoRequestCll request = new SoRequestCll();
+
+ request.setName("cloud-leased-line-101");
+ request.setServiceInstanceId("cll-instance-01");
+ request.setGlobalSubscriberId("IBNCustomer");
+ request.setSubscriptionServiceType("ibn");
+ request.setServiceType("CLL");
+ request.setAdditionalProperties(new HashMap<String, Object>());
+
+ return request;
+ }
+
private String extractUri(String response) {
final String prefix = "\"requestId\": \"";