summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/test/java
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/java
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/java')
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ModelOperationTest.java24
1 files changed, 23 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