summaryrefslogtreecommitdiffstats
path: root/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java
diff options
context:
space:
mode:
authorwaqas.ikram <waqas.ikram@est.tech>2023-01-23 11:58:29 +0000
committerwaqas.ikram <waqas.ikram@est.tech>2023-01-23 11:58:40 +0000
commitbd591af78a4ab97af4f65d6b7094d9c60f7879c4 (patch)
treed16a23906298c6b1875712ab2acae64716531ff5 /so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java
parent80d8598e1013ddee747957adf7d96ec7fb901f0b (diff)
Adding common classes for workflows
Change-Id: Id86256ee21ee8c78da82ae3141f7936191593597 Issue-ID: SO-4068 Signed-off-by: waqas.ikram <waqas.ikram@est.tech>
Diffstat (limited to 'so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java')
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java83
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapterTest.java64
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/OffsetDateTimeTypeAdapterTest.java66
-rw-r--r--so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/PropertiesToYamlConverterTest.java45
4 files changed, 258 insertions, 0 deletions
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java
new file mode 100644
index 0000000..7de9bdc
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/extclients/sdc/SdcCsarPackageParserTest.java
@@ -0,0 +1,83 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.so.cnfm.lcm.bpmn.flows.extclients.sdc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.onap.so.cnfm.lcm.bpmn.flows.extclients.sdc.SdcCsarPropertiesConstants.APPLICATION_NAME_PARAM_NAME;
+import static org.onap.so.cnfm.lcm.bpmn.flows.extclients.sdc.SdcCsarPropertiesConstants.DESCRIPTOR_ID_PARAM_NAME;
+import static org.onap.so.cnfm.lcm.bpmn.flows.extclients.sdc.SdcCsarPropertiesConstants.DESCRIPTOR_INVARIANT_ID_PARAM_NAME;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class SdcCsarPackageParserTest {
+
+ private static final String RESOURCE_ASD_PACKAGE_CSAR_PATH =
+ "src/test/resources/resource-Generatedasdpackage-csar.csar";
+
+ @Test
+ public void testResourceAsdCsar() throws IOException {
+ final SdcCsarPackageParser objUnderTest = new SdcCsarPackageParser();
+
+ final byte[] content = getFileContent(Paths.get(getAbsolutePath(RESOURCE_ASD_PACKAGE_CSAR_PATH)));
+
+ final Map<String, Object> properties = objUnderTest.getAsdProperties(content);
+ assertEquals("123e4567-e89b-12d3-a456-426614174000", properties.get(DESCRIPTOR_ID_PARAM_NAME));
+ assertEquals("123e4yyy-e89b-12d3-a456-426614174abc", properties.get(DESCRIPTOR_INVARIANT_ID_PARAM_NAME));
+ assertEquals("SampleApp", properties.get(APPLICATION_NAME_PARAM_NAME));
+ assertEquals("2.3", properties.get(SdcCsarPropertiesConstants.APPLICATION_VERSION_PARAM_NAME));
+ assertEquals("MyCompany", properties.get(SdcCsarPropertiesConstants.PROVIDER_PARAM_NAME));
+
+ @SuppressWarnings("unchecked")
+ final List<DeploymentItem> items =
+ (List<DeploymentItem>) properties.get(SdcCsarPropertiesConstants.DEPLOYMENT_ITEMS_PARAM_NAME);
+ assertNotNull(items);
+ assertTrue(items.size() == 2);
+
+ DeploymentItem deploymentItem = items.get(0);
+ assertEquals("sampleapp-db", deploymentItem.getName());
+ assertEquals("1", deploymentItem.getItemId());
+ assertEquals("1", deploymentItem.getDeploymentOrder());
+ assertEquals("Artifacts/Deployment/HELM/sampleapp-db-operator-helm.tgz", deploymentItem.getFile());
+
+
+ }
+
+ private String getAbsolutePath(final String path) {
+ final File file = new File(path);
+ return file.getAbsolutePath();
+ }
+
+ private byte[] getFileContent(final Path path) throws IOException {
+ return Files.readAllBytes(path);
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapterTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapterTest.java
new file mode 100644
index 0000000..3015d87
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/LocalDateTimeTypeAdapterTest.java
@@ -0,0 +1,64 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.so.cnfm.lcm.bpmn.flows.utils;
+
+import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.time.LocalDateTime;
+import org.junit.Test;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class LocalDateTimeTypeAdapterTest {
+ private static final LocalDateTime LOCAL_DATETIME_VALUE = LocalDateTime.of(2023, 1, 1, 12, 0, 15);
+ private static final String STRING_VALUE = "\"2023-01-01 12:00:15\"";
+
+ @Test
+ public void testReadWithValidLocalDateTimeString() throws IOException {
+ final LocalDateTimeTypeAdapter objUnderTest = new LocalDateTimeTypeAdapter();
+
+ final Reader reader = new StringReader(STRING_VALUE);
+ final JsonReader jsonReader = new JsonReader(reader);
+
+ final LocalDateTime actual = objUnderTest.read(jsonReader);
+ assertEquals(LOCAL_DATETIME_VALUE, actual);
+
+ }
+
+ @Test
+ public void testWritedWithValidLocalDateTime() throws IOException {
+ final LocalDateTimeTypeAdapter objUnderTest = new LocalDateTimeTypeAdapter();
+
+ final StringWriter writer = new StringWriter();
+ final JsonWriter jsonWriter = new JsonWriter(writer);
+
+ objUnderTest.write(jsonWriter, LOCAL_DATETIME_VALUE);
+ assertEquals(STRING_VALUE, writer.toString());
+
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/OffsetDateTimeTypeAdapterTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/OffsetDateTimeTypeAdapterTest.java
new file mode 100644
index 0000000..0adbef0
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/OffsetDateTimeTypeAdapterTest.java
@@ -0,0 +1,66 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.so.cnfm.lcm.bpmn.flows.utils;
+
+import static org.junit.Assert.assertEquals;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+import org.junit.Test;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class OffsetDateTimeTypeAdapterTest {
+ private static final OffsetDateTime OFF_SET_DATETIME_VALUE =
+ OffsetDateTime.of(2023, 1, 1, 12, 00, 15, 0, ZoneOffset.UTC);
+ private static final String STRING_VALUE = "\"2023-01-01T12:00:15Z\"";
+
+ @Test
+ public void testReadWithValidOffsetDateTimeString() throws IOException {
+ final OffsetDateTimeTypeAdapter objUnderTest = new OffsetDateTimeTypeAdapter();
+
+ final Reader reader = new StringReader(STRING_VALUE);
+ final JsonReader jsonReader = new JsonReader(reader);
+
+ final OffsetDateTime actual = objUnderTest.read(jsonReader);
+ assertEquals(OFF_SET_DATETIME_VALUE, actual);
+
+ }
+
+ @Test
+ public void testWritedWithValidOffsetDateTime() throws IOException {
+ final OffsetDateTimeTypeAdapter objUnderTest = new OffsetDateTimeTypeAdapter();
+
+ final StringWriter writer = new StringWriter();
+ final JsonWriter jsonWriter = new JsonWriter(writer);
+
+ objUnderTest.write(jsonWriter, OFF_SET_DATETIME_VALUE);
+ assertEquals(STRING_VALUE, writer.toString());
+
+ }
+}
diff --git a/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/PropertiesToYamlConverterTest.java b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/PropertiesToYamlConverterTest.java
new file mode 100644
index 0000000..2410d73
--- /dev/null
+++ b/so-cnfm/so-cnfm-lcm/so-cnfm-lcm-bpmn-flows/src/test/java/org/onap/so/cnfm/lcm/bpmn/flows/utils/PropertiesToYamlConverterTest.java
@@ -0,0 +1,45 @@
+/*-
+ * ============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=========================================================
+ */
+package org.onap.so.cnfm.lcm.bpmn.flows.utils;
+
+import static org.junit.Assert.assertEquals;
+import java.util.Map;
+import org.junit.Test;
+
+/**
+ *
+ * @author Waqas Ikram (waqas.ikram@est.tech)
+ *
+ */
+public class PropertiesToYamlConverterTest {
+
+ @Test
+ public void testGetValuesYamlFileContent() {
+ final String expected = "primary:\n" + " service:\n" + " nodePorts:\n" + " mysql: '1234'\n"
+ + " ports:\n" + " mysql: dummy\n";
+ final PropertiesToYamlConverter objUnderTest = new PropertiesToYamlConverter();
+ final Map<String, String> lifeCycleParams =
+ Map.of("primary.service.ports.mysql", "dummy", "primary.service.nodePorts.mysql", "1234");
+ final String actual = objUnderTest.getValuesYamlFileContent(lifeCycleParams);
+
+ assertEquals(expected, actual);
+
+ }
+}