summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java97
1 files changed, 68 insertions, 29 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
index ee40b0bdab..d03ebb205d 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java
@@ -16,20 +16,6 @@
package org.openecomp.sdc.be.components.impl;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyBoolean;
-import static org.mockito.ArgumentMatchers.anyMap;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.when;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import fj.data.Either;
import org.junit.Assert;
import org.junit.Before;
@@ -39,13 +25,15 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
+import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.utils.ResourceBuilder;
import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
import org.openecomp.sdc.be.components.validation.UserValidations;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.cassandra.ArtifactCassandraDao;
import org.openecomp.sdc.be.dao.cassandra.CassandraOperationStatus;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -66,6 +54,20 @@ import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.exception.ResponseFormat;
import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.Assert.fail;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyMap;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
public class InterfaceOperationBusinessLogicTest {
@@ -117,7 +119,6 @@ public class InterfaceOperationBusinessLogicTest {
resource.setInputs(createInputsForResource());
user = new User();
- when(userValidations.validateUserExists(eq(user.getUserId()), anyString(), eq(true))).thenReturn(user);
when(toscaOperationFacade.getToscaElement(resourceId)).thenReturn(Either.left(resource));
when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
.thenReturn(StorageOperationStatus.OK);
@@ -373,6 +374,54 @@ public class InterfaceOperationBusinessLogicTest {
}
@Test
+ public void shouldFailOnDeleteInterfaceWhenLockComponentFailedTest() {
+ when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
+ .thenReturn(StorageOperationStatus.NOT_FOUND);
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, ComponentTypeEnum.RESOURCE)).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+ try{
+ interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
+ Collections.singletonList(operationId), user, true);
+ } catch (ByActionStatusComponentException e){
+ Assert.assertEquals(ActionStatus.RESOURCE_NOT_FOUND, e.getActionStatus());
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ public void shouldFailOnGetInterfaceWhenLockComponentFailedTest() {
+ when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
+ .thenReturn(StorageOperationStatus.NOT_FOUND);
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, ComponentTypeEnum.RESOURCE)).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+ try{
+ interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
+ Collections.singletonList(operationId), user, true);
+ } catch (ByActionStatusComponentException e){
+ Assert.assertEquals(ActionStatus.RESOURCE_NOT_FOUND, e.getActionStatus());
+ return;
+ }
+ fail();
+ }
+
+ @Test
+ public void shouldFailOnCreateInterfaceWhenLockComponentFailedTest() {
+ when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
+ .thenReturn(StorageOperationStatus.NOT_FOUND);
+ when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND, ComponentTypeEnum.RESOURCE)).thenReturn(ActionStatus.RESOURCE_NOT_FOUND);
+ try{
+ interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
+ Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
+ user, true);
+ } catch (ByActionStatusComponentException e){
+ Assert.assertEquals(ActionStatus.RESOURCE_NOT_FOUND, e.getActionStatus());
+ return;
+ }
+ fail();
+
+ }
+
+
+ @Test
public void deleteInterfaceOperationTestFailOnArtifactDeletion() {
when(artifactToscaOperation.getArtifactById(any(), any())).thenReturn(Either.left(new ArtifactDefinition()));
when(artifactToscaOperation.removeArifactFromResource(any(), any(), any(), anyBoolean()))
@@ -443,19 +492,6 @@ public class InterfaceOperationBusinessLogicTest {
}
@Test
- public void shouldFailWhenLockComponentFailedTest() {
- when(graphLockOperation.lockComponent(Mockito.anyString(), eq(NodeTypeEnum.Resource)))
- .thenReturn(StorageOperationStatus.NOT_FOUND);
- Assert.assertTrue(interfaceOperationBusinessLogic.deleteInterfaceOperation(resourceId, interfaceId,
- Collections.singletonList(operationId), user, true).isRight());
- Assert.assertTrue(interfaceOperationBusinessLogic.getInterfaceOperation(resourceId, interfaceId,
- Collections.singletonList(operationId), user, true).isRight());
- Assert.assertTrue(interfaceOperationBusinessLogic.createInterfaceOperation(resourceId,
- Collections.singletonList(InterfaceOperationTestUtils.createMockInterface(interfaceId, operationId, operationName)),
- user, true).isRight());
- }
-
- @Test
public void shouldFailWhenGetComponentFailedTest() {
when(toscaOperationFacade.getToscaElement(resourceId))
.thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
@@ -490,4 +526,7 @@ public class InterfaceOperationBusinessLogicTest {
interfaceOperationBusinessLogic.getAllInterfaceLifecycleTypes();
Assert.assertEquals(1, response.left().value().size());
}
+
+
+
} \ No newline at end of file