summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2022-08-19 09:36:41 +0100
committerVasyl Razinkov <vasyl.razinkov@est.tech>2022-09-02 10:22:01 +0000
commit97b5fa431d5924d90e97adedf76f3ce5648cd938 (patch)
tree40b200066f88dff83ae7773d30d2b37b42594d0d /catalog-model/src/test
parent7e84536e49b49cd1721b324d1ccaa17ca96456a7 (diff)
Support updated data types in service import
Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-4140 Change-Id: Ib66d47a0f566b648722ce86cfc4e208880551a29
Diffstat (limited to 'catalog-model/src/test')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java24
-rw-r--r--catalog-model/src/test/resources/modelOperation/expected-additional_types-1.yaml3
-rw-r--r--catalog-model/src/test/resources/modelOperation/expected-additional_types-2-updated.yaml24
-rw-r--r--catalog-model/src/test/resources/modelOperation/expected-additional_types-2.yaml3
-rw-r--r--catalog-model/src/test/resources/modelOperation/input-data_types-updated.yaml12
-rw-r--r--catalog-model/src/test/resources/modelOperation/input-data_types.yaml3
6 files changed, 68 insertions, 1 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
index 42f52982a8..acff2a3aa2 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java
@@ -31,6 +31,7 @@ import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.openecomp.sdc.be.model.operations.impl.ModelOperation.ADDITIONAL_TYPE_DEFINITIONS_PATH;
@@ -503,7 +504,28 @@ class ModelOperationTest extends ModelTestBase {
final ToscaImportByModel actualImport1 = actualImportList.stream().filter(expectedImport1::equals).findFirst().orElse(null);
assertNotNull(actualImport1);
assertEquals(expectedImport1.getContent(), actualImport1.getContent());
-
+
+ // Update the added additional type
+ final var updatedDataTypesPath = testResourcePath.resolve(Path.of("input-data_types-updated.yaml"));
+ final var updatedDataTypes = Files.readString(updatedDataTypesPath);
+ modelOperation.updateTypesInAdditionalTypesImport(ElementTypeEnum.DATA_TYPE, updatedDataTypes, modelName);
+
+ ArgumentCaptor<List<ToscaImportByModel>> updatedImportListArgumentCaptor = ArgumentCaptor.forClass(List.class);
+ verify(toscaModelImportCassandraDao, times(2)).saveAll(eq(modelName), updatedImportListArgumentCaptor.capture());
+
+ final List<ToscaImportByModel> updatedActualImportList = updatedImportListArgumentCaptor.getValue();
+ assertEquals(2, updatedActualImportList.size());
+
+ var expectedUpdatedAdditionalTypesImport = new ToscaImportByModel();
+ expectedUpdatedAdditionalTypesImport.setModelId(modelName);
+ expectedUpdatedAdditionalTypesImport.setFullPath(ADDITIONAL_TYPE_DEFINITIONS_PATH.toString());
+ expectedUpdatedAdditionalTypesImport.setContent(Files.readString(testResourcePath.resolve(Path.of("expected-additional_types-2-updated.yaml"))));
+ final ToscaImportByModel actualUpdatedAdditionalTypesImport =
+ actualImportList.stream().filter(expectedUpdatedAdditionalTypesImport::equals).findFirst().orElse(null);
+ assertNotNull(actualUpdatedAdditionalTypesImport);
+
+ assertTrue(actualUpdatedAdditionalTypesImport.getContent().contains("added_property_1"));
+ assertTrue(actualUpdatedAdditionalTypesImport.getContent().contains("added_property_2"));
}
@Test
diff --git a/catalog-model/src/test/resources/modelOperation/expected-additional_types-1.yaml b/catalog-model/src/test/resources/modelOperation/expected-additional_types-1.yaml
index c9e6741993..50d9babb60 100644
--- a/catalog-model/src/test/resources/modelOperation/expected-additional_types-1.yaml
+++ b/catalog-model/src/test/resources/modelOperation/expected-additional_types-1.yaml
@@ -5,6 +5,9 @@ data_types:
tosca.datatypes.nfv.ServiceAvailability:
derived_from: tosca.datatypes.Root
description: additional type
+ properties:
+ added_property_1:
+ type: string
tosca.datatypes.nfv.L2AddressData:
derived_from: tosca.datatypes.Root
description: additional type
diff --git a/catalog-model/src/test/resources/modelOperation/expected-additional_types-2-updated.yaml b/catalog-model/src/test/resources/modelOperation/expected-additional_types-2-updated.yaml
new file mode 100644
index 0000000000..ad3d0bfdd8
--- /dev/null
+++ b/catalog-model/src/test/resources/modelOperation/expected-additional_types-2-updated.yaml
@@ -0,0 +1,24 @@
+tosca_definitions_version: tosca_simple_yaml_1_3
+description: Auto-generated file that contains package custom types or types added
+ after system installation.
+data_types:
+ tosca.datatypes.nfv.PreviouslyExistingType1:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+ tosca.datatypes.nfv.PreviouslyExistingType2:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+ tosca.datatypes.nfv.ServiceAvailability:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+ properties:
+ added_property_1:
+ type: string
+ added_property_2:
+ type: string
+ tosca.datatypes.nfv.L2AddressData:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+ tosca.datatypes.nfv.Unknown:
+ derived_from: tosca.datatypes.Root
+ description: additional type
diff --git a/catalog-model/src/test/resources/modelOperation/expected-additional_types-2.yaml b/catalog-model/src/test/resources/modelOperation/expected-additional_types-2.yaml
index 2d2c54206e..a36c828193 100644
--- a/catalog-model/src/test/resources/modelOperation/expected-additional_types-2.yaml
+++ b/catalog-model/src/test/resources/modelOperation/expected-additional_types-2.yaml
@@ -11,6 +11,9 @@ data_types:
tosca.datatypes.nfv.ServiceAvailability:
derived_from: tosca.datatypes.Root
description: additional type
+ properties:
+ added_property_1:
+ type: string
tosca.datatypes.nfv.L2AddressData:
derived_from: tosca.datatypes.Root
description: additional type
diff --git a/catalog-model/src/test/resources/modelOperation/input-data_types-updated.yaml b/catalog-model/src/test/resources/modelOperation/input-data_types-updated.yaml
new file mode 100644
index 0000000000..136585acb6
--- /dev/null
+++ b/catalog-model/src/test/resources/modelOperation/input-data_types-updated.yaml
@@ -0,0 +1,12 @@
+tosca.datatypes.nfv.ServiceAvailability:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+ properties:
+ added_property_2:
+ type: string
+tosca.datatypes.nfv.L2AddressData:
+ derived_from: tosca.datatypes.Root
+ description: additional type
+tosca.datatypes.nfv.Unknown:
+ derived_from: tosca.datatypes.Root
+ description: additional type \ No newline at end of file
diff --git a/catalog-model/src/test/resources/modelOperation/input-data_types.yaml b/catalog-model/src/test/resources/modelOperation/input-data_types.yaml
index 77b7d977b0..0754631071 100644
--- a/catalog-model/src/test/resources/modelOperation/input-data_types.yaml
+++ b/catalog-model/src/test/resources/modelOperation/input-data_types.yaml
@@ -1,6 +1,9 @@
tosca.datatypes.nfv.ServiceAvailability:
derived_from: tosca.datatypes.Root
description: additional type
+ properties:
+ added_property_1:
+ type: string
tosca.datatypes.nfv.L2AddressData:
derived_from: tosca.datatypes.Root
description: additional type