diff options
author | KrupaNagabhushan <krupa.nagabhushan@est.tech> | 2021-08-04 08:50:25 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2021-08-17 19:55:03 +0000 |
commit | cb872d0f9bf02546955cb713a8fbe7520f6d16d3 (patch) | |
tree | 992ce40fa74dcbc5e20662649df3f8881155a1a0 /catalog-be/src/test/java | |
parent | 6e75dd1bfd8c1a4625c9c61a60883d28ca88fff7 (diff) |
Validate model exists when associating types
Issue-ID: SDC-3665
Signed-off-by: KrupaNagabhushan <krupa.nagabhushan@est.tech>
Change-Id: I44de1c5bbd8854d02ae512f65833507aa3cbed6d
Diffstat (limited to 'catalog-be/src/test/java')
4 files changed, 18 insertions, 3 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java index a684e21ce1..f8b1800951 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/CapabilityTypeImportManagerTest.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.be.components.impl; import fj.data.Either; +import java.util.Optional; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.BeforeClass; @@ -32,8 +33,10 @@ import org.mockito.stubbing.Answer; import org.openecomp.sdc.be.dao.janusgraph.JanusGraphGenericDao; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.CapabilityTypeDefinition; +import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.CapabilityTypeOperation; +import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.common.util.CapabilityTypeNameEnum; import org.openecomp.sdc.exception.ResponseFormat; @@ -57,7 +60,8 @@ public class CapabilityTypeImportManagerTest { private static final JanusGraphGenericDao JANUS_GRAPH_GENERIC_DAO = mock(JanusGraphGenericDao.class); private static final PropertyOperation propertyOperation = mock(PropertyOperation.class); private CommonImportManager commonImportManager = new CommonImportManager(componentsUtils, propertyOperation); - private CapabilityTypeImportManager manager = new CapabilityTypeImportManager(capabilityTypeOperation, commonImportManager); + private ModelOperation modelOperation = mock(ModelOperation.class); + private CapabilityTypeImportManager manager = new CapabilityTypeImportManager(capabilityTypeOperation, commonImportManager, modelOperation); @BeforeClass public static void beforeClass() { @@ -81,6 +85,7 @@ public class CapabilityTypeImportManagerTest { @Test public void testCreateCapabilityTypes() throws IOException { String ymlContent = getCapabilityTypesYml(); + when(modelOperation.findModelByName("testModel")).thenReturn(Optional.of(new Model("testModel"))); Either<List<ImmutablePair<CapabilityTypeDefinition, Boolean>>, ResponseFormat> createCapabilityTypes = manager.createCapabilityTypes(ymlContent, "testModel"); assertTrue(createCapabilityTypes.isLeft()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManagerTest.java index 33cd971c14..a6ee23b392 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManagerTest.java @@ -28,6 +28,7 @@ import org.openecomp.sdc.be.components.impl.model.ToscaTypeImportData; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation; +import org.openecomp.sdc.be.model.operations.impl.ModelOperation; @RunWith(MockitoJUnitRunner.class) public class GroupTypeImportManagerTest { @@ -41,12 +42,14 @@ public class GroupTypeImportManagerTest { @Mock CommonImportManager commonImportManager; @Mock + ModelOperation modelOperation; + @Mock private ToscaTypeImportData data; @Test public void shouldInvokeCreateElementTypes() { GroupTypeImportManager groupTypeImportManager = new GroupTypeImportManager(groupTypeOperation, componentsUtils, - toscaOperationFacade, commonImportManager); + toscaOperationFacade, commonImportManager, modelOperation); groupTypeImportManager.createGroupTypes(data, null); Mockito.verify(commonImportManager).createElementTypes(Mockito.any(ToscaTypeImportData.class), Mockito.any(), Mockito.any(), Mockito.any()); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java index 9cd18bc9a2..0595a4c24d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceLifecycleTypeImportManagerTest.java @@ -35,8 +35,10 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.InterfaceDefinition; +import org.openecomp.sdc.be.model.Model; import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.exception.ResponseFormat; import java.io.IOException; @@ -61,6 +63,7 @@ public class InterfaceLifecycleTypeImportManagerTest { public static final CommonImportManager commonImportManager = Mockito.mock(CommonImportManager.class); public static final IInterfaceLifecycleOperation interfaceLifecycleOperation = Mockito.mock(IInterfaceLifecycleOperation.class); public static final ComponentsUtils componentsUtils = Mockito.mock(ComponentsUtils.class); + public static final ModelOperation modelOperation = Mockito.mock(ModelOperation.class); @BeforeClass public static void beforeClass() throws IOException { @@ -83,6 +86,7 @@ public class InterfaceLifecycleTypeImportManagerTest { @Test public void createLifecycleTypesTest() throws IOException { final String ymlContent = getYmlContent(); + when(modelOperation.findModelByName("test")).thenReturn(Optional.of(new Model("test"))); final Either<List<InterfaceDefinition>, ResponseFormat> createCapabilityTypes = importManager.createLifecycleTypes(ymlContent, "test"); assertTrue(createCapabilityTypes.isLeft()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManagerTest.java index 3495159153..06be58d584 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManagerTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManagerTest.java @@ -25,6 +25,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.openecomp.sdc.be.impl.ComponentsUtils; +import org.openecomp.sdc.be.model.operations.impl.ModelOperation; import org.openecomp.sdc.be.model.operations.impl.RelationshipTypeOperation; @RunWith(MockitoJUnitRunner.class) @@ -36,11 +37,13 @@ public class RelationshipTypeImportManagerTest { private CommonImportManager commonImportManager; @Mock private ComponentsUtils componentsUtils; + @Mock + private ModelOperation modelOperation; @Test public void shouldInvokeCreateElementTypes() { RelationshipTypeImportManager relationshipTypeImportManager = - new RelationshipTypeImportManager(relationshipTypeOperation, commonImportManager, componentsUtils); + new RelationshipTypeImportManager(relationshipTypeOperation, commonImportManager, componentsUtils, modelOperation); relationshipTypeImportManager.createRelationshipTypes("anyYaml", "anyModel"); Mockito.verify(commonImportManager).createElementTypes((String) Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any()); |