aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/test/java/org/onap
diff options
context:
space:
mode:
Diffstat (limited to 'common/src/test/java/org/onap')
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java (renamed from common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java)49
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java (renamed from common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java)12
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java (renamed from common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java)2
-rw-r--r--common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java (renamed from common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java)2
-rw-r--r--common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java151
5 files changed, 33 insertions, 183 deletions
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java
index 6d39337f7..ef0472cdc 100644
--- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/exception/ExceptionsTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/exception/ExceptionsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.common.exception;
+package org.onap.policy.clamp.common.acm.exception;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
@@ -37,45 +37,46 @@ class ExceptionsTest {
@Test
void testExceptions() {
- assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE));
- assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, STRING_TEXT));
- assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException()));
- assertNotNull(new ControlLoopException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
+ assertNotNull(new AutomationCompositionException(Response.Status.OK, MESSAGE));
+ assertNotNull(new AutomationCompositionException(Response.Status.OK, MESSAGE, STRING_TEXT));
+ assertNotNull(new AutomationCompositionException(Response.Status.OK, MESSAGE, new IOException()));
+ assertNotNull(new AutomationCompositionException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
String key = "A String";
- ControlLoopException ae =
- new ControlLoopException(Response.Status.OK, MESSAGE, new IOException("IO exception message"), key);
+ AutomationCompositionException ae = new AutomationCompositionException(Response.Status.OK, MESSAGE,
+ new IOException("IO exception message"), key);
ErrorResponse errorResponse = ae.getErrorResponse();
assertEquals("Message\nIO exception message", String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, ae.getObject());
- assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE));
- assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, STRING_TEXT));
- assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException()));
- assertNotNull(new ControlLoopRuntimeException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
+ assertNotNull(new AutomationCompositionRuntimeException(Response.Status.OK, MESSAGE));
+ assertNotNull(new AutomationCompositionRuntimeException(Response.Status.OK, MESSAGE, STRING_TEXT));
+ assertNotNull(new AutomationCompositionRuntimeException(Response.Status.OK, MESSAGE, new IOException()));
+ assertNotNull(
+ new AutomationCompositionRuntimeException(Response.Status.OK, MESSAGE, new IOException(), STRING_TEXT));
String rkey = "A String";
- ControlLoopRuntimeException re = new ControlLoopRuntimeException(Response.Status.OK, "Runtime Message",
- new IOException("IO runtime exception message"), rkey);
+ AutomationCompositionRuntimeException re = new AutomationCompositionRuntimeException(Response.Status.OK,
+ "Runtime Message", new IOException("IO runtime exception message"), rkey);
errorResponse = re.getErrorResponse();
assertEquals("Runtime Message\nIO runtime exception message",
- String.join("\n", errorResponse.getErrorDetails()));
+ String.join("\n", errorResponse.getErrorDetails()));
assertEquals(key, re.getObject());
- ControlLoopRuntimeException clre = new ControlLoopRuntimeException(ae);
- assertEquals(ae.getErrorResponse().getResponseCode(), clre.getErrorResponse().getResponseCode());
- assertEquals(ae.getMessage(), clre.getMessage());
+ AutomationCompositionRuntimeException acre = new AutomationCompositionRuntimeException(ae);
+ assertEquals(ae.getErrorResponse().getResponseCode(), acre.getErrorResponse().getResponseCode());
+ assertEquals(ae.getMessage(), acre.getMessage());
try {
try {
- throw new ControlLoopException(Status.BAD_GATEWAY, "An Exception");
- } catch (ControlLoopException cle) {
- throw new ControlLoopRuntimeException(cle);
+ throw new AutomationCompositionException(Status.BAD_GATEWAY, "An Exception");
+ } catch (AutomationCompositionException ace) {
+ throw new AutomationCompositionRuntimeException(ace);
}
- } catch (ControlLoopRuntimeException clred) {
- assertEquals(Status.BAD_GATEWAY, clred.getErrorResponse().getResponseCode());
- assertEquals("An Exception", clred.getMessage());
- assertEquals(ControlLoopException.class.getName(), clred.getCause().getClass().getName());
+ } catch (AutomationCompositionRuntimeException acred) {
+ assertEquals(Status.BAD_GATEWAY, acred.getErrorResponse().getResponseCode());
+ assertEquals("An Exception", acred.getMessage());
+ assertEquals(AutomationCompositionException.class.getName(), acred.getCause().getClass().getName());
}
assertThat(ae.toString()).contains("A String");
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java
index 58015ae3d..5c5bf3fbb 100644
--- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMessageConverterTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMessageConverterTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.common.rest;
+package org.onap.policy.clamp.common.acm.rest;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -28,8 +28,8 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
-import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
+import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException;
+import org.onap.policy.clamp.common.acm.startstop.CommonCommandLineArguments;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
@@ -37,7 +37,7 @@ class CoderHttpMessageConverterTest {
@Test
- void coderHttpMesageConverterTest() throws ControlLoopRuntimeException, IOException {
+ void coderHttpMesageConverterTest() throws AutomationCompositionRuntimeException, IOException {
var y = new CoderHttpMesageConverter<>("yaml");
var j = new CoderHttpMesageConverter<>("json");
@@ -46,14 +46,14 @@ class CoderHttpMessageConverterTest {
var testInputStream = new ByteArrayInputStream("testdata".getBytes());
HttpInputMessage input = Mockito.mock(HttpInputMessage.class);
Mockito.when(input.getBody()).thenReturn(testInputStream);
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
y.readInternal(RequestResponseLoggingFilterTest.class, input);
});
var testOutputStream = new ByteArrayOutputStream();
HttpOutputMessage output = Mockito.mock(HttpOutputMessage.class);
Mockito.when(output.getBody()).thenReturn(testOutputStream);
- assertThrows(ControlLoopRuntimeException.class, () -> {
+ assertThrows(AutomationCompositionRuntimeException.class, () -> {
j.writeInternal(String.class, output);
});
}
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java
index 7621c9219..ff6e1cd34 100644
--- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilterTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilterTest.java
@@ -20,7 +20,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.common.rest;
+package org.onap.policy.clamp.common.acm.rest;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java b/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java
index 8eff21248..93b500df0 100644
--- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArgumentsTest.java
+++ b/common/src/test/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArgumentsTest.java
@@ -18,7 +18,7 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.policy.clamp.controlloop.common.startstop;
+package org.onap.policy.clamp.common.acm.startstop;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
diff --git a/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java b/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java
deleted file mode 100644
index 52e86cf61..000000000
--- a/common/src/test/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtilsTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021 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=========================================================
- */
-
-package org.onap.policy.clamp.controlloop.common.utils;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUtils;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaDataType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyType;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate;
-
-class CommonUtilsTest {
-
- private ToscaConceptIdentifier id = new ToscaConceptIdentifier("id", "1.0.0");
- private ToscaConceptIdentifier idNode = new ToscaConceptIdentifier(
- "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", "0.0.0");
-
- @Test
- void testCommonUtilsParticipantUpdate() {
- var clElement = new ControlLoopElement();
- List<ParticipantUpdates> participantUpdates = new ArrayList<>();
- assertThat(participantUpdates).isEmpty();
-
- CommonUtils.prepareParticipantUpdate(clElement, participantUpdates);
- assertThat(participantUpdates).isNotEmpty();
- assertEquals(clElement, participantUpdates.get(0).getControlLoopElementList().get(0));
-
- CommonUtils.prepareParticipantUpdate(clElement, participantUpdates);
- assertNotEquals(id, participantUpdates.get(0).getParticipantId());
-
- clElement.setParticipantId(id);
- clElement.setParticipantType(id);
- CommonUtils.prepareParticipantUpdate(clElement, participantUpdates);
- assertEquals(id, participantUpdates.get(1).getParticipantId());
- }
-
- @Test
- void testCommonUtilsServiceTemplate() {
- var clElement = new ControlLoopElement();
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- CommonUtils.setServiceTemplatePolicyInfo(clElement, toscaServiceTemplate);
- assertEquals(getDummyToscaDataTypeMap(), clElement.getToscaServiceTemplateFragment().getDataTypes());
- }
-
- @Test
- void testCommonUtilsDefinitionUpdate() {
- var toscaServiceTemplate = getDummyToscaServiceTemplate();
- List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
- assertThat(participantDefinitionUpdates).isEmpty();
-
- checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
- assertThat(participantDefinitionUpdates).isNotEmpty();
- assertEquals(id, participantDefinitionUpdates.get(0).getParticipantType());
-
- checkParticipantDefinitionUpdate(toscaServiceTemplate, participantDefinitionUpdates);
- assertEquals(idNode, participantDefinitionUpdates.get(0)
- .getControlLoopElementDefinitionList().get(0)
- .getClElementDefinitionId());
- }
-
- private ToscaServiceTemplate getDummyToscaServiceTemplate() {
- var toscaServiceTemplate = new ToscaServiceTemplate();
- var policyTypes = getDummyPolicyTypesMap();
- toscaServiceTemplate.setPolicyTypes(policyTypes);
-
- var dataTypes = getDummyToscaDataTypeMap();
- dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType());
- toscaServiceTemplate.setDataTypes(dataTypes);
-
- var toscaTopologyTemplate = new ToscaTopologyTemplate();
- Map<String, ToscaPolicy> policy = new HashMap<>();
- toscaTopologyTemplate.setPolicies(List.of(policy));
- var nodeTemplates = getDummyNodeTemplates();
- toscaTopologyTemplate.setNodeTemplates(nodeTemplates);
-
- toscaServiceTemplate.setToscaTopologyTemplate(toscaTopologyTemplate);
- toscaServiceTemplate.setDerivedFrom("tosca.nodetypes.Root");
- toscaServiceTemplate.setDescription("description");
- toscaServiceTemplate.setMetadata(null);
- toscaServiceTemplate.setName("name");
- toscaServiceTemplate.setToscaDefinitionsVersion("1.0.0");
- toscaServiceTemplate.setVersion("1.0.1");
- return toscaServiceTemplate;
- }
-
- private Map<String, ToscaPolicyType> getDummyPolicyTypesMap() {
- Map<String, ToscaPolicyType> policyTypes = new HashMap<>();
- policyTypes.put("onap.policies.Match", new ToscaPolicyType());
- return policyTypes;
- }
-
- private Map<String, ToscaDataType> getDummyToscaDataTypeMap() {
- Map<String, ToscaDataType> dataTypes = new HashMap<>();
- dataTypes.put("onap.datatypes.ToscaConceptIdentifier", new ToscaDataType());
- return dataTypes;
- }
-
- private Map<String, ToscaNodeTemplate> getDummyNodeTemplates() {
- Map<String, ToscaNodeTemplate> nodeTemplates = new HashMap<>();
- var nodeTemplate = new ToscaNodeTemplate();
- nodeTemplate.setType("org.onap.policy.clamp.controlloop.ControlLoopElement");
- nodeTemplates.put("org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant", nodeTemplate);
- return nodeTemplates;
- }
-
- private void checkParticipantDefinitionUpdate(
- ToscaServiceTemplate toscaServiceTemplate,
- List<ParticipantDefinition> participantDefinitionUpdates) {
-
- for (Map.Entry<String, ToscaNodeTemplate> toscaInputEntry : toscaServiceTemplate.getToscaTopologyTemplate()
- .getNodeTemplates().entrySet()) {
- if (ParticipantUtils.checkIfNodeTemplateIsControlLoopElement(toscaInputEntry.getValue(),
- toscaServiceTemplate)) {
- CommonUtils.prepareParticipantDefinitionUpdate(id, toscaInputEntry.getKey(),
- toscaInputEntry.getValue(), participantDefinitionUpdates, null);
- }
- }
- }
-}