summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManagerTest.java31
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/RelationshipTypeImportManagerTest.java30
2 files changed, 55 insertions, 6 deletions
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 c288fa82cd..35c9af8a60 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
@@ -19,17 +19,26 @@
*/
package org.openecomp.sdc.be.components.impl;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
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.normatives.ElementTypeEnum;
import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
+import fj.data.Either;
+
@RunWith(MockitoJUnitRunner.class)
public class GroupTypeImportManagerTest {
@@ -50,7 +59,23 @@ public class GroupTypeImportManagerTest {
public void shouldInvokeCreateElementTypes() {
GroupTypeImportManager groupTypeImportManager = new GroupTypeImportManager(groupTypeOperation, componentsUtils,
toscaOperationFacade, commonImportManager, modelOperation);
- groupTypeImportManager.createGroupTypes(data, null, false);
- Mockito.verify(commonImportManager).createElementTypes(Mockito.any(ToscaTypeImportData.class), Mockito.any(), Mockito.any(), Mockito.any());
+
+ when(commonImportManager.createElementTypes(any(ToscaTypeImportData.class), any(), any(), any())).thenReturn(Either.left(Collections.emptyList()));
+
+ groupTypeImportManager.createGroupTypes(data, "test model", true);
+ verify(commonImportManager).createElementTypes(any(ToscaTypeImportData.class), any(), any(), any());
+ verify(commonImportManager).addTypesToDefaultImports(any(ElementTypeEnum.class), any(), any());
+ }
+
+ @Test
+ public void shouldInvokeCreateElementTypes_Error() {
+ GroupTypeImportManager groupTypeImportManager = new GroupTypeImportManager(groupTypeOperation, componentsUtils,
+ toscaOperationFacade, commonImportManager, modelOperation);
+
+ when(commonImportManager.createElementTypes(any(ToscaTypeImportData.class), any(), any(), any())).thenReturn(Either.right(null));
+
+ groupTypeImportManager.createGroupTypes(data, "test model", true);
+ verify(commonImportManager).createElementTypes(any(ToscaTypeImportData.class), any(), any(), any());
+ verify(commonImportManager, never()).addTypesToDefaultImports(any(ElementTypeEnum.class), any(), any());
}
} \ No newline at end of file
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 5a8a704728..c3f0137bf6 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
@@ -19,15 +19,24 @@
*/
package org.openecomp.sdc.be.components.impl;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Collections;
+
import org.junit.Test;
import org.junit.runner.RunWith;
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.normatives.ElementTypeEnum;
import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
import org.openecomp.sdc.be.model.operations.impl.RelationshipTypeOperation;
+import fj.data.Either;
+
@RunWith(MockitoJUnitRunner.class)
public class RelationshipTypeImportManagerTest {
@@ -44,8 +53,23 @@ public class RelationshipTypeImportManagerTest {
public void shouldInvokeCreateElementTypes() {
RelationshipTypeImportManager relationshipTypeImportManager =
new RelationshipTypeImportManager(relationshipTypeOperation, commonImportManager, componentsUtils, modelOperation);
- relationshipTypeImportManager.createRelationshipTypes("anyYaml", "anyModel", false);
- Mockito.verify(commonImportManager).createElementTypes((String) Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
+
+ when(commonImportManager.createElementTypes((String) any(), any(), any(), any())).thenReturn(Either.left(Collections.emptyList()));
+
+ relationshipTypeImportManager.createRelationshipTypes("anyYaml", "anyModel", true);
+ verify(commonImportManager).createElementTypes((String) any(), any(), any(), any());
+ verify(commonImportManager).addTypesToDefaultImports(any(ElementTypeEnum.class), any(), any());
+ }
+
+ @Test
+ public void shouldInvokeCreateElementTypes_Error() {
+ RelationshipTypeImportManager relationshipTypeImportManager =
+ new RelationshipTypeImportManager(relationshipTypeOperation, commonImportManager, componentsUtils, modelOperation);
+
+ when(commonImportManager.createElementTypes((String) any(), any(), any(), any())).thenReturn(Either.right(null));
+ relationshipTypeImportManager.createRelationshipTypes("anyYaml", "anyModel", true);
+ verify(commonImportManager).createElementTypes((String) any(), any(), any(), any());
+ verify(commonImportManager, never()).addTypesToDefaultImports(any(ElementTypeEnum.class), any(), any());
}
} \ No newline at end of file