summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java31
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java15
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java2
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java14
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml234
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java39
-rwxr-xr-x[-rw-r--r--]participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java26
7 files changed, 253 insertions, 108 deletions
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
index eaf94552b..329921f34 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandler.java
@@ -42,6 +42,7 @@ import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -269,7 +270,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
}
/**
- * Get Data List.
+ * Get Instance Data List.
*
* @return the InternalDatas
*/
@@ -343,4 +344,32 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
unlock(automationCompositionId, element.getId());
}
}
+
+ /**
+ * Get Composition Data List.
+ *
+ * @return the InternalDatas
+ */
+ public InternalDatas getCompositionDataList() {
+ var acElementsDefinitions = intermediaryApi.getAcElementsDefinitions();
+ var internalDatas = new InternalDatas();
+ for (var entry : acElementsDefinitions.entrySet()) {
+ for (var acElementsDefinition : entry.getValue().values()) {
+ var internalData = new InternalData();
+ internalData.setCompositionId(entry.getKey());
+ internalData.setCompositionDefinitionElementId(acElementsDefinition.getAcElementDefinitionId());
+ internalData.setIntProperties(
+ acElementsDefinition.getAutomationCompositionElementToscaNodeTemplate().getProperties());
+ internalData.setOutProperties(acElementsDefinition.getOutProperties());
+ internalDatas.getList().add(internalData);
+ }
+ }
+ return internalDatas;
+ }
+
+ public void setCompositionOutProperties(UUID compositionId, ToscaConceptIdentifier compositionDefinitionElementId,
+ Map<String, Object> outProperties) {
+ intermediaryApi.sendAcDefinitionInfo(compositionId, compositionDefinitionElementId, outProperties);
+
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java
index 14e53338d..5e40bf190 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java
@@ -24,13 +24,16 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.UUID;
import lombok.Data;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@Data
public class InternalData {
- Map<String, Object> intProperties = new LinkedHashMap<>();
- Map<String, Object> outProperties = new LinkedHashMap<>();
- UUID automationCompositionId;
- UUID automationCompositionElementId;
- String useState;
- String operationalState;
+ private Map<String, Object> intProperties = new LinkedHashMap<>();
+ private Map<String, Object> outProperties = new LinkedHashMap<>();
+ private UUID compositionId;
+ private ToscaConceptIdentifier compositionDefinitionElementId;
+ private UUID automationCompositionId;
+ private UUID automationCompositionElementId;
+ private String useState;
+ private String operationalState;
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java
index ca7844657..f4c288d5d 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java
@@ -27,5 +27,5 @@ import lombok.Data;
@Data
public class InternalDatas {
- List<InternalData> list = new ArrayList<>();
+ private List<InternalData> list = new ArrayList<>();
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
index a12e5f70d..db828414d 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/rest/SimulatorController.java
@@ -65,7 +65,7 @@ public class SimulatorController implements SimulatorParticipantControllerApi {
}
/**
- * Set Data.
+ * Set instance Data.
*
* @param body the Data
* @return Void
@@ -77,4 +77,16 @@ public class SimulatorController implements SimulatorParticipantControllerApi {
body.getOutProperties());
return new ResponseEntity<>(HttpStatus.OK);
}
+
+ @Override
+ public ResponseEntity<InternalDatas> getCompositionDatas(UUID xonapRequestId) {
+ return new ResponseEntity<>(automationCompositionElementHandler.getCompositionDataList(), HttpStatus.OK);
+ }
+
+ @Override
+ public ResponseEntity<Void> setCompositionData(UUID xonapRequestId, @Valid InternalData body) {
+ automationCompositionElementHandler.setCompositionOutProperties(body.getCompositionId(),
+ body.getCompositionDefinitionElementId(), body.getOutProperties());
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
index b95aa33cd..c3b02e412 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
+++ b/participant/participant-impl/participant-impl-simulator/src/main/resources/openapi/openapi.yaml
@@ -1,3 +1,20 @@
+# ============LICENSE_START=======================================================
+# Copyright (C) 2023 Nordix Foundation
+# ================================================================================
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
openapi: 3.0.3
info:
title: ACM Simulator Participant
@@ -45,30 +62,14 @@ paths:
description: OK, reutrns a serialised instance of
[SimConfig](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/SimConfig.java)
headers:
- api-version:
- schema:
- type: string
X-LatestVersion:
- schema:
- type: string
- description: Used only to communicate an API's latest version
+ $ref: '#/components/headers/X-LatestVersion'
X-PatchVersion:
- schema:
- type: string
- description:
- Used only to communicate a PATCH version in a response for troubleshooting purposes only,
- and will not be provided by the client on request
+ $ref: '#/components/headers/X-PatchVersion'
X-MinorVersion:
- schema:
- type: string
- description:
- Used to request or communicate a MINOR version back from the client
- to the server, and from the server back to the client
+ $ref: '#/components/headers/X-MinorVersion'
X-onap-RequestId:
- schema:
- type: string
- format: uuid
- description: Used to track REST transactions for logging purposes
+ $ref: '#/components/headers/X-onap-RequestId'
content:
application/json:
schema:
@@ -111,30 +112,14 @@ paths:
200:
description: OK, the parameters has been saved
headers:
- api-version:
- schema:
- type: string
X-LatestVersion:
- schema:
- type: string
- description: Used only to communicate an API's latest version
+ $ref: '#/components/headers/X-LatestVersion'
X-PatchVersion:
- schema:
- type: string
- description:
- Used only to communicate a PATCH version in a response for troubleshooting purposes only,
- and will not be provided by the client on request
+ $ref: '#/components/headers/X-PatchVersion'
X-MinorVersion:
- schema:
- type: string
- description:
- Used to request or communicate a MINOR version back from the client
- to the server, and from the server back to the client
+ $ref: '#/components/headers/X-MinorVersion'
X-onap-RequestId:
- schema:
- type: string
- format: uuid
- description: Used to track REST transactions for logging purposes
+ $ref: '#/components/headers/X-onap-RequestId'
400:
description: Bad Request
401:
@@ -164,30 +149,14 @@ paths:
[AutomationCompositions](https://github.com/onap/policy-clamp/blob/master/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositions.java)
containing a list of automation composition instances found
headers:
- api-version:
- schema:
- type: string
X-LatestVersion:
- schema:
- type: string
- description: Used only to communicate an API's latest version
+ $ref: '#/components/headers/X-LatestVersion'
X-PatchVersion:
- schema:
- type: string
- description:
- Used only to communicate a PATCH version in a response for troubleshooting purposes only,
- and will not be provided by the client on request
+ $ref: '#/components/headers/X-PatchVersion'
X-MinorVersion:
- schema:
- type: string
- description:
- Used to request or communicate a MINOR version back from the client
- to the server, and from the server back to the client
+ $ref: '#/components/headers/X-MinorVersion'
X-onap-RequestId:
- schema:
- type: string
- format: uuid
- description: Used to track REST transactions for logging purposes
+ $ref: '#/components/headers/X-onap-RequestId'
content:
application/json:
schema:
@@ -220,30 +189,14 @@ paths:
description: Serialised instance of
[InternalDatas](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java)
headers:
- api-version:
- schema:
- type: string
X-LatestVersion:
- schema:
- type: string
- description: Used only to communicate an API's latest version
+ $ref: '#/components/headers/X-LatestVersion'
X-PatchVersion:
- schema:
- type: string
- description:
- Used only to communicate a PATCH version in a response for troubleshooting purposes only,
- and will not be provided by the client on request
+ $ref: '#/components/headers/X-PatchVersion'
X-MinorVersion:
- schema:
- type: string
- description:
- Used to request or communicate a MINOR version back from the client
- to the server, and from the server back to the client
+ $ref: '#/components/headers/X-MinorVersion'
X-onap-RequestId:
- schema:
- type: string
- format: uuid
- description: Used to track REST transactions for logging purposes
+ $ref: '#/components/headers/X-onap-RequestId'
content:
application/json:
schema:
@@ -286,30 +239,99 @@ paths:
200:
description: OK, the data has been saved
headers:
- api-version:
- schema:
- type: string
X-LatestVersion:
- schema:
- type: string
- description: Used only to communicate an API's latest version
+ $ref: '#/components/headers/X-LatestVersion'
X-PatchVersion:
- schema:
- type: string
- description:
- Used only to communicate a PATCH version in a response for troubleshooting purposes only,
- and will not be provided by the client on request
+ $ref: '#/components/headers/X-PatchVersion'
X-MinorVersion:
- schema:
- type: string
- description:
- Used to request or communicate a MINOR version back from the client
- to the server, and from the server back to the client
+ $ref: '#/components/headers/X-MinorVersion'
X-onap-RequestId:
+ $ref: '#/components/headers/X-onap-RequestId'
+ 400:
+ description: Bad Request
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ /compositiondatas:
+ get:
+ tags:
+ - Simulator-participant-controller
+ summary: Query details of the requested internal composition datas
+ description: Query details of the requested internal composition datas
+ operationId: getCompositionDatas
+ parameters:
+ - name: X-onap-RequestId
+ in: header
+ description: RequestID for http transaction
+ schema:
+ type: string
+ format: uuid
+ responses:
+ 200:
+ description: Serialised instance of
+ [InternalDatas](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalDatas.java)
+ headers:
+ X-LatestVersion:
+ $ref: '#/components/headers/X-LatestVersion'
+ X-PatchVersion:
+ $ref: '#/components/headers/X-PatchVersion'
+ X-MinorVersion:
+ $ref: '#/components/headers/X-MinorVersion'
+ X-onap-RequestId:
+ $ref: '#/components/headers/X-onap-RequestId'
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/InternalDatas'
+ application/yaml:
schema:
- type: string
- format: uuid
- description: Used to track REST transactions for logging purposes
+ $ref: '#/components/schemas/InternalDatas'
+ 401:
+ description: Authorization Error
+ 500:
+ description: Internal Server Error
+ security:
+ - basicAuth: []
+ put:
+ tags:
+ - Simulator-participant-controller
+ summary: change the parameters
+ description: >-
+ Change the data of the Simulator Participant
+ operationId: setCompositionData
+ parameters:
+ - name: X-ONAP-RequestID
+ in: header
+ description: RequestID for http transaction
+ required: false
+ schema:
+ type: string
+ format: uuid
+ requestBody:
+ description: The data in a serialised instance of
+ [InternalData](https://github.com/onap/policy-clamp/blob/master/participant/participant-impl/policy-clamp-participant-impl-simulator/src/main/java/org/onap/policy/clamp/acm/participant/sim/model/InternalData.java)
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/InternalData'
+ application/yaml:
+ schema:
+ $ref: '#/components/schemas/InternalData'
+ responses:
+ 200:
+ description: OK, the data has been saved
+ headers:
+ X-LatestVersion:
+ $ref: '#/components/headers/X-LatestVersion'
+ X-PatchVersion:
+ $ref: '#/components/headers/X-PatchVersion'
+ X-MinorVersion:
+ $ref: '#/components/headers/X-MinorVersion'
+ X-onap-RequestId:
+ $ref: '#/components/headers/X-onap-RequestId'
400:
description: Bad Request
401:
@@ -337,3 +359,17 @@ components:
InternalData:
title: InternalData
type: object
+ headers:
+ X-LatestVersion:
+ schema:
+ type: string
+ X-PatchVersion:
+ schema:
+ type: string
+ X-MinorVersion:
+ schema:
+ type: string
+ X-onap-RequestId:
+ schema:
+ type: string
+ format: uuid
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
index 70111cb52..ed3f0745b 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/main/handler/AutomationCompositionElementHandlerTest.java
@@ -20,6 +20,7 @@
package org.onap.policy.clamp.acm.participant.sim.main.handler;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -34,10 +35,13 @@ import org.onap.policy.clamp.acm.participant.sim.comm.CommonTestData;
import org.onap.policy.clamp.acm.participant.sim.model.SimConfig;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.clamp.models.acm.concepts.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
class AutomationCompositionElementHandlerTest {
@@ -295,4 +299,39 @@ class AutomationCompositionElementHandlerTest {
verify(intermediaryApi).updateAutomationCompositionElementState(instanceId, element.getId(), null,
LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
}
+
+ @Test
+ void testGetCompositionDataList() {
+ var acElementDefinition = new AutomationCompositionElementDefinition();
+ var toscaConceptIdentifier = new ToscaConceptIdentifier("code", "1.0.0");
+ acElementDefinition.setAcElementDefinitionId(toscaConceptIdentifier);
+ acElementDefinition.setAutomationCompositionElementToscaNodeTemplate(new ToscaNodeTemplate());
+ Map<String, Object> outProperties = Map.of("code", "value");
+ Map<String, Object> inProperties = Map.of("key", "value");
+ acElementDefinition.getAutomationCompositionElementToscaNodeTemplate().setProperties(inProperties);
+ acElementDefinition.setOutProperties(outProperties);
+ var elementsDefinitions = Map.of(toscaConceptIdentifier, acElementDefinition);
+ var compositionId = UUID.randomUUID();
+ var map = Map.of(compositionId, elementsDefinitions);
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ when(intermediaryApi.getAcElementsDefinitions()).thenReturn(map);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+
+ var result = acElementHandler.getCompositionDataList();
+ assertThat(result.getList()).hasSize(1);
+ assertEquals(result.getList().get(0).getCompositionId(), compositionId);
+ assertEquals(result.getList().get(0).getCompositionDefinitionElementId(), toscaConceptIdentifier);
+ assertEquals(result.getList().get(0).getOutProperties(), outProperties);
+ assertEquals(result.getList().get(0).getIntProperties(), inProperties);
+ }
+
+ @Test
+ void testSetCompositionData() {
+ var intermediaryApi = mock(ParticipantIntermediaryApi.class);
+ var acElementHandler = new AutomationCompositionElementHandler(intermediaryApi);
+
+ var compositionId = UUID.randomUUID();
+ acElementHandler.setCompositionOutProperties(compositionId, null, Map.of());
+ verify(intermediaryApi).sendAcDefinitionInfo(compositionId, null, Map.of());
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
index bcdabc86d..3592a1998 100644..100755
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/acm/participant/sim/rest/AcSimRestTest.java
@@ -64,6 +64,7 @@ class AcSimRestTest {
private static final String CONFIG_URL = "/v2/parameters";
private static final String INSTANCE_URL = "/v2/instances";
private static final String DATAS_URL = "/v2/datas";
+ private static final String COMPOSITION_DATAS_URL = "/v2/compositiondatas";
@Autowired
private MockMvc mockMvc;
@@ -140,4 +141,29 @@ class AcSimRestTest {
mockMvc.perform(requestBuilder).andExpect(status().isOk());
}
+
+ @Test
+ void testgetCompositionDatas() throws Exception {
+ var internalDatas = new InternalDatas();
+ var internalData = new InternalData();
+ internalData.setCompositionId(UUID.randomUUID());
+ internalDatas.getList().add(internalData);
+
+ doReturn(internalDatas).when(automationCompositionElementHandler).getCompositionDataList();
+
+ var requestBuilder = MockMvcRequestBuilders.get(COMPOSITION_DATAS_URL).accept(MediaType.APPLICATION_JSON_VALUE);
+ var result = mockMvc.perform(requestBuilder).andExpect(status().isOk())
+ .andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)).andReturn();
+ var body = result.getResponse().getContentAsString();
+ var acsResult = CODER.decode(body, InternalDatas.class);
+ assertEquals(internalData.getCompositionId(), acsResult.getList().get(0).getCompositionId());
+ }
+
+ @Test
+ void testsetCompositionDatas() throws Exception {
+ var requestBuilder = MockMvcRequestBuilders.put(COMPOSITION_DATAS_URL).accept(MediaType.APPLICATION_JSON_VALUE)
+ .content(CODER.encode(new InternalData())).contentType(MediaType.APPLICATION_JSON_VALUE);
+
+ mockMvc.perform(requestBuilder).andExpect(status().isOk());
+ }
}