From eade687014a0c1b3b571a914f709488608635d6d Mon Sep 17 00:00:00 2001 From: Piotr Krysiak Date: Fri, 20 Jul 2018 10:17:26 +0200 Subject: Catalog-be dead code removal Issue-ID: SDC-1546 Change-Id: I63b43748b85f1b3823caa7cb6f4d2b960fdb9c79 Signed-off-by: Piotr Krysiak --- .../impl/AuditResourceEventFactoryMananger.java | 5 - .../be/components/impl/ArtifactsBusinessLogic.java | 6 - .../impl/ComponentInstanceBusinessLogic.java | 46 +++--- .../components/lifecycle/CheckoutTransition.java | 13 +- .../servlet/ArtifactExternalServlet.java | 61 ++++--- .../org/openecomp/sdc/ElementOperationMock.java | 13 +- .../components/BaseServiceBusinessLogicTest.java | 67 ++------ .../sdc/be/components/GroupBusinessLogicTest.java | 166 +------------------ .../components/HealthCheckBusinessLogicTest.java | 16 +- .../be/components/PropertyBusinessLogicTest.java | 53 ++---- .../be/components/ServiceBusinessLogicTest.java | 143 ++-------------- .../engine/DistributionEngineHealthCheckTest.java | 45 +----- .../impl/ArtifactsBusinessLogicTest.java | 97 ++++------- .../impl/ComponentInstanceBusinessLogicTest.java | 47 ++---- .../sdc/be/components/impl/ImportUtilsTest.java | 51 ++---- .../components/impl/ResourceBusinessLogicTest.java | 146 +++-------------- .../impl/ResourceInstanceBusinessLogicTest.java | 59 ++----- .../lifecycle/CertificationRequestTest.java | 26 +-- .../sdc/be/components/lifecycle/CheckoutTest.java | 15 +- .../be/components/lifecycle/LifecycleTestBase.java | 25 +-- ...ComponentCapabilitiesPropertiesMergeBLTest.java | 18 +-- .../be/components/path/BaseForwardingPathTest.java | 33 +--- .../sdc/be/datamodel/utils/ArtifactUtilsTest.java | 17 +- .../openecomp/sdc/be/ecomp/EcompIntImplTest.java | 12 -- .../sdc/be/servlets/GroupEndpointTest.java | 179 --------------------- .../sdc/be/servlets/GroupTypesEndpointTest.java | 65 +++----- .../sdc/be/servlets/UserAdminServletTest.java | 47 ++---- .../transaction/mngr/SdncTransactionTest.java | 54 +------ 28 files changed, 269 insertions(+), 1256 deletions(-) delete mode 100644 catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java (limited to 'catalog-be') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryMananger.java b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryMananger.java index 3400016ff0..25ce6e46a7 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryMananger.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/auditing/impl/AuditResourceEventFactoryMananger.java @@ -52,11 +52,6 @@ public class AuditResourceEventFactoryMananger { resourceType, resourceName, invariantUuid, modifier, artifactData, comment, did); break; -// case DOWNLOAD_ARTIFACT: -// factory = new AuditDownloadArtifactExternalApiEventFactory(commonFields, String resourceType, String resourceName, -// String consumerId, String resourceUrl, ResourceAuditData prevParams, ResourceAuditData currParams, -// String invariantUuid, User modifier, String artifactData); -// break; case DISTRIBUTION_STATE_CHANGE_REQUEST: factory = new AuditDistStateChangeRequestResourceAdminEventFactory(commonFields, prevParams, currParams, resourceType, resourceName, invariantUuid, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index c8fc13d31e..b7c4b924c2 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -421,10 +421,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private Either, ResponseFormat> doAction(String componentId, ComponentTypeEnum componentType, ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo, String origMd5, String originData, String interfaceName, String operationName, AuditingActionEnum auditingAction, User user, org.openecomp.sdc.be.model.Component parent, boolean shouldLock, boolean inTransaction, boolean needUpdateGroup) { - /*if (interfaceName != null && operationName != null) { - interfaceName = interfaceName.toLowerCase(); - operationName = operationName.toLowerCase(); - }*/ switch (operation.getArtifactOperationEnum()) { case DOWNLOAD: if (artifactGenerationRequired(parent, artifactInfo)) { @@ -1190,10 +1186,8 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return Either.right(validateGroupType.right().value()); } } - // TODO TEMP !!! NodeTypeEnum parentType = convertParentType(componentType); - // TODO TEMP !!! boolean isCreate = ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()); if (isDeploymentArtifact(artifactInfo)) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java index 81b7c6a9c1..0ff00913e0 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java @@ -20,23 +20,8 @@ package org.openecomp.sdc.be.components.impl; -import static org.openecomp.sdc.be.components.property.GetInputUtils.isGetInputValueForInput; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Optional; -import java.util.Set; -import java.util.UUID; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; - +import com.google.common.collect.Sets; +import fj.data.Either; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang.StringUtils; @@ -102,9 +87,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.UUID; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; -import fj.data.Either; +import static org.openecomp.sdc.be.components.property.GetInputUtils.isGetInputValueForInput; @org.springframework.stereotype.Component public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { @@ -884,12 +882,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { if (lockComponent.isRight()) { return Either.right(lockComponent.right().value()); } - // validate resource - /* - * if (!ComponentValidationUtils.canWorkOnComponent(containerComponentId, serviceOperation, userId)) { log.info( "Restricted operation for user " + userId + " on service " + containerComponentId); return Either.right(componentsUtils - * .getResponseFormat(ActionStatus.RESTRICTED_OPERATION)); } // lock resource StorageOperationStatus lockStatus = graphLockOperation.lockComponent( containerComponentId, NodeTypeEnum.Service); if (lockStatus != StorageOperationStatus.OK) { - * log.debug("Failed to lock service {}", containerComponentId); resultOp = Either.right(componentsUtils .getResponseFormat(componentsUtils .convertFromStorageResponse(lockStatus))); return resultOp; } - */ + Either resultOp = null; try { resultOp = deleteComponentInstance(containerComponent, componentInstanceId, containerComponentType); @@ -904,9 +897,6 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic { return deleteEither; } finally { - /* - * if (resultOp == null || resultOp.isRight()) { titanGenericDao.rollback(); } else { titanGenericDao.commit(); } graphLockOperation.unlockComponent(containerComponentId, NodeTypeEnum.Service); - */ unlockComponent(resultOp, containerComponent); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java index 3d1ba33df2..5d7470e79b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java @@ -20,9 +20,7 @@ package org.openecomp.sdc.be.components.lifecycle; -import java.util.Arrays; -import java.util.List; - +import fj.data.Either; import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic; import org.openecomp.sdc.be.config.BeEcompErrorManager; import org.openecomp.sdc.be.dao.api.ActionStatus; @@ -49,7 +47,8 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import fj.data.Either; +import java.util.Arrays; +import java.util.List; public class CheckoutTransition extends LifeCycleTransition { @@ -167,12 +166,6 @@ public class CheckoutTransition extends LifeCycleTransition { return userValidationResponse; } - // Disabled as of 1604 patch after discussing with Ella/Eli/Michael - - /* - * if (componentType == ComponentTypeEnum.PRODUCT){ Either productContactsEither = productContactsValidation((Product)component, modifier); if (productContactsEither.isRight()){ return productContactsEither; } } - */ - // check resource is not locked by another user if (oldState.equals(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT)) { ResponseFormat error = componentUtils.getResponseFormat(ActionStatus.COMPONENT_IN_CHECKOUT_STATE, componentName, componentType.name().toLowerCase(), owner.getFirstName(), owner.getLastName(), owner.getUserId()); diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java index 80642c1e93..0c31539baa 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/ArtifactExternalServlet.java @@ -20,27 +20,15 @@ package org.openecomp.sdc.be.externalapi.servlet; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.Map; - -import javax.inject.Singleton; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.HeaderParam; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - +import com.jcabi.aspects.Loggable; +import fj.data.Either; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; import org.openecomp.sdc.be.config.BeEcompErrorManager; @@ -57,16 +45,25 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.jcabi.aspects.Loggable; - -import fj.data.Either; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import javax.inject.Singleton; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.HeaderParam; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.HttpHeaders; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.Map; /** * This Servlet serves external users operations on artifacts. * @@ -568,8 +565,6 @@ public class ArtifactExternalServlet extends AbstractValidationsServlet { @Path("/{assetType}/{uuid}/artifacts/{artifactUUID}") @Produces(MediaType.APPLICATION_JSON) @ApiOperation(value = "deletes an artifact of a resource or service", httpMethod = "DELETE", notes = "deletes an artifact of a resource or service", response = Response.class) - /*@ApiResponses(value = { @ApiResponse(code = 200, message = "Artifact Deleted"), @ApiResponse(code = 401, message = "Authorization required"), @ApiResponse(code = 403, message = "Restricted operation"), - @ApiResponse(code = 404, message = "Asset not found") })*/ @ApiResponses(value = { @ApiResponse(code = 200, message = "Artifact deleted", response = ArtifactDefinition.class), @ApiResponse(code = 400, message = "Missing 'X-ECOMP-InstanceID' HTTP header - POL5001"), diff --git a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java index d87f01d1fb..1043a6b694 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java @@ -20,10 +20,7 @@ package org.openecomp.sdc; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - +import fj.data.Either; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.graph.datatype.GraphNode; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -38,7 +35,9 @@ import org.openecomp.sdc.be.model.operations.api.IElementOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.resources.data.CategoryData; -import fj.data.Either; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; public class ElementOperationMock implements IElementOperation { @@ -93,10 +92,6 @@ public class ElementOperationMock implements IElementOperation { } - /* - * @Override public Either getCategory(String name) { if (name.equals(resourceCategory.getName())){ return Either.left(resourceCategory); } else { return Either.right(ActionStatus.CATEGORY_NOT_FOUND); } } - */ - @Override public Either, ActionStatus> getAllTags() { // TODO Auto-generated method stub diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java index a8c014754c..6a17189dd2 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/BaseServiceBusinessLogicTest.java @@ -1,15 +1,7 @@ package org.openecomp.sdc.be.components; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.ServletContext; - +import com.google.common.collect.Sets; +import fj.data.Either; import org.junit.Before; import org.mockito.Mockito; import org.openecomp.sdc.ElementOperationMock; @@ -51,15 +43,17 @@ import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import com.google.common.collect.Sets; +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import fj.data.Either; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; public class BaseServiceBusinessLogicTest { - private static final Logger log = LoggerFactory.getLogger(ServiceBusinessLogicTest.class); private static final String SERVICE_CATEGORY = "Mobility"; final ServletContext servletContext = Mockito.mock(ServletContext.class); UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class); @@ -114,7 +108,6 @@ public class BaseServiceBusinessLogicTest { // Servlet Context attributes when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); -// when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation()); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao); @@ -209,10 +202,8 @@ public class BaseServiceBusinessLogicTest { createResourceAudit.setStatus("201"); createResourceAudit.setPrevVersion(""); createResourceAudit.setAction("Create"); - // fields.put("TIMESTAMP", "2015-11-22 09:19:12.977"); createResourceAudit.setPrevState(""); createResourceAudit.setResourceName("MyTestResource"); - // createResourceAudit.setFields(fields); final ResourceAdminEvent checkInResourceAudit = new ResourceAdminEvent(); checkInResourceAudit.setModifier("Carlos Santana(cs0008)"); @@ -226,7 +217,6 @@ public class BaseServiceBusinessLogicTest { checkInResourceAudit.setStatus("200"); checkInResourceAudit.setPrevVersion("0.1"); checkInResourceAudit.setAction("Checkin"); - // fields.put("TIMESTAMP", "2015-11-22 09:25:03.797"); checkInResourceAudit.setPrevState("NOT_CERTIFIED_CHECKOUT"); checkInResourceAudit.setResourceName("MyTestResource"); @@ -242,43 +232,8 @@ public class BaseServiceBusinessLogicTest { checkOutResourceAudit.setStatus("200"); checkOutResourceAudit.setPrevVersion("0.1"); checkOutResourceAudit.setAction("Checkout"); - // fields.put("TIMESTAMP", "2015-11-22 09:39:41.024"); checkOutResourceAudit.setPrevState("NOT_CERTIFIED_CHECKIN"); checkOutResourceAudit.setResourceName("MyTestResource"); - // checkOutResourceAudit.setFields(fields); - - // Mockito.doAnswer(new Answer, - // ActionStatus> >() { - // public Either, ActionStatus> - // answer(InvocationOnMock invocation) { - // final Either, ActionStatus> either; - // final List list; - // Object[] args = invocation.getArguments(); - // Map filterMap = - // (Map) args[0]; - // if( filterMap.equals(FILTER_MAP_CERTIFIED_VERSION) ){ - // list = new - // ArrayList(){{add(createResourceAudit);add(checkInResourceAudit);add(checkOutResourceAudit);}}; - // either = Either.left(list); - // - // } - // else if( filterMap.equals(FILTER_MAP_UNCERTIFIED_VERSION_PREV) ){ - // list = new ArrayList(); - // either = Either.left(list); - // } - // else if( filterMap.equals(FILTER_MAP_UNCERTIFIED_VERSION_CURR) ){ - // list = new - // ArrayList(){{/*add(createResourceAudit);add(checkInResourceAudit);*/add(checkOutResourceAudit);}}; - // either = Either.left(list); - // } - // else{ - // either = null; - // } - // return either; - // } - // }).when(auditingDao).getFilteredResourceAdminAuditingEvents(Mockito.anyMap()); - // - // List list = new ArrayList() { { add(createResourceAudit); @@ -300,7 +255,6 @@ public class BaseServiceBusinessLogicTest { }; Either, ActionStatus> resultCurr = Either.left(listCurr); Mockito.when(auditingDao.getAuditByServiceIdAndCurrVersion(Mockito.anyString(), Mockito.anyString())).thenReturn(resultCurr); - } protected Service createServiceObject(boolean afterCreate) { @@ -316,10 +270,7 @@ public class BaseServiceBusinessLogicTest { List tgs = new ArrayList(); tgs.add(service.getName()); service.setTags(tgs); - // service.setVendorName("Motorola"); - // service.setVendorRelease("1.0.0"); service.setIcon("MyIcon"); - // service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); service.setContactId("aa1234"); service.setProjectCode("12345"); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java index a2dfd907da..2884a590a8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/GroupBusinessLogicTest.java @@ -20,13 +20,8 @@ package org.openecomp.sdc.be.components; -import static org.mockito.Mockito.when; - -import javax.servlet.ServletContext; - import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; @@ -35,17 +30,17 @@ import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.impl.ComponentsUtils; -import org.openecomp.sdc.be.model.GroupDefinition; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.GroupOperation; import org.openecomp.sdc.common.api.ConfigurationSource; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; + +import javax.servlet.ServletContext; + +import static org.mockito.Mockito.when; /** * tests GroupBusinessLogic class * @author ns019t @@ -53,15 +48,11 @@ import org.slf4j.LoggerFactory; */ public class GroupBusinessLogicTest { - private static final Logger log = LoggerFactory.getLogger(ServiceBusinessLogicTest.class); ComponentsUtils componentsUtils; final ServletContext servletContext = Mockito.mock(ServletContext.class); private static IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class); - private static GroupOperation groupOperation = Mockito.mock(GroupOperation.class); - private static GroupDefinition groupDefenition = Mockito.mock(GroupDefinition.class); private static User user = Mockito.mock(User.class); private static String componentId = "vfUniqueId-xxxx"; - private static String groupUniqueId = "groupUniqueId-xxxx"; @InjectMocks static GroupBusinessLogic bl = new GroupBusinessLogic(); @@ -81,154 +72,5 @@ public class GroupBusinessLogicTest { @BeforeClass public static void setupBeforeClass() { when(graphLockOperation.lockComponent(componentId, ComponentTypeEnum.RESOURCE.getNodeType())).thenReturn(StorageOperationStatus.OK); -// when(groupOperation.getGroup(groupUniqueId)).thenReturn(Either.left(groupDefenition)); - } - - /** - * tests the ValidateMinMaxAndInitialCountPropertyValues() method - */ - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Test - public void testValidateMinMaxAndInitialCountPropertyValues(){ - -// Class targetClass = GroupBusinessLogic.class; -// String methodName = "validateMinMaxAndInitialCountPropertyValues"; -// Either validationRes; -// -// Map parentPropertyValues = new EnumMap<>(PropertyNames.class); -// parentPropertyValues.put(PropertyNames.MIN_INSTANCES, "20"); -// parentPropertyValues.put(PropertyNames.MAX_INSTANCES, "100"); -// parentPropertyValues.put(PropertyNames.INITIAL_COUNT, "40"); -// -// Map parentPropertyValues1 = new EnumMap<>(PropertyNames.class); -// parentPropertyValues1.put(PropertyNames.MIN_INSTANCES, "20"); -// parentPropertyValues1.put(PropertyNames.MAX_INSTANCES, null); -// parentPropertyValues1.put(PropertyNames.INITIAL_COUNT, "40"); -// -// Map parentPropertyValues2 = new EnumMap<>(PropertyNames.class); -// parentPropertyValues2.put(PropertyNames.MIN_INSTANCES, "20"); -// parentPropertyValues2.put(PropertyNames.MAX_INSTANCES, "null"); -// parentPropertyValues2.put(PropertyNames.INITIAL_COUNT, "40"); -// -// Map validNewPropertyValues = new EnumMap<>(PropertyNames.class); -// validNewPropertyValues.put(PropertyNames.MIN_INSTANCES, "20"); -// validNewPropertyValues.put(PropertyNames.MAX_INSTANCES, "100"); -// validNewPropertyValues.put(PropertyNames.INITIAL_COUNT, "50"); -// -// Map validNewPropertyValues1 = new EnumMap<>(PropertyNames.class); -// validNewPropertyValues1.put(PropertyNames.MIN_INSTANCES, "40"); -// validNewPropertyValues1.put(PropertyNames.MAX_INSTANCES, "90"); -// validNewPropertyValues1.put(PropertyNames.INITIAL_COUNT, "60"); -// -// Map validNewPropertyValues2 = new EnumMap<>(PropertyNames.class); -// validNewPropertyValues2.put(PropertyNames.MIN_INSTANCES, "40"); -// validNewPropertyValues2.put(PropertyNames.MAX_INSTANCES, null); -// validNewPropertyValues2.put(PropertyNames.INITIAL_COUNT, "60"); -// -// Map validNewPropertyValues3 = new EnumMap<>(PropertyNames.class); -// validNewPropertyValues3.put(PropertyNames.MIN_INSTANCES, "40"); -// validNewPropertyValues3.put(PropertyNames.MAX_INSTANCES, "null"); -// validNewPropertyValues3.put(PropertyNames.INITIAL_COUNT, "60"); -// -// Map validNewPropertyValues4 = new EnumMap<>(PropertyNames.class); -// validNewPropertyValues4.put(PropertyNames.MIN_INSTANCES, null); -// validNewPropertyValues4.put(PropertyNames.MAX_INSTANCES, null); -// validNewPropertyValues4.put(PropertyNames.INITIAL_COUNT, "60"); -// -// Map invalidNewPropertyValues = new EnumMap<>(PropertyNames.class); -// invalidNewPropertyValues.put(PropertyNames.MIN_INSTANCES, "20"); -// invalidNewPropertyValues.put(PropertyNames.MAX_INSTANCES, "10"); -// invalidNewPropertyValues.put(PropertyNames.INITIAL_COUNT, "5"); -// -// Map invalidNewPropertyValues1 = new EnumMap<>(PropertyNames.class); -// invalidNewPropertyValues1.put(PropertyNames.MIN_INSTANCES, "5"); -// invalidNewPropertyValues1.put(PropertyNames.MAX_INSTANCES, "10"); -// invalidNewPropertyValues1.put(PropertyNames.INITIAL_COUNT, "20"); -// -// Map invalidNewPropertyValues2 = new EnumMap<>(PropertyNames.class); -// invalidNewPropertyValues2.put(PropertyNames.MIN_INSTANCES, "25"); -// invalidNewPropertyValues2.put(PropertyNames.MAX_INSTANCES, "95"); -// invalidNewPropertyValues2.put(PropertyNames.INITIAL_COUNT, "100"); -// -// Map invalidNewPropertyValues3 = new EnumMap<>(PropertyNames.class); -// invalidNewPropertyValues3.put(PropertyNames.MIN_INSTANCES, null); -// invalidNewPropertyValues3.put(PropertyNames.MAX_INSTANCES, "95"); -// invalidNewPropertyValues3.put(PropertyNames.INITIAL_COUNT, "10"); -// -// Map invalidNewPropertyValues4 = new EnumMap<>(PropertyNames.class); -// invalidNewPropertyValues4.put(PropertyNames.MIN_INSTANCES, "30"); -// invalidNewPropertyValues4.put(PropertyNames.MAX_INSTANCES, "80"); -// invalidNewPropertyValues4.put(PropertyNames.INITIAL_COUNT, null); -// -// -// Class[] argClasses = {Map.class, Map.class}; -// try { -// Method method = targetClass.getDeclaredMethod(methodName, argClasses); -// method.setAccessible(true); -// -// Object[] argObjects2 = {invalidNewPropertyValues, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects2); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isRight()); -// assertTrue(validationRes.right().value().getMessageId().equals(ResponseEnum.INVALID_MIN_MAX.getMessageId())); -// -// Object[] argObjects3 = {invalidNewPropertyValues1, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects3); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isRight()); -// assertTrue(validationRes.right().value().getMessageId().equals(ResponseEnum.INVALID_MIN_MAX.getMessageId())); -// -// Object[] argObjects7 = {invalidNewPropertyValues3, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects7); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isRight()); -// assertTrue(validationRes.right().value().getMessageId().equals(ResponseEnum.INVALID_MIN_MAX.getMessageId())); -// -// Object[] argObjects = {validNewPropertyValues, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isLeft()); -// assertTrue(validationRes.left().value()); -// -// Object[] argObjects1 = {validNewPropertyValues1, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects1); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isLeft()); -// assertTrue(validationRes.left().value()); -// -// Object[] argObjects5 = {validNewPropertyValues2, parentPropertyValues2}; -// validationRes = (Either) method.invoke(bl, argObjects5); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isLeft()); -// assertTrue(validationRes.left().value()); -// -// Object[] argObjects6 = {validNewPropertyValues3, parentPropertyValues1}; -// validationRes = (Either) method.invoke(bl, argObjects6); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isLeft()); -// assertTrue(validationRes.left().value()); -// -// Object[] argObjects9 = {validNewPropertyValues4, parentPropertyValues1}; -// validationRes = (Either) method.invoke(bl, argObjects9); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isLeft()); -// assertTrue(validationRes.left().value()); -// -// Object[] argObjects4 = {invalidNewPropertyValues2, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects4); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isRight()); -// assertTrue(validationRes.right().value().getMessageId().equals(ResponseEnum.INVALID_INITIAL_COUNT.getMessageId())); -// -// Object[] argObjects8 = {invalidNewPropertyValues4, parentPropertyValues}; -// validationRes = (Either) method.invoke(bl, argObjects8); -// assertTrue(validationRes != null); -// assertTrue(validationRes.isRight()); -// assertTrue(validationRes.right().value().getMessageId().equals(ResponseEnum.INVALID_INITIAL_COUNT.getMessageId())); -// } -// catch (Exception e) { -// e.printStackTrace(); -// } } - } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java index 11d2496211..29143189b5 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java @@ -20,17 +20,17 @@ package org.openecomp.sdc.be.components; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.List; - import org.junit.Test; import org.openecomp.sdc.be.components.health.HealthCheckBusinessLogic; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.common.api.HealthCheckInfo; import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus; + +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; public class HealthCheckBusinessLogicTest { HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic(); @@ -50,10 +50,6 @@ public class HealthCheckBusinessLogicTest { HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(Constants.HC_COMPONENT_TITAN, HealthCheckStatus.DOWN, null, null); - /* - * HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null); - */ - checkInfosLeft.add(checkInfoTitanUp); checkInfosRight.add(checkInfoTitanUp); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java index 120077efc9..9e323a55d6 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/PropertyBusinessLogicTest.java @@ -20,19 +20,7 @@ package org.openecomp.sdc.be.components; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -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.List; -import java.util.Map; - -import javax.servlet.ServletContext; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -45,13 +33,11 @@ import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.WebAppContextWrapper; -import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IPropertyOperation; -import org.openecomp.sdc.be.resources.data.EntryData; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.be.user.UserBusinessLogic; import org.openecomp.sdc.common.api.ConfigurationSource; @@ -63,8 +49,15 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import fj.data.Either; -import junit.framework.Assert; +import javax.servlet.ServletContext; +import java.util.Arrays; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; public class PropertyBusinessLogicTest { @@ -117,34 +110,9 @@ public class PropertyBusinessLogicTest { when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); when(servletContext.getAttribute(Constants.PROPERTY_OPERATION_MANAGER)).thenReturn(propertyOperation); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); -// when(servletContext.getAttribute(Constants.RESOURCE_OPERATION_MANAGER)).thenReturn(resourceOperation); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); - // Resource Operation mock methods - // getCount -// Either eitherCount = Either.left(0); -// when(resourceOperation.getNumberOfResourcesByName("MyResourceName".toLowerCase())).thenReturn(eitherCount); -// Either eitherCountExist = Either.left(1); -// when(resourceOperation.getNumberOfResourcesByName("alreadyExist".toLowerCase())).thenReturn(eitherCountExist); -// Either eitherCountRoot = Either.left(1); -// when(resourceOperation.getNumberOfResourcesByName("Root".toLowerCase())).thenReturn(eitherCountRoot); -// -// Either eitherGetResource = Either.left(createResourceObject(true)); -// when(resourceOperation.getResource(resourceId)).thenReturn(eitherGetResource); - - } - - // @Test - public void testHappyScenario() { - - String propertyName = "disk_size"; - PropertyDefinition newPropertyDefinition = createPropertyObject(propertyName, resourceId); - Either, ResponseFormat> either = bl.createProperty(resourceId, propertyName, newPropertyDefinition, user.getUserId()); - if (either.isRight()) { - Assert.assertFalse(true); - } - Assert.assertEquals(newPropertyDefinition, either.left().value()); } @Test @@ -191,7 +159,6 @@ public class PropertyBusinessLogicTest { private PropertyDefinition createPropertyObject(String propertyName, String resourceId) { PropertyDefinition pd = new PropertyDefinition(); - List constraints = new ArrayList(); pd.setConstraints(null); pd.setDefaultValue("100"); pd.setDescription("Size of thasdasdasdasde local disk, in Gigabytes (GB), available to applications running on the Compute node"); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java index f9c75d488e..6dfcad1d98 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ServiceBusinessLogicTest.java @@ -20,23 +20,7 @@ package org.openecomp.sdc.be.components; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -import java.lang.reflect.Method; -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 fj.data.Either; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Ignore; @@ -87,7 +71,21 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import fj.data.Either; +import javax.servlet.ServletContext; +import java.lang.reflect.Method; +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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; public class ServiceBusinessLogicTest { @@ -150,10 +148,7 @@ public class ServiceBusinessLogicTest { when(mockUserAdmin.getUser("jh0003", false)).thenReturn(eitherGetUser); when(userValidations.validateUserExists(eq("jh0003"), anyString(), eq(false))).thenReturn(Either.left(user)); when(userValidations.validateUserNotEmpty(eq(user), anyString())).thenReturn(Either.left(user)); -// when(userValidations.validateUserRole(user)) - // Servlet Context attributes when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager); -// when(servletContext.getAttribute(Constants.SERVICE_OPERATION_MANAGER)).thenReturn(new ServiceOperation()); when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext); when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao); @@ -258,14 +253,11 @@ public class ServiceBusinessLogicTest { assertEquals("assert error description", expectedResponse.getFormattedMessage(), actualResponse.getFormattedMessage()); } - /* CREATE validations - start ***********************/ - // Service name - start @Test public void testFailedServiceValidations() { testServiceNameAlreadyExists(); testServiceNameEmpty(); - // testServiceNameExceedsLimit(); testServiceNameWrongFormat(); testServiceDescriptionEmpty(); testServiceDescriptionMissing(); @@ -275,8 +267,6 @@ public class ServiceBusinessLogicTest { testServiceIconMissing(); testResourceIconInvalid(); testResourceIconExceedsLimit(); - // testTagsExceedsLimitCreate(); - // testTagsSingleExcessLimit(); testTagsNoServiceName(); testInvalidTag(); testServiceTagNotExist(); @@ -328,8 +318,6 @@ public class ServiceBusinessLogicTest { assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.SERVICE.getValue()); } - // Service name - end - // Service description - start private void testServiceDescriptionEmpty() { Service serviceExist = createServiceObject(false); serviceExist.setDescription(""); @@ -513,34 +501,6 @@ public class ServiceBusinessLogicTest { assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.SERVICE.getValue()); } - public void markDistributionAsDeployedTestAlreadyDeployed() { - String notifyAction = "DNotify"; - String requestAction = "DRequest"; - String resultAction = "DResult"; - String did = "123456"; - - setupBeforeDeploy(notifyAction, requestAction, did); - List resultList = new ArrayList(); - Map params = new HashMap(); - DistributionDeployEvent event = new DistributionDeployEvent(); - - event.setAction(resultAction); - event.setDid(did); - event.setStatus("200"); - // ESTimeBasedEvent deployEvent = new ESTimeBasedEvent(); - // deployEvent.setFields(params); - resultList.add(event); - Either, ActionStatus> eventList = Either.left(resultList); - - Mockito.when(auditingDao.getDistributionDeployByStatus(Mockito.anyString(), Mockito.eq(resultAction), Mockito.anyString())).thenReturn(eventList); - - Either markDeployed = bl.markDistributionAsDeployed(did, did, user); - assertTrue(markDeployed.isLeft()); - - Mockito.verify(auditingDao, Mockito.times(0)).getDistributionRequest(did, requestAction); - - } - @Test public void markDistributionAsDeployedTestSuccess() { String notifyAction = "DNotify"; @@ -556,25 +516,6 @@ public class ServiceBusinessLogicTest { assertTrue(markDeployed.isLeft()); } - //@Test - public void markDistributionAsDeployedTestNotDistributed() { - String notifyAction = "DNotify"; - String requestAction = "DRequest"; - String did = "123456"; - - setupBeforeDeploy(notifyAction, requestAction, did); - List emptyList = new ArrayList(); - Either, ActionStatus> emptyEventList = Either.left(emptyList); - Mockito.when(auditingDao.getDistributionRequest(Mockito.anyString(), Mockito.eq(requestAction))).thenReturn(emptyEventList); - - Either notFound = Either.right(StorageOperationStatus.NOT_FOUND); - Mockito.when(toscaOperationFacade.getToscaElement(did)).thenReturn(notFound); - - Either markDeployed = bl.markDistributionAsDeployed(did, did, user); - assertTrue(markDeployed.isRight()); - assertEquals(404, markDeployed.right().value().getStatus().intValue()); - - } private void testServiceBadCategoryCreate() { @@ -638,20 +579,6 @@ public class ServiceBusinessLogicTest { assertResponse(createResponse, ActionStatus.MISSING_PROJECT_CODE); } -// @Test -// public void testDeleteMarkedServicesNoServices() { -// List ids = new ArrayList(); -// Either, StorageOperationStatus> eitherNoResources = Either.left(ids); -// when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources); -// -// Either, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents(); -// assertTrue(deleteMarkedResources.isLeft()); -// assertTrue(deleteMarkedResources.left().value().isEmpty()); -// -// Mockito.verify(artifactBl, Mockito.times(0)).deleteAllComponentArtifactsIfNotOnGraph(Mockito.anyList()); -// -// } - @Test @Ignore public void testDeleteMarkedServices() { @@ -668,7 +595,6 @@ public class ServiceBusinessLogicTest { List artifacts = new ArrayList(); Either, StorageOperationStatus> getArtifactsResponse = Either.left(artifacts); -// when(toscaOperationFacade.getComponentArtifactsForDelete(resourceFree, NodeTypeEnum.Service, true)).thenReturn(getArtifactsResponse); when(toscaOperationFacade.isComponentInUse(resourceFree)).thenReturn(resourceFreeResponse); when(toscaOperationFacade.isComponentInUse(resourceInUse)).thenReturn(resourceInUseResponse); @@ -699,10 +625,7 @@ public class ServiceBusinessLogicTest { List tgs = new ArrayList(); tgs.add(service.getName()); service.setTags(tgs); - // service.setVendorName("Motorola"); - // service.setVendorRelease("1.0.0"); service.setIcon("MyIcon"); - // service.setState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); service.setContactId("aa1234"); service.setProjectCode("12345"); @@ -770,40 +693,6 @@ public class ServiceBusinessLogicTest { // fields.put("TIMESTAMP", "2015-11-22 09:39:41.024"); checkOutResourceAudit.setPrevState("NOT_CERTIFIED_CHECKIN"); checkOutResourceAudit.setResourceName("MyTestResource"); - // checkOutResourceAudit.setFields(fields); - - // Mockito.doAnswer(new Answer, - // ActionStatus> >() { - // public Either, ActionStatus> - // answer(InvocationOnMock invocation) { - // final Either, ActionStatus> either; - // final List list; - // Object[] args = invocation.getArguments(); - // Map filterMap = - // (Map) args[0]; - // if( filterMap.equals(FILTER_MAP_CERTIFIED_VERSION) ){ - // list = new - // ArrayList(){{add(createResourceAudit);add(checkInResourceAudit);add(checkOutResourceAudit);}}; - // either = Either.left(list); - // - // } - // else if( filterMap.equals(FILTER_MAP_UNCERTIFIED_VERSION_PREV) ){ - // list = new ArrayList(); - // either = Either.left(list); - // } - // else if( filterMap.equals(FILTER_MAP_UNCERTIFIED_VERSION_CURR) ){ - // list = new - // ArrayList(){{/*add(createResourceAudit);add(checkInResourceAudit);*/add(checkOutResourceAudit);}}; - // either = Either.left(list); - // } - // else{ - // either = null; - // } - // return either; - // } - // }).when(auditingDao).getFilteredResourceAdminAuditingEvents(Mockito.anyMap()); - // - // List list = new ArrayList() { { add(createResourceAudit); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java index 3d4462e1a3..a1c1cab701 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/DistributionEngineHealthCheckTest.java @@ -20,12 +20,6 @@ package org.openecomp.sdc.be.components.distribution.engine; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.List; - import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; @@ -33,49 +27,20 @@ import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.distribution.api.client.CambriaOperationStatus; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; +import java.util.List; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; public class DistributionEngineHealthCheckTest extends BeConfDependentTest { @Mock private CambriaHandler cambriaHandler = Mockito.mock(CambriaHandler.class); - DistributionEngineClusterHealth distributionEngineClusterHealth = new DistributionEngineClusterHealth(); - - Gson gson = new Gson(); - - Gson prettyGson = new GsonBuilder().setPrettyPrinting().create(); - - // - // @Test - // public void validateDownWhenEnvAreDown() { - // - // Map envNamePerStatus = new HashMap<>(); - // envNamePerStatus.put("PROD1", new AtomicBoolean(false)); - // envNamePerStatus.put("PROD2", new AtomicBoolean(false)); - // - // distributionEngineClusterHealth.startHealthCheckTask(envNamePerStatus); - // - // HealthCheckInfo healthCheckInfo = - // distributionEngineClusterHealth.getHealthCheckInfo(); - // assertEquals("verify down", HealthCheckStatus.DOWN, - // healthCheckInfo.getHealthCheckStatus()); - // assertEquals("verify DE component", HealthCheckComponent.DE, - // healthCheckInfo.getHealthCheckComponent()); - // - // } - @Test public void validateUpWhenQuerySucceed() { - // Map envNamePerStatus = new HashMap<>(); - // envNamePerStatus.put("PROD1", new AtomicBoolean(true)); - // envNamePerStatus.put("PROD2", new AtomicBoolean(false)); - // - // distributionEngineClusterHealth.startHealthCheckTask(envNamePerStatus, - // false); - CambriaErrorResponse cambriaOkResponse = new CambriaErrorResponse(CambriaOperationStatus.OK, 200); CambriaErrorResponse cambriaErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.INTERNAL_SERVER_ERROR, 500); CambriaErrorResponse cambriaNotErrorResponse = new CambriaErrorResponse(CambriaOperationStatus.AUTHENTICATION_ERROR, 403); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java index 3492c07684..52e5e29725 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogicTest.java @@ -20,29 +20,16 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; -import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import fj.data.Either; +import mockit.Deencapsulation; +import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -77,6 +64,7 @@ import org.openecomp.sdc.be.model.GroupInstance; import org.openecomp.sdc.be.model.HeatParameterDefinition; import org.openecomp.sdc.be.model.InterfaceDefinition; 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.Service; import org.openecomp.sdc.be.model.User; @@ -93,33 +81,36 @@ import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation; import org.openecomp.sdc.be.resources.data.ESArtifactData; import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum; import org.openecomp.sdc.be.servlets.RepresentationUtils; -import org.openecomp.sdc.be.user.IUserBusinessLogic; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.be.user.UserBusinessLogic; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; +import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import org.xml.sax.XMLReader; -import org.openecomp.sdc.be.model.Operation; -import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum; -import org.openecomp.sdc.common.datastructure.Wrapper; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonElement; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import fj.data.Either; -import mockit.Deencapsulation; -import java.util.*; -import org.junit.Assert; -import org.apache.commons.lang3.tuple.ImmutablePair; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_ENV_NAME; +import static org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.HEAT_VF_ENV_NAME; public class ArtifactsBusinessLogicTest { @@ -176,10 +167,6 @@ public class ArtifactsBusinessLogicTest { @Mock TitanDao titanDao; - // public static final InformationDeployedArtifactsBusinessLogic - // informationDeployedArtifactsBusinessLogic = - // Mockito.mock(InformationDeployedArtifactsBusinessLogic.class); - public static final Resource resource = Mockito.mock(Resource.class); private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -538,9 +525,6 @@ public class ArtifactsBusinessLogicTest { assertNull(heatEnvParam.getCurrentValue()); } - ////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////new tests/////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////////// private ArtifactsBusinessLogic createTestSubject() { return new ArtifactsBusinessLogic(); } @@ -1591,23 +1575,4 @@ public class ArtifactsBusinessLogicTest { testSubject = createTestSubject(); Deencapsulation.invoke(testSubject, "setNodeTemplateOperation", new Object[] { NodeTemplateOperation.class }); } - - // @Test - // public void convertAndValidateDeploymentArtifactNonHeatSuccess(){ - // ArtifactDefinition createArtifactDef = createArtifactDef(); - // createArtifactDef.setArtifactType(ArtifactTypeEnum.YANG_XML.getType()); - // - // Either validateResult = artifactBL - // - // assertTrue(validateResult.isLeft()); - // ArtifactDefinition validatedArtifact = validateResult.left().value(); - // - // assertEquals(createArtifactDef.getArtifactGroupType(), - // validatedArtifact.getArtifactGroupType()); - // assertEquals(new Integer(0), validatedArtifact.getTimeout()); - // assertFalse(validatedArtifact.getMandatory()); - // assertFalse(validatedArtifact.getServiceApi()); - // - // } - } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java index 944de05757..329ac3d609 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java @@ -1,33 +1,17 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anySet; -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.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.function.BiPredicate; - +import fj.data.Either; +import mockit.Deencapsulation; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; import org.assertj.core.util.Lists; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.openecomp.sdc.be.components.validation.UserValidations; import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum; -import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition; @@ -35,7 +19,6 @@ import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; -import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.impl.ServletUtils; @@ -58,17 +41,24 @@ import org.openecomp.sdc.be.model.jsontitan.operations.ForwardingPathOperation; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation; import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; -import org.openecomp.sdc.be.model.operations.impl.ArtifactOperation; -import org.openecomp.sdc.be.resources.data.ComponentInstanceData; import org.openecomp.sdc.be.user.UserBusinessLogic; import org.openecomp.sdc.exception.ResponseFormat; -import org.openecomp.sdc.common.datastructure.Wrapper; -import fj.data.Either; -import javassist.CodeConverter.ArrayAccessReplacementMethodNames; -import mockit.Deencapsulation; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.BiPredicate; -import java.util.*; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anySet; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; /** * The test suite designed for test functionality of @@ -219,7 +209,6 @@ public class ComponentInstanceBusinessLogicTest { ComponentTypeEnum containerComponentType = ComponentTypeEnum.findByParamName("services"); String containerComponentID = "Service-comp"; - String componentInstanceID = "NodeA1"; Service component = new Service(); component.addForwardingPath(createPath("path1", "NodeA1", "NodeB1", "1")); @@ -286,10 +275,6 @@ public class ComponentInstanceBusinessLogicTest { } private void getServiceRelationByIdUserValidationFailure(Component component) { - // Either eitherCreator = - // Either.right(ActionStatus.USER_NOT_FOUND); - // when(userAdmin.getUser(eq(USER_ID), - // eq(false))).thenReturn(eitherCreator); when(userValidations.validateUserExists(eq(USER_ID), eq("get relation by Id"), eq(false))) .thenReturn(Either.right(new ResponseFormat(404))); Either response = componentInstanceBusinessLogic diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java index 8597136b3f..9b6b5c00df 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java @@ -20,21 +20,7 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.nio.file.FileSystems; -import java.nio.file.Files; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - +import fj.data.Either; import org.junit.Test; import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum; import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum; @@ -46,7 +32,20 @@ import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.common.api.ArtifactTypeEnum; import org.yaml.snakeyaml.Yaml; -import fj.data.Either; +import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class ImportUtilsTest { @Test @@ -236,26 +235,6 @@ public class ImportUtilsTest { } - // @Test - // public void testCreateFullHeatParameterModuleWithInvalidType(){ - // - // String name = "fullParameter"; - // String description = "description_text"; - // - // Map parametersMap = new HashMap(); - // Map firstParam = createParameterMap("aaa", "aaa", - // name, description); - // parametersMap.put(ToscaTagNamesEnum.PARAMETERS.getElementName(), - // firstParam); - // - // Either,ResultStatusEnum> heatParameters = - // ImportUtils.getHeatParameters(parametersMap); - // assertTrue(heatParameters.isRight()); - // assertEquals(ResultStatusEnum.INVALID_PROPERTY_TYPE, - // heatParameters.right().value()); - // - // } - @Test public void testCreateFullHeatParameterModuleWithMissingType() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java index bc9a1392b7..70cae9bfce 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java @@ -20,31 +20,8 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -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 java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collection; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.servlet.ServletContext; - +import fj.data.Either; +import mockit.Deencapsulation; import org.apache.commons.lang3.tuple.ImmutablePair; import org.junit.Assert; import org.junit.Before; @@ -134,8 +111,29 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import fj.data.Either; -import mockit.Deencapsulation; +import javax.servlet.ServletContext; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyObject; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { @@ -244,17 +242,6 @@ public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { Either eitherCount = Either.left(false); when(toscaOperationFacade.validateComponentNameExists(eq(RESOURCE_NAME), any(ResourceTypeEnum.class), eq(ComponentTypeEnum.RESOURCE))).thenReturn(eitherCount); - /* - * when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, - * ResourceTypeEnum.VF, - * ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount); - * when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, - * ResourceTypeEnum.PNF, - * ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount); - * when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, - * ResourceTypeEnum.CR, - * ComponentTypeEnum.RESOURCE)).thenReturn(eitherCount); - */ when(interfaceOperation.updateInterface(anyString(), anyObject())) .thenReturn(Either.left(mockInterfaceDefinitionToReturn(RESOURCE_NAME))); Either validateDerivedExists = Either.left(true); @@ -421,8 +408,6 @@ public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { assertEquals(resource.getUniqueId(), updateResponse.left().value().getUniqueId()); } - /* CREATE validations - start ***********************/ - // Resource name - start @Test public void testFailedResourceValidations() { @@ -688,24 +673,6 @@ public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { } - private void testTagsSingleExceedsLimit() { - Resource resourceExccedsNameLimit = createResourceObject(false); - String tag1 = "afzs2qLBb5X6tZhiunkcEwiFX1qRQY8YZl3y3Du5M5xeQY5Nq9afcFHDZ9HaURw43gH27nAUWM36bMbMylwTFSzzNV8NO4v4ripe6Q15Vc2nPOFI"; - String tag2 = resourceExccedsNameLimit.getName(); - List tagsList = new ArrayList(); - tagsList.add(tag1); - tagsList.add(tag2); - - resourceExccedsNameLimit.setTags(tagsList); - - Either createResponse = bl.createResource(resourceExccedsNameLimit, - AuditingActionEnum.CREATE_RESOURCE, user, null, null); - assertTrue(createResponse.isRight()); - assertResponse(createResponse, ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT, - "" + ValidationUtils.TAG_MAX_LENGTH); - - } - private void testTagsNoServiceName() { Resource serviceExccedsNameLimit = createResourceObject(false); String tag1 = "afzs2qLBb"; @@ -1612,68 +1579,6 @@ public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { assertTrue(validatePropertiesDefaultValues.isRight()); } - // @Test - // public void testDeleteMarkedResourcesNoResources() { - // List ids = new ArrayList<>(); - // Either, StorageOperationStatus> eitherNoResources = - // Either.left(ids); - // when(topologyTemplateOperation.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources); - // - // Either, ResponseFormat> deleteMarkedResources = - // bl.deleteMarkedComponents(); - // assertTrue(deleteMarkedResources.isLeft()); - // assertTrue(deleteMarkedResources.left().value().isEmpty()); - // - // Mockito.verify(artifactManager, - // Mockito.times(0)).deleteAllComponentArtifactsIfNotOnGraph(Mockito.anyList()); - // - // } - // - // @Test - // public void testDeleteMarkedResources() { - // List ids = new ArrayList(); - // String resourceInUse = "123"; - // ids.add(resourceInUse); - // String resourceFree = "456"; - // ids.add(resourceFree); - // Either, StorageOperationStatus> eitherNoResources = - // Either.left(ids); - // when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources); - // - // Either resourceInUseResponse = - // Either.left(true); - // Either resourceFreeResponse = - // Either.left(false); - // - // List artifacts = new ArrayList(); - // Either, StorageOperationStatus> - // getArtifactsResponse = Either.left(artifacts); - // when(toscaOperationFacade.getComponentArtifactsForDelete(resourceFree, - // NodeTypeEnum.Resource, true)).thenReturn(getArtifactsResponse); - // - // when(toscaOperationFacade.isComponentInUse(resourceFree)).thenReturn(resourceFreeResponse); - // when(toscaOperationFacade.isComponentInUse(resourceInUse)).thenReturn(resourceInUseResponse); - // - // Either eitherDelete = Either.left(new - // Resource()); - // when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete); - // - // when(artifactManager.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK); - // List deletedComponents = new ArrayList<>(); - // deletedComponents.add(resourceFree); - // when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(deletedComponents)); - // - // Either, ResponseFormat> deleteMarkedResources = - // bl.deleteMarkedComponents(); - // assertTrue(deleteMarkedResources.isLeft()); - // List resourceIdList = deleteMarkedResources.left().value(); - // assertFalse(resourceIdList.isEmpty()); - // assertTrue(resourceIdList.contains(resourceFree)); - // assertFalse(resourceIdList.contains(resourceInUse)); - // - // Mockito.verify(artifactManager, - // Mockito.times(1)).deleteAllComponentArtifactsIfNotOnGraph(artifacts); - // } @SuppressWarnings("unchecked") @Test @@ -2456,7 +2361,6 @@ public class ResourceBusinessLogicTest implements InterfaceOperationTestUtils { public void testValidateDerivedFromNotEmpty() throws Exception { ResourceBusinessLogic testSubject; Resource resource = createResourceObject(true); - ; AuditingActionEnum actionEnum = AuditingActionEnum.ADD_ECOMP_USER_CREDENTIALS; Either result; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java index 0c88a37f2b..ab042b4a7d 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceInstanceBusinessLogicTest.java @@ -20,16 +20,7 @@ package org.openecomp.sdc.be.components.impl; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -62,7 +53,15 @@ import org.openecomp.sdc.common.impl.ExternalConfiguration; import org.openecomp.sdc.common.impl.FSConfigurationSource; import org.openecomp.sdc.exception.ResponseFormat; -import fj.data.Either; +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ResourceInstanceBusinessLogicTest { @@ -152,7 +151,6 @@ public class ResourceInstanceBusinessLogicTest { @Before public void initMocks() { MockitoAnnotations.initMocks(this); -// Mockito.reset(artifactBusinessLogic, serviceOperation, componentsUtils, userAdminManager); setup(); } @@ -173,37 +171,9 @@ public class ResourceInstanceBusinessLogicTest { Map deploymentArtifacts = resourceInstance.getDeploymentArtifacts(); assertNotNull(deploymentArtifacts); -// assertTrue(deploymentArtifacts.size() == 2); ArtifactDefinition heatDefinition = deploymentArtifacts.get(HEAT_LABEL.toLowerCase()); assertNotNull(heatDefinition); -// assertEquals(getHeatArtifactDefinition(USER_ID, RESOURCE_ID_WITH_HEAT_PARAMS, HEAT_LABEL, ARTIFACT_CREATION_TIME, false, true), heatDefinition); -// -// ArtifactDefinition heatEnvDefinition = deploymentArtifacts.get(HEAT_ENV_LABEL.toLowerCase()); -// assertNotNull(heatEnvDefinition); -// -// List heatParameters = heatDefinition.getListHeatParameters(); -// assertNotNull(heatParameters); -// -// List heatEnvParameters = heatEnvDefinition.getListHeatParameters(); -// assertNotNull(heatEnvParameters); -// -// assertEquals(heatParameters.size(), heatEnvParameters.size()); -// -// int index = 0; -// for (HeatParameterDefinition heatEnvParameter : heatEnvParameters) { -// HeatParameterDefinition heatParameterDefinition = heatParameters.get(index); -// assertEquals(heatEnvParameter.getUniqueId(), heatParameterDefinition.getUniqueId()); -// assertEquals(heatEnvParameter.getType(), heatParameterDefinition.getType()); -// assertEquals(heatEnvParameter.getName(), heatParameterDefinition.getName()); -// assertEquals(heatEnvParameter.getDescription(), heatParameterDefinition.getDescription()); -// assertEquals(heatEnvParameter.getCurrentValue(), heatParameterDefinition.getCurrentValue()); -// // current of heat parameter should be the default for heat env -// // parameter -// assertEquals(heatEnvParameter.getDefaultValue(), heatParameterDefinition.getCurrentValue()); -// -// index++; -// } } @Test @@ -222,21 +192,13 @@ public class ResourceInstanceBusinessLogicTest { Map deploymentArtifacts = resourceInstance.getDeploymentArtifacts(); assertNotNull(deploymentArtifacts); -// assertTrue(deploymentArtifacts.size() == 2); ArtifactDefinition heatDefinition = deploymentArtifacts.get(HEAT_LABEL.toLowerCase()); assertNotNull(heatDefinition); -// assertEquals(getHeatArtifactDefinition(USER_ID, RESOURCE_ID_NO_HEAT_PARAMS, HEAT_LABEL, ARTIFACT_CREATION_TIME, false, false), heatDefinition); - -// ArtifactDefinition heatEnvDefinition = deploymentArtifacts.get(HEAT_ENV_LABEL.toLowerCase()); -// assertNotNull(heatEnvDefinition); List heatParameters = heatDefinition.getListHeatParameters(); assertNull(heatParameters); -// List heatEnvParameters = heatEnvDefinition.getListHeatParameters(); -// assertNull(heatEnvParameters); - } @SuppressWarnings("unchecked") @@ -273,7 +235,6 @@ public class ResourceInstanceBusinessLogicTest { artifactInfo.setUserIdCreator(userId); String fullName = "Jim H"; artifactInfo.setUpdaterFullName(fullName); - // long time = System.currentTimeMillis(); artifactInfo.setCreatorFullName(fullName); artifactInfo.setCreationDate(time); artifactInfo.setLastUpdateDate(time); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java index 495483a857..981abb0f08 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CertificationRequestTest.java @@ -20,13 +20,7 @@ package org.openecomp.sdc.be.components.lifecycle; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; - +import fj.data.Either; import org.apache.http.HttpStatus; import org.junit.Before; import org.junit.Test; @@ -54,7 +48,12 @@ import org.openecomp.sdc.be.tosca.ToscaExportHandler; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import fj.data.Either; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.Silent.class) public class CertificationRequestTest extends LifecycleTestBase { @@ -75,14 +74,7 @@ public class CertificationRequestTest extends LifecycleTestBase { public void setup() { super.setup(); rfcObj = new CertificationRequestTransition(componentsUtils, toscaElementLifecycleOperation, serviceDistributionArtifactsBuilder, serviceBusinessLogic, capabilityOperation, toscaExportUtils, toscaOperationFacade, titanDao); - // checkout transition object -// rfcObj.setLifeCycleOperation(toscaElementLifecycleOperation); - // checkoutObj.setAuditingManager(iAuditingManager); rfcObj.setConfigurationManager(configurationManager); - -// Either either = Either.left(toscaRepresentation); -// when(toscaExportUtils.exportComponent(Mockito.any())).thenReturn(either); - } @Test @@ -114,14 +106,10 @@ public class CertificationRequestTest extends LifecycleTestBase { Either ownerResponse = rfcObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); assertTrue(ownerResponse.isLeft()); User owner = ownerResponse.left().value(); - // changeStateResult = rfcObj.changeStateOperation(resource, user, - // owner, false); changeStateResult = rfcObj.changeState(ComponentTypeEnum.RESOURCE, resource, serviceBusinessLogic, user, owner, false, false); assertEquals(changeStateResult.isLeft(), true); resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - // changeStateResult = rfcObj.changeStateOperation(resource, user, - // owner, false); changeStateResult = rfcObj.changeState(ComponentTypeEnum.RESOURCE, resource, serviceBusinessLogic, user, owner, false, false); assertEquals(changeStateResult.isLeft(), true); } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java index 14cbcc80d7..97e6992ae8 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTest.java @@ -20,9 +20,7 @@ package org.openecomp.sdc.be.components.lifecycle; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -36,7 +34,8 @@ import org.openecomp.sdc.be.model.User; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.exception.ResponseFormat; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class CheckoutTest extends LifecycleTestBase { @@ -124,8 +123,6 @@ public class CheckoutTest extends LifecycleTestBase { Either ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); assertTrue(ownerResponse.isLeft()); User owner = ownerResponse.left().value(); - // changeStateResult = checkoutObj.changeStateOperation(resource, user, - // owner); Either validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, user, owner, LifecycleStateEnum.READY_FOR_CERTIFICATION); assertEquals(validateBeforeTransition.isLeft(), true); @@ -137,8 +134,6 @@ public class CheckoutTest extends LifecycleTestBase { // admin modifier.setRole(Role.ADMIN.name()); - // changeStateResult = checkoutObj.changeStateOperation(resource, user, - // owner); validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, modifier, owner, LifecycleStateEnum.READY_FOR_CERTIFICATION); assertEquals(validateBeforeTransition.isLeft(), true); @@ -168,14 +163,10 @@ public class CheckoutTest extends LifecycleTestBase { Either ownerResponse = checkoutObj.getComponentOwner(resource, ComponentTypeEnum.RESOURCE); assertTrue(ownerResponse.isLeft()); User owner = ownerResponse.left().value(); - // changeStateResult = checkoutObj.changeStateOperation(resource, - // modifier, owner); Either validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, modifier, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertEquals(validateBeforeTransition.isLeft(), true); modifier.setRole(Role.TESTER.name()); - // changeStateResult = checkoutObj.changeStateOperation(resource, - // modifier, owner); validateBeforeTransition = checkoutObj.validateBeforeTransition(resource, ComponentTypeEnum.RESOURCE, modifier, owner, LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertEquals(validateBeforeTransition.isRight(), true); changeStateResult = Either.right(validateBeforeTransition.right().value()); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java index d2903f5f11..922c9afa33 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java @@ -20,13 +20,7 @@ package org.openecomp.sdc.be.components.lifecycle; -import static org.mockito.Mockito.when; - -import java.util.ArrayList; -import java.util.List; - -import javax.servlet.ServletContext; - +import fj.data.Either; import org.junit.BeforeClass; import org.mockito.InjectMocks; import org.mockito.Mockito; @@ -67,7 +61,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.context.WebApplicationContext; -import fj.data.Either; +import javax.servlet.ServletContext; +import java.util.ArrayList; +import java.util.List; + +import static org.mockito.Mockito.when; public class LifecycleTestBase { private static final Logger log = LoggerFactory.getLogger(LifecycleTestBase.class); @@ -101,14 +99,6 @@ public class LifecycleTestBase { public void setup() { -// ExternalConfiguration.setAppName("catalog-be"); -// -// // init Configuration -// String appConfigDir = "src/test/resources/config/catalog-be"; -// ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir); -// configurationManager = new ConfigurationManager(configurationSource); - - // User data and management user = new User(); user.setUserId("jh003"); @@ -126,9 +116,6 @@ public class LifecycleTestBase { when(webAppContext.getBean(ToscaElementLifecycleOperation.class)).thenReturn(toscaElementLifecycleOperation); when(webAppContext.getBean(ArtifactsBusinessLogic.class)).thenReturn(artifactsManager); - // Resource Operation mock methods - // getCount - // createResource resourceResponse = createResourceObject(); Either eitherComponent = Either.left(ModelConverter.convertToToscaElement(resourceResponse)); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentCapabilitiesPropertiesMergeBLTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentCapabilitiesPropertiesMergeBLTest.java index aac50a3638..817aa5dde3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentCapabilitiesPropertiesMergeBLTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/merge/instance/ComponentCapabilitiesPropertiesMergeBLTest.java @@ -1,10 +1,6 @@ package org.openecomp.sdc.be.components.merge.instance; -import static org.mockito.Mockito.when; - -import java.util.Arrays; -import java.util.List; - +import fj.data.Either; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -23,7 +19,10 @@ import org.openecomp.sdc.be.model.ComponentParametersView; import org.openecomp.sdc.be.model.Resource; import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade; -import fj.data.Either; +import java.util.Arrays; +import java.util.List; + +import static org.mockito.Mockito.when; public class ComponentCapabilitiesPropertiesMergeBLTest { @@ -51,17 +50,13 @@ public class ComponentCapabilitiesPropertiesMergeBLTest { @Test public void testDescription() throws Exception { - // ComponentCapabilitiesPropertiesMergeBL testSubject; String result; - // default test - // testSubject = createTestSubject(); result = testSubject.description(); } @Test public void testMergeComponents() throws Exception { - // ComponentCapabilitiesPropertiesMergeBL testSubject; Component prevComponent = ObjectGenerator.buildResourceWithComponentInstance("mock3"); Component currentComponent = ObjectGenerator.buildResourceWithComponentInstance("mock1", "mock2"); currentComponent.setUniqueId("mock"); @@ -75,7 +70,6 @@ public class ComponentCapabilitiesPropertiesMergeBLTest { @Test public void testMergeComponentInstanceCapabilities() throws Exception { - // ComponentCapabilitiesPropertiesMergeBL testSubject; Component currentComponent = null; Component origInstanceCmpt = null; String instanceId = ""; @@ -83,8 +77,6 @@ public class ComponentCapabilitiesPropertiesMergeBLTest { List prevInstanceCapabilities = null; ActionStatus result; - // default test - // testSubject = createTestSubject(); result = testSubject.mergeComponentInstanceCapabilities(currentComponent, origInstanceCmpt, instanceId, prevInstanceCapabilities); diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java index 1182136d6c..5253550591 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/BaseForwardingPathTest.java @@ -1,12 +1,7 @@ package org.openecomp.sdc.be.components.path; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - +import com.google.common.collect.Lists; +import fj.data.Either; import org.junit.Before; import org.openecomp.sdc.be.components.BeConfDependentTest; import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic; @@ -40,9 +35,12 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.beans.factory.annotation.Autowired; -import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; -import fj.data.Either; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; public class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils { @@ -187,23 +185,6 @@ public class BaseForwardingPathTest extends BeConfDependentTest implements Forwa Either serviceCreateResult = bl.createService(createTestService(), user); assertTrue("Failed to create service", serviceCreateResult.isLeft()); Service service = serviceCreateResult.left().value(); -// ComponentInstance componentInstance = new ComponentInstance(); -// componentInstance.setName("Test1"); -// componentInstance.setNormalizedName("Test1"); -// componentInstance.setUniqueId("Test1"); -// componentInstance.setInputValueCounter(1); -// componentInstance.setAttributeValueCounter(1); -// componentInstance.setIcon("network"); -// componentInstance.setComponentVersion("1.0"); -// componentInstance.setIsProxy(true); -// componentInstance.setComponentUid(service.getUniqueId()); -// componentInstance.setPropertyValueCounter(1); -// componentInstance.setPosX("333"); -// componentInstance.setPosY("333"); -// componentInstance.setOriginType(OriginTypeEnum.VF); -// -// Either instanceResult = serviceComponentInstanceBusinessLogic.createComponentInstance("services", service.getUniqueId(), user.getUserId(), componentInstance); -// assertTrue("Failed to create instance", instanceResult.isLeft()); return service; } } diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java index 0e564c1249..438a21a5a3 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/datamodel/utils/ArtifactUtilsTest.java @@ -1,16 +1,15 @@ package org.openecomp.sdc.be.datamodel.utils; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.junit.Assert; import org.junit.Test; import org.openecomp.sdc.be.info.ArtifactTemplateInfo; import org.openecomp.sdc.be.model.ArtifactDefinition; import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + public class ArtifactUtilsTest { private ArtifactUtils createTestSubject() { @@ -46,12 +45,6 @@ public class ArtifactUtilsTest { artifactId = null; result = ArtifactUtils.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType, label, displayName, description, artifactContentent, updatedRequiredArtifacts, isFromCsar); - - // test 2 - /*artifactId = ""; - result = ArtifactUtils.buildJsonForUpdateArtifact(artifactId, artifactName, artifactType, artifactGroupType, - label, displayName, description, artifactContentent, updatedRequiredArtifacts, isFromCsar); - Assert.assertEquals(null, result);*/ } @Test diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java index f01ff0db4c..0700a19aa7 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/ecomp/EcompIntImplTest.java @@ -83,18 +83,6 @@ public class EcompIntImplTest { result = testSubject.getAvailableRoles(); } - /*@Test - public void testPushUserRole() throws Exception { - EcompIntImpl testSubject; - String loginId = ""; - List roles = null; - - // test 1 - testSubject = createTestSubject(); - roles = null; - testSubject.pushUserRole(loginId, roles); - }*/ - @Test(expected=PortalAPIException.class) public void testGetUserRoles() throws Exception { EcompIntImpl testSubject; diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java deleted file mode 100644 index 414ffaad59..0000000000 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupEndpointTest.java +++ /dev/null @@ -1,179 +0,0 @@ -//package org.openecomp.sdc.be.servlets; -// -//import com.fasterxml.jackson.databind.DeserializationFeature; -//import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; -//import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; -//import fj.data.Either; -//import org.eclipse.jetty.http.HttpStatus; -//import org.glassfish.hk2.utilities.binding.AbstractBinder; -//import org.glassfish.jersey.client.ClientConfig; -//import org.glassfish.jersey.server.ResourceConfig; -//import org.glassfish.jersey.test.JerseyTest; -//import org.glassfish.jersey.test.TestProperties; -//import org.junit.Before; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.mockito.Mock; -//import org.mockito.junit.MockitoJUnitRunner; -//import org.openecomp.sdc.be.DummyConfigurationManager; -//import org.openecomp.sdc.be.components.impl.GroupBusinessLogic; -//import org.openecomp.sdc.be.dao.api.ActionStatus; -//import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; -//import org.openecomp.sdc.be.impl.ComponentsUtils; -//import org.openecomp.sdc.be.impl.ServletUtils; -//import org.openecomp.sdc.be.impl.WebAppContextWrapper; -//import org.openecomp.sdc.be.info.GroupDefinitionInfo; -//import org.openecomp.sdc.be.model.GroupDefinition; -//import org.openecomp.sdc.common.api.Constants; -//import org.openecomp.sdc.exception.ResponseFormat; -//import org.springframework.web.context.WebApplicationContext; -// -//import javax.servlet.ServletContext; -//import javax.servlet.http.HttpServletRequest; -//import javax.servlet.http.HttpSession; -//import javax.ws.rs.client.ClientBuilder; -//import javax.ws.rs.client.Invocation; -//import javax.ws.rs.core.Application; -//import javax.ws.rs.core.MediaType; -//import javax.ws.rs.core.Response; -// -//import static org.assertj.core.api.Assertions.assertThat; -//import static org.junit.Assert.assertEquals; -//import static org.mockito.ArgumentMatchers.*; -//import static org.mockito.Mockito.when; -// -//@RunWith(MockitoJUnitRunner.class) -//public class GroupEndpointTest extends JerseyTest { -// -// public static final String USER_ID = "jh0003"; -// public static final String INVALID_USER_ID = "jh0001"; -// final static String RESOURCE_TYPE = "resources"; -// private static final String COMPONENT_ID = "1234"; -// private static final String VALID_GROUP_ID = "1"; -// private static final String INVALID_GROUP_ID = "2"; -// private static final String NEW_GROUP_NAME = "new group"; -// private static final String VALID_GROUP_TYPE = "networkConnection"; -// -// @Mock -// private GroupBusinessLogic groupBusinessLogic; -// @Mock -// private ServletContext servletContext; -// @Mock -// private WebAppContextWrapper webAppContextWrapper; -// @Mock -// private WebApplicationContext webApplicationContext; -// @Mock -// private HttpServletRequest request; -// @Mock -// private HttpSession session; -// @Mock -// private ComponentsUtils componentUtils; -// @Mock -// private ServletUtils servletUtils; -// @Mock -// private ResponseFormat responseFormat; -// -// @Override -// protected Application configure() { -// ResourceConfig resourceConfig = new ResourceConfig() -// .register(GroupServlet.class) -// //.register(mapper) -// ; -// forceSet(TestProperties.CONTAINER_PORT, "0"); -// resourceConfig.register(new AbstractBinder() { -// @Override -// protected void configure() { -// bind(request).to(HttpServletRequest.class); -// } -// }); -// return resourceConfig; -// } -// -// @Before -// public void before() { -// when(request.getSession()).thenReturn(session); -// when(session.getServletContext()).thenReturn(servletContext); -// when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper); -// when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webApplicationContext); -// when(webApplicationContext.getBean(GroupBusinessLogic.class)).thenReturn(groupBusinessLogic); -//// when(webApplicationContext.getBean(ComponentsUtils.class)).thenReturn(componentUtils); -// when(webApplicationContext.getBean(ServletUtils.class)).thenReturn(servletUtils); -// when(servletUtils.getComponentsUtils()).thenReturn(componentUtils); -//// when(request.getHeader("USER_ID")).thenReturn(USER_ID); -// final JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); -// setClient(ClientBuilder.newClient(new ClientConfig(jacksonJsonProvider))); -// new DummyConfigurationManager(); -//// when(ConfigurationManager.getConfigurationManager().getConfiguration().getExcludedGroupTypesMapping()).thenReturn(buildExcludePolicyTypesMap()); -// } -// -// //@Test -// public void createGroup() { -// GroupDefinition groupDefinition = new GroupDefinition(); -// groupDefinition.setName(NEW_GROUP_NAME); -// groupDefinition.setType(VALID_GROUP_TYPE); -// when(groupBusinessLogic.createGroup(eq(NEW_GROUP_NAME), eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(USER_ID))) -// .thenReturn(groupDefinition); -// //List gdList = buildCreateGroupCall().post(Response.class); -// -// } -// -// //@Test -// public void deleteGroup_withInvalidUser_shouldReturn_401() { -// int unauthorized401 = HttpStatus.UNAUTHORIZED_401; -// int unauthorized403 = HttpStatus.FORBIDDEN_403; -// when(groupBusinessLogic.validateUserExists(eq(INVALID_USER_ID), anyString(), anyBoolean())) -// .thenReturn(Either.right(new ResponseFormat(unauthorized401))); -// -// Response response = buildDeleteGroupCall(INVALID_USER_ID, VALID_GROUP_ID).delete(); -// assertThat(response.getStatus()).isEqualTo(unauthorized401); -// } -// -// @Test -// public void getGroupById_internalServerError() { -// when(groupBusinessLogic.getGroupWithArtifactsById(eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(VALID_GROUP_ID), eq(USER_ID), eq(false) )) -// .thenReturn(Either.right(new ResponseFormat(HttpStatus.INTERNAL_SERVER_ERROR_500))); -// Response response = buildGetGroupCall(VALID_GROUP_ID).get(); -// assertEquals(response.getStatus(), 500); -// } -// -// @Test -// public void getGroupById_Success() { -// GroupDefinitionInfo groupDefinitionInfo = new GroupDefinitionInfo(); -// groupDefinitionInfo.setUniqueId(VALID_GROUP_ID); -// when(groupBusinessLogic.getGroupWithArtifactsById(eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(VALID_GROUP_ID), eq(USER_ID), eq(false) )) -// .thenReturn(Either.left(groupDefinitionInfo)); -// when(componentUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat); -// when(responseFormat.getStatus()).thenReturn(HttpStatus.OK_200); -// GroupDefinitionInfo gdi = buildGetGroupCall(VALID_GROUP_ID).get(GroupDefinitionInfo.class); -// assertEquals(gdi.getUniqueId(), VALID_GROUP_ID); -// } -// -// @Test -// public void getGroupById_Failure() { -// when(groupBusinessLogic.getGroupWithArtifactsById(eq(ComponentTypeEnum.RESOURCE), eq(COMPONENT_ID), eq(INVALID_GROUP_ID), eq(USER_ID), eq(false) )) -// .thenReturn(Either.right(new ResponseFormat(HttpStatus.NOT_FOUND_404))); -// Response response = buildGetGroupCall(INVALID_GROUP_ID).get(); -// assertEquals(response.getStatus(), 404); -// } -// -// private Invocation.Builder buildGetGroupCall(String groupId) { -// String path = "/v1/catalog/" + RESOURCE_TYPE + "/" + COMPONENT_ID + "/groups/" + groupId; -// return target(path) -// .request(MediaType.APPLICATION_JSON) -// .header(Constants.USER_ID_HEADER, USER_ID); -// } -// -// private Invocation.Builder buildDeleteGroupCall(String userId, String groupId) { -// String path = "/v1/catalog/" + RESOURCE_TYPE + "/" + COMPONENT_ID + "/groups/" + groupId; -// return target(path) -// .request(MediaType.APPLICATION_JSON) -// .header(Constants.USER_ID_HEADER, userId); -// } -// -// private Invocation.Builder buildCreateGroupCall() { -// String path = "/v1/catalog/" + RESOURCE_TYPE + "/" + COMPONENT_ID + "/groups"; -// return target(path) -// .request(MediaType.APPLICATION_JSON) -// .header(Constants.USER_ID_HEADER, USER_ID); -// } -//} diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java index 39a541d568..2d30616ebb 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/GroupTypesEndpointTest.java @@ -1,31 +1,15 @@ package org.openecomp.sdc.be.servlets; -import static java.util.Arrays.asList; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -import javax.ws.rs.client.Invocation; -import javax.ws.rs.core.GenericType; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Sets; +import fj.data.Either; import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider; import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider; import org.glassfish.jersey.server.ResourceConfig; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.openecomp.sdc.be.DummyConfigurationManager; import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic; @@ -33,26 +17,32 @@ import org.openecomp.sdc.be.components.impl.ResponseFormatManager; import org.openecomp.sdc.be.components.utils.GroupTypeBuilder; import org.openecomp.sdc.be.components.validation.UserValidations; import org.openecomp.sdc.be.config.ConfigurationManager; -import org.openecomp.sdc.be.dao.api.ActionStatus; import org.openecomp.sdc.be.dao.jsongraph.TitanDao; import org.openecomp.sdc.be.impl.ComponentsUtils; import org.openecomp.sdc.be.model.GroupTypeDefinition; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.operations.StorageException; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation; import org.openecomp.sdc.common.api.Constants; -import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; -import org.springframework.http.HttpStatus; -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Sets; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.core.GenericType; +import javax.ws.rs.core.MediaType; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; -import fj.data.Either; +import static java.util.Arrays.asList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyBoolean; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class GroupTypesEndpointTest extends JerseySpringBaseTest { @@ -130,23 +120,6 @@ public class GroupTypesEndpointTest extends JerseySpringBaseTest { verifyGroupTypesList(testConfigGroupTypes, fetchedGroupTypes); } - @Ignore - public void getGroupTypes_dbError() { - when(groupTypeOperation.getAllGroupTypes(EXCLUDED_TYPES)).thenThrow(new StorageException(StorageOperationStatus.NOT_FOUND)); - when(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND)).thenReturn(ActionStatus.RESOURCE_NOT_FOUND); - when(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND)).thenReturn(new ResponseFormat(HttpStatus.NOT_FOUND.value())); - Response response = buildGetGroupTypesCall(USER_ID).get(); - assertThat(response.getStatus()).isEqualTo(HttpStatus.NOT_FOUND.value()); - } - - // TODO: simulate proper error with configuration error mapping and eactivate the test - @Ignore - public void getGroupTypes_invalidUser_Failure() { - when(groupTypeOperation.getAllGroupTypes(EXCLUDED_TYPES)).thenReturn(buildGroupTypesList()); - Response response = buildGetGroupTypesCall(INVALID_USER_ID).get(); - assertThat(response.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST.value()); - } - private void verifyGroupTypesList(List groupTypes, List fetchedGroupTypes) { assertThat(fetchedGroupTypes) .usingElementComparatorOnFields("version", "type", "uniqueId") diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java index 3e6f934bfc..af08992252 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/UserAdminServletTest.java @@ -20,17 +20,8 @@ package org.openecomp.sdc.be.servlets; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; - -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.ws.rs.core.Application; - +import com.google.gson.Gson; +import fj.data.Either; import org.glassfish.hk2.utilities.binding.AbstractBinder; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; @@ -50,9 +41,16 @@ import org.openecomp.sdc.exception.ResponseFormat; import org.springframework.http.HttpStatus; import org.springframework.web.context.WebApplicationContext; -import com.google.gson.Gson; +import javax.servlet.ServletContext; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import javax.ws.rs.core.Application; -import fj.data.Either; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.when; public class UserAdminServletTest extends JerseyTest { @@ -95,29 +93,6 @@ public class UserAdminServletTest extends JerseyTest { when(request.getHeader("USER_ID")).thenReturn(ADMIN_ATT_UID); } - /* - * @Test public void deactivateUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID); Either eitherActiveUser = buildEitherUser(userToDeleteUserId, true); - * User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId); - * - * Either eitherInactiveUser = buildEitherUser(userToDeleteUserId, false); doReturn(eitherInactiveUser).when(userAdminManager).deActivateUser( adminUser, userToDelete.getUserId()); - * - * - * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(1)).deActivateUser(adminUser, userToDelete.getUserId()); } - * - * - * @Test public void forceDeleteUserSuccessfullyTest(){ String userToDeleteUserId = "admin1"; when(request.getHeader(User.FORCE_DELETE_HEADER_FLAG)).thenReturn(User. FORCE_DELETE_HEADER_FLAG); - * - * User adminUser = new User(); adminUser.setUserId(ADMIN_ATT_UID); - * - * Either eitherActiveUser = buildEitherUser(userToDeleteUserId, true); User userToDelete = eitherActiveUser.left().value(); doReturn(eitherActiveUser).when(userAdminManager).getUser( userToDeleteUserId); - * - * Either eitherUser = buildEitherUser(userToDeleteUserId, true); doReturn(eitherUser).when(userAdminManager).deleteUser(userToDelete. getUserId()); - * - * - * Response response = target().path("/v1/user/"+userToDeleteUserId).request().delete(); assertTrue(response.getStatus() == HttpStatus.OK.value()); verify(userAdminManager, times(0)).deActivateUser(adminUser, userToDelete.getUserId()); - * verify(userAdminManager, times(1)).deleteUser(userToDelete.getUserId()); } - */ - @Override protected Application configure() { diff --git a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java index 0a65a51890..52d7db901e 100644 --- a/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java +++ b/catalog-be/src/test/java/org/openecomp/sdc/common/transaction/mngr/SdncTransactionTest.java @@ -20,12 +20,7 @@ package org.openecomp.sdc.common.transaction.mngr; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - +import fj.data.Either; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -51,7 +46,11 @@ import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionCode import org.openecomp.sdc.common.transaction.api.TransactionUtils.TransactionStatusEnum; import org.slf4j.Logger; -import fj.data.Either; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.reset; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class SdncTransactionTest { private static ESCatalogDAO esCatalogDao = Mockito.mock(ESCatalogDAO.class); @@ -119,9 +118,6 @@ public class SdncTransactionTest { TransactionCodeEnum finishTransaction = tx.finishTransaction(); assertTrue(finishTransaction == TransactionCodeEnum.TRANSACTION_CLOSED); - // verify(log).error(LogMessages.COMMIT_ON_CLOSED_TRANSACTION, - // transactionId, TransactionStatusEnum.CLOSED.name(), - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.COMMIT_ON_CLOSED_TRANSACTION, transactionId, TransactionStatusEnum.CLOSED.name(), TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); assertTrue(tx.getStatus() == TransactionStatusEnum.CLOSED); @@ -136,9 +132,6 @@ public class SdncTransactionTest { assertTrue(doBasicTitanAction.isRight()); assertTrue(tx.getStatus() != TransactionStatusEnum.OPEN); verify(log).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.DOUBLE_FINISH_FLAG_ACTION, transactionId, DBTypeEnum.TITAN.name(), TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); - // verify(log).error( LogMessages.DOUBLE_FINISH_FLAG_ACTION, - // transactionId, DBTypeEnum.TITAN.name(), TransactionUtils.DUMMY_USER, - // ActionTypeEnum.ADD_ARTIFACT.name()); } @Test @@ -161,9 +154,6 @@ public class SdncTransactionTest { assertTrue(eitherGeneralDBAction.right().value() == TransactionCodeEnum.TRANSACTION_CLOSED); assertTrue(tx.getStatus() == TransactionStatusEnum.CLOSED); - // verify(log, times(3)).error(LogMessages.ACTION_ON_CLOSED_TRANSACTION, - // transactionId, TransactionUtils.DUMMY_USER, - // ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(3)).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.ACTION_ON_CLOSED_TRANSACTION, transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); } @@ -198,9 +188,6 @@ public class SdncTransactionTest { assertTrue(eitherTransactionResult.isRight()); assertTrue(eitherTransactionResult.right().value() == TransactionCodeEnum.ROLLBACK_SUCCESS); assertTrue(tx.getStatus() == TransactionStatusEnum.CLOSED); - // verify(log).error(LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, - // DBTypeEnum.TITAN.name(), transactionId, crushMessage, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, DBTypeEnum.TITAN.name(), transactionId, crushMessage, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(1)).debug(LogMessages.ROLLBACK_PERSISTENT_ACTION, DBTypeEnum.ELASTIC_SEARCH.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); @@ -227,9 +214,6 @@ public class SdncTransactionTest { assertTrue(eitherTransactionResult.isRight()); assertTrue(tx.getStatus() == TransactionStatusEnum.FAILED_ROLLBACK); assertTrue(eitherTransactionResult.right().value() == TransactionCodeEnum.ROLLBACK_FAILED); - // verify(log).error(LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, - // DBTypeEnum.TITAN.name(), transactionId, crushMessage, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, DBTypeEnum.TITAN.name(), transactionId, crushMessage, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(1)).debug(LogMessages.ROLLBACK_PERSISTENT_ACTION, DBTypeEnum.ELASTIC_SEARCH.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); @@ -237,13 +221,6 @@ public class SdncTransactionTest { verify(log, times(1)).debug(LogMessages.ROLLBACK_NON_PERSISTENT_ACTION, DBTypeEnum.TITAN.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(1)).debug(TransactionUtils.TRANSACTION_MARKER, LogMessages.ROLLBACK_NON_PERSISTENT_ACTION, DBTypeEnum.TITAN.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); - - // verify(log, times(1)).error(LogMessages.ROLLBACK_FAILED_GENERAL, - // transactionId, TransactionUtils.DUMMY_USER, - // ActionTypeEnum.ADD_ARTIFACT.name()); - // verify(log, times(1)).error(TransactionUtils.TRANSACTION_MARKER, - // LogMessages.ROLLBACK_FAILED_GENERAL, transactionId, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); } @Test @@ -291,21 +268,6 @@ public class SdncTransactionTest { verify(log, times(1)).debug(LogMessages.ROLLBACK_NON_PERSISTENT_ACTION, DBTypeEnum.TITAN.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(1)).debug(TransactionUtils.TRANSACTION_MARKER, LogMessages.ROLLBACK_NON_PERSISTENT_ACTION, DBTypeEnum.TITAN.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); - - // verify(log).error(LogMessages.ROLLBACK_FAILED_ON_DB_WITH_EXCEPTION, - // transactionId, DBTypeEnum.ELASTIC_SEARCH.name(), esError, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); - // verify(log).error(TransactionUtils.TRANSACTION_MARKER, - // LogMessages.ROLLBACK_FAILED_ON_DB_WITH_EXCEPTION, transactionId, - // DBTypeEnum.ELASTIC_SEARCH.name(), esError, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); - - // verify(log, times(1)).error(LogMessages.ROLLBACK_FAILED_GENERAL, - // transactionId, TransactionUtils.DUMMY_USER, - // ActionTypeEnum.ADD_ARTIFACT.name()); - // verify(log, times(1)).error(TransactionUtils.TRANSACTION_MARKER, - // LogMessages.ROLLBACK_FAILED_GENERAL, transactionId, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); } @Test @@ -328,9 +290,6 @@ public class SdncTransactionTest { assertTrue(eitherResult.right().value() == TransactionCodeEnum.ROLLBACK_SUCCESS); assertTrue(tx.getStatus() == TransactionStatusEnum.CLOSED); - // verify(log).error(LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, - // DBTypeEnum.MYSTERY.name(), transactionId, crushMessage, - // TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log).info(TransactionUtils.TRANSACTION_MARKER, LogMessages.DB_ACTION_FAILED_WITH_EXCEPTION, DBTypeEnum.MYSTERY.name(), transactionId, crushMessage, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); verify(log, times(2)).debug(LogMessages.ROLLBACK_PERSISTENT_ACTION, DBTypeEnum.MYSTERY.name(), transactionId, TransactionUtils.DUMMY_USER, ActionTypeEnum.ADD_ARTIFACT.name()); @@ -390,7 +349,6 @@ public class SdncTransactionTest { private ESArtifactData createDummyArtifactData() { String strData = "qweqwqweqw34e4wrwer"; - String myNodeType = "MyNewNodeType"; ESArtifactData arData = new ESArtifactData("artifactNewMarina11", strData.getBytes()); return arData; } -- cgit 1.2.3-korg