From 38c6faa738abe6e0acdd24df2364d725d36fca40 Mon Sep 17 00:00:00 2001 From: "andre.schmid" Date: Tue, 31 Aug 2021 10:04:26 +0100 Subject: Fix additional types import file generation The additional_type_definitions.yaml is missing types entries and header. Also, the solution is not considering the types entries, i.e. 'data_types:', 'policy_types:', etc., when replacing types and generating the new file, which renders the solution broken. This change aims to fix the related problems. Change-Id: I412683b49966c09dd067ecbf8a1d778155b23fa6 Issue-ID: SDC-3703 Signed-off-by: andre.schmid --- .../be/dao/cassandra/ToscaModelImportCassandraDao.java | 17 +++++++++++++++-- .../dao/cassandra/ToscaModelImportCassandraDaoTest.java | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'catalog-dao') diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDao.java index 5d1501c0b5..c250aecdef 100644 --- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDao.java +++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDao.java @@ -84,7 +84,14 @@ public class ToscaModelImportCassandraDao extends CassandraDao { LOGGER.info("{} successfully initialized", ToscaModelImportCassandraDao.class.getName()); } - public void importAll(final String modelId, final List toscaImportByModelList) { + /** + * Completely replaces the previous model imports by the imports on the given list that are from the same model. + * New imports will be added, existing will be replaced and the remaining will be deleted. + * + * @param modelId the model id + * @param toscaImportByModelList the new list of imports + */ + public void replaceImports(final String modelId, final List toscaImportByModelList) { final List importOfModelList = toscaImportByModelList.stream() .filter(toscaImportByModel -> modelId.equals(toscaImportByModel.getModelId())) .collect(Collectors.toList()); @@ -99,7 +106,13 @@ public class ToscaModelImportCassandraDao extends CassandraDao { ); } - public void importOnly(final String modelId, final List toscaImportByModelList) { + /** + * Saves all imports provided on the list that are from the given modelId. + * + * @param modelId the model id + * @param toscaImportByModelList the list of imports to save + */ + public void saveAll(final String modelId, final List toscaImportByModelList) { toscaImportByModelList.stream() .filter(toscaImportByModel -> modelId.equals(toscaImportByModel.getModelId())) .forEach(toscaImportByModelMapper::save); diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDaoTest.java index cddf3a2708..a43e153f7b 100644 --- a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDaoTest.java +++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/ToscaModelImportCassandraDaoTest.java @@ -95,7 +95,7 @@ class ToscaModelImportCassandraDaoTest { when(findAllByModelResult.all()).thenReturn(List.of(toscaImportByModel1, toscaImportByModelDatabase1)); when(toscaImportByModelAccessorMock.findAllByModel(modelId)).thenReturn(findAllByModelResult); - toscaModelImportCassandraDao.importAll(modelId, importModelList); + toscaModelImportCassandraDao.replaceImports(modelId, importModelList); verify(toscaImportByModelMapperMock).save(toscaImportByModel1); verify(toscaImportByModelMapperMock).save(toscaImportByModel2); -- cgit 1.2.3-korg