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/InterfaceOperationBusinessLogicTest.java44
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java72
2 files changed, 58 insertions, 58 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 b9e0b594ea..eb17d56154 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,7 +16,22 @@
package org.openecomp.sdc.be.components.impl;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyObject;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.servlet.ServletContext;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -25,7 +40,6 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.openecomp.sdc.ElementOperationMock;
import org.openecomp.sdc.be.auditing.impl.AuditingManager;
-import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.impl.generic.GenericTypeBusinessLogic;
import org.openecomp.sdc.be.components.validation.InterfaceOperationValidation;
import org.openecomp.sdc.be.components.validation.UserValidations;
@@ -40,10 +54,19 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.InputDefinition;
+import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
-import org.openecomp.sdc.be.model.jsontitan.operations.*;
-import org.openecomp.sdc.be.model.jsontitan.utils.InterfaceUtils;
+import org.openecomp.sdc.be.model.jsontitan.operations.InterfaceOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -55,16 +78,9 @@ import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
+import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.springframework.web.context.WebApplicationContext;
-import javax.servlet.ServletContext;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static org.mockito.ArgumentMatchers.*;
-import static org.mockito.Mockito.when;
-
public class InterfaceOperationBusinessLogicTest {
public static final String RESOURCE_CATEGORY1 = "Network Layer 2-3";
@@ -166,12 +182,11 @@ public class InterfaceOperationBusinessLogicTest {
when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
//InterfaceOperation
- when(operationValidator.validateInterfaceOperations(anyCollection(), anyString(), anyBoolean())).thenReturn(Either.left(true));
+ when(operationValidator.validateInterfaceOperations(anyCollection(), anyObject(), anyBoolean())).thenReturn(Either.left(true));
when(interfaceOperation.addInterface(anyString(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
when(interfaceOperation.updateInterface(anyString(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
when(interfaceOperation.addInterfaceOperation(anyObject(), anyObject(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockOperationToReturn(RESOURCE_NAME)));
when(interfaceOperation.updateInterfaceOperation(anyObject(), anyObject(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockOperationToReturn(RESOURCE_NAME)));
- when(interfaceOperation.getInterfaceOperation(anyObject(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockOperationToReturn(RESOURCE_NAME)));
when(interfaceOperation.deleteInterfaceOperation(anyObject(), anyObject(), anyObject())).thenReturn(Either.left(InterfaceOperationTestUtils.mockOperationToReturn(RESOURCE_NAME)));
when(interfaceOperation.deleteInterfaceOperation(any(),any(), any())).thenReturn(Either.left(InterfaceOperationTestUtils.mockOperationToReturn(RESOURCE_NAME)));
when(interfaceOperation.updateInterface(any(),any())).thenReturn(Either.left(InterfaceOperationTestUtils.mockInterfaceDefinitionToReturn(RESOURCE_NAME)));
@@ -185,7 +200,6 @@ public class InterfaceOperationBusinessLogicTest {
bl.setComponentsUtils(componentsUtils);
bl.setGraphLockOperation(graphLockOperation);
bl.setTitanGenericDao(mockTitanDao);
- bl.setGenericTypeBusinessLogic(genericTypeBusinessLogic);
toscaOperationFacade.setNodeTypeOperation(nodeTypeOperation);
toscaOperationFacade.setTopologyTemplateOperation(topologyTemplateOperation);
bl.setToscaOperationFacade(toscaOperationFacade);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
index 3d3447d88b..d41294b4c2 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/validation/InterfaceOperationValidationTest.java
@@ -16,57 +16,49 @@
package org.openecomp.sdc.be.components.validation;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.Sets;
import fj.data.Either;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
import org.openecomp.sdc.be.datatypes.elements.OperationOutputDefinition;
-import org.openecomp.sdc.be.model.*;
-import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
-import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
+import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.exception.ResponseFormat;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.when;
+import org.openecomp.sdc.test.utils.InterfaceOperationTestUtils;
public class InterfaceOperationValidationTest {
- private Resource resource = (Resource) getToscaFullElement().left().value();
-
- ResponseFormatManager mock;
- @Mock
- ToscaOperationFacade toscaOperationFacade;
+ private Resource resource = setUpResourceMock();
+ ResponseFormatManager responseFormatManagerMock;
- @InjectMocks
InterfaceOperationValidationUtilTest interfaceOperationValidationUtilTest = new InterfaceOperationValidationUtilTest();
- private static final String RESOURCE_ID = "resource1";
ListDataDefinition<OperationInputDefinition> operationInputDefinitionList = new ListDataDefinition<>();
ListDataDefinition<OperationOutputDefinition> operationOutputDefinitionList = new ListDataDefinition<>();
+
@Before
public void init() {
MockitoAnnotations.initMocks(this);
- mock = Mockito.mock(ResponseFormatManager.class);
- when(toscaOperationFacade.getToscaElement(any(), any(ComponentParametersView.class))).thenReturn(Either.left(resource));
- when(mock.getResponseFormat(any())).thenReturn(new ResponseFormat());
- when(mock.getResponseFormat(any(), any())).thenReturn(new ResponseFormat());
- when(mock.getResponseFormat(any(), any(), any())).thenReturn(new ResponseFormat());
+ responseFormatManagerMock = Mockito.mock(ResponseFormatManager.class);
+ when(responseFormatManagerMock.getResponseFormat(any())).thenReturn(new ResponseFormat());
+ when(responseFormatManagerMock.getResponseFormat(any(), any())).thenReturn(new ResponseFormat());
+ when(responseFormatManagerMock.getResponseFormat(any(), any(), any())).thenReturn(new ResponseFormat());
}
-
@Test
public void testValidInterfaceOperation() {
operationInputDefinitionList.add(InterfaceOperationTestUtils.createMockOperationInputDefinition("label1"));
@@ -75,7 +67,7 @@ public class InterfaceOperationValidationTest {
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"upgrade");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isLeft());
}
@@ -89,7 +81,7 @@ public class InterfaceOperationValidationTest {
"with web, data access (relational and NoSQL datastores), cloud, or messaging support",
new ArtifactDefinition(), operationInputDefinitionList, operationOutputDefinitionList,"update");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -103,7 +95,7 @@ public class InterfaceOperationValidationTest {
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList, "");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -115,7 +107,7 @@ public class InterfaceOperationValidationTest {
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"input2");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -127,7 +119,7 @@ public class InterfaceOperationValidationTest {
"interface operation2",new ArtifactDefinition(), operationInputDefinitionList,
operationOutputDefinitionList,"CREATE");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -142,7 +134,7 @@ public class InterfaceOperationValidationTest {
"productive with the certain technology stack from the beginning. You can create a skeleton project" +
"with web, data access (relational and NoSQL datastores), cloud, or messaging support");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -159,7 +151,7 @@ public class InterfaceOperationValidationTest {
operationOutputDefinitionList,"create");
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -174,7 +166,7 @@ public class InterfaceOperationValidationTest {
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isLeft());
}
@@ -189,7 +181,7 @@ public class InterfaceOperationValidationTest {
Either<Boolean, ResponseFormat> booleanResponseFormatEither = interfaceOperationValidationUtilTest
- .validateInterfaceOperations(operations, RESOURCE_ID, false);
+ .validateInterfaceOperations(operations, resource, false);
Assert.assertTrue(booleanResponseFormatEither.isRight());
}
@@ -199,15 +191,9 @@ public class InterfaceOperationValidationTest {
return Sets.newHashSet(InterfaceOperationTestUtils.createInterfaceOperation(uniqueID, description, artifactDefinition, inputs, outputs, name));
}
- private <T extends Component> Either<T, StorageOperationStatus> getToscaFullElement() {
-
- return Either.left((T) setUpResourceMock());
- }
-
private Resource setUpResourceMock(){
Resource resource = new Resource();
resource.setInterfaces(createMockInterfaceDefinition());
-
return resource;
}
@@ -223,7 +209,7 @@ public class InterfaceOperationValidationTest {
private class InterfaceOperationValidationUtilTest extends InterfaceOperationValidation {
protected ResponseFormatManager getResponseFormatManager() {
- return mock;
+ return responseFormatManagerMock;
}
}
}