summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshrikantawachar <shrikant.awachar@amdocs.com>2018-12-17 12:26:43 +0530
committershrikantawachar <shrikant.awachar@amdocs.com>2018-12-19 15:08:44 +0530
commitb6e7850484ba61df259e38fd6b59e94c2a7de5b6 (patch)
treeb235bafe42063bea899602c54d8f437c26227c77
parente7cdba9c8a87f6dfd4823214ca64016e69b45a16 (diff)
API for get all interface lifecycle types
API for get all interface lifecycle types Change-Id: I64471c98ff9626ac53562a075a34f506c2e263ab Issue-ID: SDC-1999 Signed-off-by: shrikantawachar <shrikant.awachar@amdocs.com>
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java13
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java51
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml7
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogicTest.java23
-rw-r--r--catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java2
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java38
-rw-r--r--catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java (renamed from catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java)82
-rw-r--r--openecomp-bdd/config.json6
-rw-r--r--openecomp-bdd/features/GlobalTypes/TestInterfaceLifecycleTypes.feature8
-rw-r--r--openecomp-bdd/stepDefinitions/GlobalTypes.js24
12 files changed, 246 insertions, 21 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
index 453564e2f8..02e64334f9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/BaseBusinessLogic.java
@@ -45,6 +45,7 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.StorageException;
import org.openecomp.sdc.be.model.operations.api.*;
import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.impl.PolicyTypeOperation;
import org.openecomp.sdc.be.model.operations.impl.PropertyOperation;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
@@ -129,6 +130,9 @@ public abstract class BaseBusinessLogic {
@Autowired
protected InterfaceOperationBusinessLogic interfaceOperationBusinessLogic;
+ @Autowired
+ protected InterfaceLifecycleOperation interfaceLifecycleOperation;
+
@javax.annotation.Resource
private UserValidations userValidations;
@@ -171,6 +175,10 @@ public abstract class BaseBusinessLogic {
}
+ public void setInterfaceLifecycleOperation(InterfaceLifecycleOperation interfaceLifecycleOperation) {
+ this.interfaceLifecycleOperation = interfaceLifecycleOperation;
+ }
+
User validateUserNotEmpty(User user, String ecompErrorContext) {
return userValidations.validateUserNotEmpty(user, ecompErrorContext);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
index fed2cac518..a0efddbdda 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InterfaceOperationBusinessLogic.java
@@ -41,6 +41,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.UUID;
+import java.util.stream.Collectors;
@Component("interfaceOperationBusinessLogic")
public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
@@ -324,4 +325,16 @@ public class InterfaceOperationBusinessLogic extends BaseBusinessLogic {
}
return Either.left( interfaceDefinition);
}
+
+ public Either<Map<String, InterfaceDefinition>, ResponseFormat> getAllInterfaceLifecycleTypes() {
+
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> interfaceLifecycleTypes = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes();
+ if(interfaceLifecycleTypes.isRight()) {
+ return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_LIFECYCLE_TYPES_NOT_FOUND));
+ }
+ interfaceLifecycleTypes.left().value().values().stream().forEach(
+ id -> id.setOperations(id.getOperations().keySet().stream().collect(Collectors.toMap(key -> key.replaceFirst(id.getUniqueId()+".",""), i -> id.getOperations().get(i)))));
+
+ return Either.left(interfaceLifecycleTypes.left().value());
+ }
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
index 8bb93a7d3d..ddb405779d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java
@@ -26,11 +26,13 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
+import org.openecomp.sdc.be.components.impl.InterfaceOperationBusinessLogic;
import org.openecomp.sdc.be.components.impl.PropertyBusinessLogic;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.Wrapper;
@@ -109,4 +111,53 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
return webApplicationContext.getBean(PropertyBusinessLogic.class);
}
+ @GET
+ @Path("interfaceLifecycleTypes")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ @ApiOperation(value = "Get interface lifecycle types", httpMethod = "GET", notes = "Returns interface lifecycle types", response = Response.class)
+ @ApiResponses(value = {
+ @ApiResponse(code = 200, message = "Interface lifecycle types"),
+ @ApiResponse(code = 403, message = "Restricted operation"),
+ @ApiResponse(code = 400, message = "Invalid content / Missing content"),
+ @ApiResponse(code = 404, message = "Interface lifecycle types not found")
+ })
+ public Response getInterfaceLifecycleTypes(@Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+
+ Wrapper<Response> responseWrapper = new Wrapper<>();
+ Wrapper<User> userWrapper = new Wrapper<>();
+ ServletContext context = request.getSession().getServletContext();
+
+ try {
+ validateUserExist(responseWrapper, userWrapper, userId);
+
+ if (responseWrapper.isEmpty()) {
+ String url = request.getMethod() + " " + request.getRequestURI();
+ log.info("Start handle request of {} | modifier id is {}", url, userId);
+
+ InterfaceOperationBusinessLogic businessLogic = getInterfaceOperationBL(context);
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> allInterfaceLifecycleTypes =
+ businessLogic.getAllInterfaceLifecycleTypes();
+
+ if (allInterfaceLifecycleTypes.isRight()) {
+ log.info("Failed to get all interface lifecycle types. Reason - {}",
+ allInterfaceLifecycleTypes.right().value());
+ Response errorResponse = buildErrorResponse(allInterfaceLifecycleTypes.right().value());
+ responseWrapper.setInnerElement(errorResponse);
+
+ } else {
+ String interfaceLifecycleTypeJson = gson.toJson(allInterfaceLifecycleTypes.left().value());
+ Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), interfaceLifecycleTypeJson);
+ responseWrapper.setInnerElement(okResponse);
+
+ }
+ }
+
+ return responseWrapper.getInnerElement();
+ } catch (Exception e) {
+ log.debug("get all interface lifecycle types failed with exception", e);
+ ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
+ return buildErrorResponse(responseFormat);
+ }
+ }
}
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index aa000f14a7..84213bbe8d 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -2153,4 +2153,9 @@ errors:
message: "Error: Interface operation output parameter name should not be empty.",
messageId: "SVC4706"
}
-
+#---------SVC4712-----------------------------
+ INTERFACE_LIFECYCLE_TYPES_NOT_FOUND: {
+ code: 404,
+ message: "Error: Interface Lifecycle types not found.",
+ messageId: "SVC4712"
+ } \ No newline at end of file
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 4227e5d5cc..f2d8b57dbf 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
@@ -70,6 +70,7 @@ 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;
import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
+import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.common.api.ConfigurationSource;
@@ -106,6 +107,7 @@ public class InterfaceOperationBusinessLogicTest {
private final ArtifactCassandraDao artifactCassandraDao = Mockito.mock(ArtifactCassandraDao.class);
private final InterfaceOperation interfaceOperation = Mockito.mock(InterfaceOperation.class);
private final InterfaceOperationValidation operationValidator = Mockito.mock(InterfaceOperationValidation.class);
+ private InterfaceLifecycleOperation interfaceLifecycleOperation = Mockito.mock(InterfaceLifecycleOperation.class);
private final GraphLockOperation graphLockOperation = Mockito.mock(GraphLockOperation.class);
private User user = null;
@@ -192,6 +194,7 @@ public class InterfaceOperationBusinessLogicTest {
bl.setUserValidations(userValidations);
bl.setInterfaceOperation(interfaceOperation);
bl.setInterfaceOperationValidation(operationValidator);
+ bl.setInterfaceLifecycleOperation(interfaceLifecycleOperation);
Resource resourceCsar = createResourceObjectCsar(true);
setCanWorkOnResource(resourceCsar);
Either<Component, StorageOperationStatus> oldResourceRes = Either.left(resourceCsar);
@@ -423,6 +426,24 @@ public class InterfaceOperationBusinessLogicTest {
return resource;
}
+ @Test
+ public void testGetAllInterfaceLifecycleTypes_TypesNotFound() {
+ when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> response = bl.getAllInterfaceLifecycleTypes();
+ Assert.assertTrue(response.isRight());
+ }
-
+ @Test
+ public void testGetAllInterfaceLifecycleTypes_Success() {
+ final String UNIQUE_ID = "UNIQUE_ID";
+ final String TYPE = "UNIQUE_ID";
+ InterfaceDefinition interfaceDefinition = new InterfaceDefinition();
+ interfaceDefinition.setUniqueId(UNIQUE_ID);
+ interfaceDefinition.setType(TYPE);
+ Map<String, InterfaceDefinition> interfaceDefinitionMap = new HashMap<>();
+ interfaceDefinitionMap.put(interfaceDefinition.getUniqueId(), interfaceDefinition);
+ when(interfaceLifecycleOperation.getAllInterfaceLifecycleTypes()).thenReturn(Either.left(interfaceDefinitionMap));
+ Either<Map<String, InterfaceDefinition>, ResponseFormat> response = bl.getAllInterfaceLifecycleTypes();
+ Assert.assertEquals(response.left().value().size(),1);
+ }
} \ No newline at end of file
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
index e5caee5f01..fa96c45472 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/api/ActionStatus.java
@@ -121,6 +121,9 @@ public enum ActionStatus {
INTERFACE_OPERATION_NOT_FOUND, INTERFACE_OPERATION_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_NAME_MANDATORY, INTERFACE_OPERATION_NAME_INVALID,
INTERFACE_OPERATION_DESCRIPTION_MAX_LENGTH, INTERFACE_OPERATION_INPUT_NAME_ALREADY_IN_USE, INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE,INTERFACE_OPERATION_NOT_DELETED,
INTERFACE_OPERATION_INPUT_NAME_MANDATORY, INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY,
- INTERFACE_OPERATION_INPUT_PROPERTY_NOT_FOUND_IN_COMPONENT
+ INTERFACE_OPERATION_INPUT_PROPERTY_NOT_FOUND_IN_COMPONENT,
+
+ //InterfaceLifeCycleType
+ INTERFACE_LIFECYCLE_TYPES_NOT_FOUND
;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java
index fd9addd0ec..06622ebba6 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IInterfaceLifecycleOperation.java
@@ -50,4 +50,6 @@ public interface IInterfaceLifecycleOperation {
public Either<InterfaceDefinition, StorageOperationStatus> getInterface(String interfaceId);
public String getShortInterfaceName(InterfaceDataDefinition interfaceDefinition);
+
+ Either<Map<String, InterfaceDefinition>,StorageOperationStatus> getAllInterfaceLifecycleTypes();
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
index 3482a25bc4..c842e5b59d 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperation.java
@@ -47,8 +47,8 @@ import java.util.*;
import java.util.Map.Entry;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.Set;
+import java.util.stream.Collectors;
@Component("interface-operation")
public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation {
@@ -891,4 +891,40 @@ public class InterfaceLifecycleOperation implements IInterfaceLifecycleOperation
return createInterfaceType(interf, false);
}
+ @Override
+ public Either<Map<String, InterfaceDefinition>, StorageOperationStatus> getAllInterfaceLifecycleTypes() {
+
+ Either<List<InterfaceData>, TitanOperationStatus> allInterfaceLifecycleTypes =
+ titanGenericDao.getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class);
+ if (allInterfaceLifecycleTypes.isRight()) {
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus
+ (allInterfaceLifecycleTypes.right().value()));
+ }
+
+ Map<String, InterfaceDefinition> interfaceTypes = new HashMap<>();
+ List<InterfaceData> interfaceDataList = allInterfaceLifecycleTypes.left().value();
+ List<InterfaceDefinition> interfaceDefinitions = interfaceDataList.stream()
+ .map(this::convertInterfaceDataToInterfaceDefinition)
+ .filter(interfaceDefinition -> interfaceDefinition.getUniqueId().equalsIgnoreCase((interfaceDefinition.getType())))
+ .collect(Collectors.toList());
+
+ for (InterfaceDefinition interfaceDefinition : interfaceDefinitions) {
+
+ Either<List<ImmutablePair<OperationData, GraphEdge>>, TitanOperationStatus>
+ childrenNodes = titanGenericDao.getChildrenNodes(GraphPropertiesDictionary.UNIQUE_ID.getProperty(),
+ interfaceDefinition.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class);
+ if(childrenNodes.isRight()) {
+ return Either.right(DaoStatusConverter.convertTitanStatusToStorageStatus(childrenNodes.right().value()));
+ }
+
+ Map<String, OperationDataDefinition> operationsDataDefinitionMap = new HashMap<>();
+ for(ImmutablePair<OperationData, GraphEdge> operation : childrenNodes.left().value()) {
+ OperationData operationData = operation.getLeft();
+ operationsDataDefinitionMap.put(operationData.getUniqueId(), operationData.getOperationDataDefinition());
+ }
+ interfaceDefinition.setOperations(operationsDataDefinitionMap);
+ interfaceTypes.put(interfaceDefinition.getUniqueId(), interfaceDefinition);
+ }
+ return Either.left(interfaceTypes);
+ }
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
index a50435b30c..3e8b087fb2 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java
@@ -22,44 +22,59 @@ package org.openecomp.sdc.be.model.operations.impl;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+import fj.data.Either;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.ModelTestBase;
import org.openecomp.sdc.be.model.Operation;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil;
+import org.openecomp.sdc.be.resources.data.category.CategoryData;
+import org.openecomp.sdc.be.resources.data.InterfaceData;
+import org.openecomp.sdc.be.resources.data.OperationData;
import org.openecomp.sdc.be.resources.data.UserData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import org.junit.Assert;
+
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
-public class InterfaceOperationTest {
- private static final Logger log = LoggerFactory.getLogger(InterfaceOperationTest.class);
+public class InterfaceLifecycleOperationTest {
+ private static final Logger log = LoggerFactory.getLogger(InterfaceLifecycleOperationTest.class);
private Gson prettyGson = new GsonBuilder().setPrettyPrinting().create();
-
private static String USER_ID = "muUserId";
private static String CATEGORY_NAME = "category/mycategory";
- // InterfaceLifecycleOperation interfaceOperation = new
- // InterfaceLifecycleOperation();
-
- // TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
- @javax.annotation.Resource(name = "titan-generic-dao")
- private TitanGenericDao titanDao;
- @javax.annotation.Resource(name = "interface-operation")
- private InterfaceLifecycleOperation interfaceOperation;
+ TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+ @InjectMocks
+ private InterfaceLifecycleOperation interfaceLifecycleOperation = new InterfaceLifecycleOperation();
@javax.annotation.Resource(name = "property-operation")
private PropertyOperation propertyOperation;
@@ -69,6 +84,10 @@ public class InterfaceOperationTest {
@Before
public void createUserAndCategory() {
+ MockitoAnnotations.initMocks(this);
+ final String UNIQUE_ID = "UNIQUE_ID";
+ CategoryData categoryData = new CategoryData(NodeTypeEnum.ResourceCategory);
+ when(titanGenericDao.createNode(any(),any())).thenReturn(Either.left(categoryData));
deleteAndCreateCategory(CATEGORY_NAME);
deleteAndCreateUser(USER_ID, "first_" + USER_ID, "last_" + USER_ID);
}
@@ -88,7 +107,7 @@ public class InterfaceOperationTest {
@Test
public void testDummy() {
- assertNotNull(interfaceOperation);
+ assertNotNull(interfaceLifecycleOperation);
}
@@ -228,7 +247,7 @@ public class InterfaceOperationTest {
private void deleteAndCreateCategory(String category) {
String[] names = category.split("/");
- OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanDao);
+ OperationTestsUtil.deleteAndCreateResourceCategory(names[0], names[1], titanGenericDao);
/*
* CategoryData categoryData = new CategoryData(); categoryData.setName(category);
@@ -244,11 +263,40 @@ public class InterfaceOperationTest {
userData.setFirstName(firstName);
userData.setLastName(lastName);
- titanDao.deleteNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), userId, UserData.class);
- titanDao.createNode(userData, UserData.class);
- titanDao.commit();
+ titanGenericDao.deleteNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), userId,
+ UserData.class);
+ titanGenericDao.createNode(userData, UserData.class);
+ titanGenericDao.commit();
return userData;
}
+ @Test
+ public void testGetAllInterfaceLifecycleTypes_TypesNotFound() {
+ when(titanGenericDao.getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(),
+ InterfaceData.class)).thenReturn(Either.right(TitanOperationStatus.NOT_FOUND));
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes();
+ Assert.assertEquals(types.isRight(), Boolean.TRUE);
+ }
+
+ @Test
+ public void testGetAllInterfaceLifecycleTypes_Success() {
+ final String UNIQUE_ID = "UNIQUE_ID";
+ final String TYPE = "UNIQUE_ID";
+ InterfaceData interfaceData = new InterfaceData();
+ interfaceData.getInterfaceDataDefinition().setUniqueId(UNIQUE_ID);
+ interfaceData.getInterfaceDataDefinition().setType(TYPE);
+ List<InterfaceData> interfaceDataList = new ArrayList<>();
+ interfaceDataList.add(interfaceData);
+ Either<List<InterfaceData>, TitanOperationStatus> allInterfaceTypes = Either.left(interfaceDataList);
+ when(titanGenericDao.getByCriteria(NodeTypeEnum.Interface, Collections.emptyMap(), InterfaceData.class)).thenReturn(allInterfaceTypes);
+
+ List<ImmutablePair<OperationData, GraphEdge>> list = new ArrayList<>();
+ Either<List<ImmutablePair<OperationData, GraphEdge>>, TitanOperationStatus> childrenNodes = Either.left(list);
+ when(titanGenericDao.getChildrenNodes(interfaceData.getUniqueIdKey(), interfaceData.getUniqueId(), GraphEdgeLabels.INTERFACE_OPERATION, NodeTypeEnum.InterfaceOperation, OperationData.class)).thenReturn(childrenNodes);
+
+ Either<Map<String, InterfaceDefinition>, StorageOperationStatus> types = interfaceLifecycleOperation.getAllInterfaceLifecycleTypes();
+ Assert.assertEquals(types.left().value().size(),1);
+ }
+
}
diff --git a/openecomp-bdd/config.json b/openecomp-bdd/config.json
index c28bc9d390..4bf5f95ac5 100644
--- a/openecomp-bdd/config.json
+++ b/openecomp-bdd/config.json
@@ -13,6 +13,12 @@
"server" : "vf.server",
"user" : "user"
},
+ "catalog" : {
+ "port" : 8080,
+ "prefix" : "sdc2/rest/v1",
+ "server" : "CatalogBE.server",
+ "user" : "user"
+ },
"activity_spec" : {
"port" : 8080,
"prefix" : "activity-spec-api/v1.0",
diff --git a/openecomp-bdd/features/GlobalTypes/TestInterfaceLifecycleTypes.feature b/openecomp-bdd/features/GlobalTypes/TestInterfaceLifecycleTypes.feature
new file mode 100644
index 0000000000..ef98fa5b42
--- /dev/null
+++ b/openecomp-bdd/features/GlobalTypes/TestInterfaceLifecycleTypes.feature
@@ -0,0 +1,8 @@
+Feature: Interface Lifecycle Types
+
+Scenario: Test Interface Lifecycle Types
+
+ When I want to get interface lifecycle types
+ Then I want to check property "tosca.interfaces.node.lifecycle.standard" exists
+ Then I want to check property "tosca.interfaces.nfv.vnf.lifecycle.nfv" exists
+
diff --git a/openecomp-bdd/stepDefinitions/GlobalTypes.js b/openecomp-bdd/stepDefinitions/GlobalTypes.js
new file mode 100644
index 0000000000..461fee74a7
--- /dev/null
+++ b/openecomp-bdd/stepDefinitions/GlobalTypes.js
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+const {Then, When} = require('cucumber');
+const assert = require('assert');
+const util = require('./Utils.js');
+
+When('I want to get interface lifecycle types', function () {
+ let path = '/catalog/interfaceLifecycleTypes';
+ return util.request(this.context, 'GET', path, null, false, 'catalog');
+}); \ No newline at end of file