summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src/test')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/TestSuite.java12
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java66
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java1109
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java308
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java89
5 files changed, 1229 insertions, 355 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/TestSuite.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/TestSuite.java
new file mode 100644
index 0000000000..712e16d97a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/TestSuite.java
@@ -0,0 +1,12 @@
+package org.openecomp.sdc.be.components.distribution.engine;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses(
+
+{ DistributionEngineInitTaskTest.class, DistributionEngineConfigTest.class, DistributionEngineHealthCheckTest.class,
+ VfModuleArtifactPayloadTest.class })
+public class TestSuite { // nothing
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
new file mode 100644
index 0000000000..1bc8c47f8c
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayloadTest.java
@@ -0,0 +1,66 @@
+package org.openecomp.sdc.be.components.distribution.engine;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.annotation.Generated;
+
+import org.junit.Test;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupInstance;
+import org.openecomp.sdc.be.model.GroupInstanceProperty;
+
+
+public class VfModuleArtifactPayloadTest {
+
+ private VfModuleArtifactPayload createTestSubject() {
+ return new VfModuleArtifactPayload(new GroupDefinition());
+ }
+
+
+
+
+ @Test
+ public void testGetArtifacts() throws Exception {
+ VfModuleArtifactPayload testSubject;
+ List<String> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getArtifacts();
+ }
+
+
+ @Test
+ public void testSetArtifacts() throws Exception {
+ VfModuleArtifactPayload testSubject;
+ List<String> artifacts = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setArtifacts(artifacts);
+ }
+
+
+ @Test
+ public void testGetProperties() throws Exception {
+ VfModuleArtifactPayload testSubject;
+ Map<String, Object> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getProperties();
+ }
+
+
+ @Test
+ public void testSetProperties() throws Exception {
+ VfModuleArtifactPayload testSubject;
+ List<GroupInstanceProperty> properties = new ArrayList<>();
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setProperties(properties);
+ }
+} \ No newline at end of file
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 c47400bcdb..796a426e26 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,7 +20,10 @@
package org.openecomp.sdc.be.components.impl;
-import static org.junit.Assert.*;
+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.Mockito.when;
import java.lang.reflect.Method;
@@ -29,11 +32,14 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.servlet.ServletContext;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -50,25 +56,42 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
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.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentMetadataDefinition;
+import org.openecomp.sdc.be.model.CsarInfo;
import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupProperty;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
+import org.openecomp.sdc.be.model.NodeTypeInfo;
+import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.UploadCapInfo;
+import org.openecomp.sdc.be.model.UploadComponentInstanceInfo;
+import org.openecomp.sdc.be.model.UploadReqInfo;
+import org.openecomp.sdc.be.model.UploadResourceInfo;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+import org.openecomp.sdc.be.model.category.CategoryDefinition;
+import org.openecomp.sdc.be.model.category.SubCategoryDefinition;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
+import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.ICapabilityTypeOperation;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
@@ -79,12 +102,15 @@ import org.openecomp.sdc.be.model.operations.impl.GraphLockOperation;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
+import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
+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.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.openecomp.sdc.common.util.GeneralUtility;
@@ -94,6 +120,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
+import com.att.nsa.cambria.test.support.CambriaBatchingPublisherMock.Entry;
+
import fj.data.Either;
public class ResourceBusinessLogicTest {
@@ -107,10 +135,10 @@ public class ResourceBusinessLogicTest {
public static final String UPDATED_SUBCATEGORY = "Gateway";
public static final String RESOURCE_NAME = "My-Resource_Name with space";
- private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
- private static final String GENERIC_VFC_NAME = "org.openecomp.resource.abstract.nodes.VFC";
- private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
-
+ private static final String GENERIC_VF_NAME = "org.openecomp.resource.abstract.nodes.VF";
+ private static final String GENERIC_VFC_NAME = "org.openecomp.resource.abstract.nodes.VFC";
+ private static final String GENERIC_PNF_NAME = "org.openecomp.resource.abstract.nodes.PNF";
+
final ServletContext servletContext = Mockito.mock(ServletContext.class);
IAuditingManager iAuditingManager = null;
IElementOperation mockElementDao;
@@ -157,7 +185,8 @@ public class ResourceBusinessLogicTest {
// Init Configuration
String appConfigDir = "src/test/resources/config/catalog-be";
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+ appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
// Elements
@@ -175,30 +204,38 @@ public class ResourceBusinessLogicTest {
// Servlet Context attributes
when(servletContext.getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).thenReturn(configurationManager);
- when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR)).thenReturn(webAppContextWrapper);
+ when(servletContext.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR))
+ .thenReturn(webAppContextWrapper);
when(webAppContextWrapper.getWebAppContext(servletContext)).thenReturn(webAppContext);
when(webAppContext.getBean(IElementOperation.class)).thenReturn(mockElementDao);
Either<Integer, StorageOperationStatus> eitherCountRoot = Either.left(1);
Either<Boolean, StorageOperationStatus> eitherFalse = Either.left(true);
- when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherFalse);
+ when(toscaOperationFacade.validateComponentNameExists("Root", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE))
+ .thenReturn(eitherFalse);
Either<Boolean, StorageOperationStatus> eitherCountExist = Either.left(true);
- when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC, ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
-
+ when(toscaOperationFacade.validateComponentNameExists("alreadyExists", ResourceTypeEnum.VFC,
+ ComponentTypeEnum.RESOURCE)).thenReturn(eitherCountExist);
+
Either<Boolean, StorageOperationStatus> eitherCount = Either.left(false);
- when(toscaOperationFacade.validateComponentNameExists(RESOURCE_NAME, ResourceTypeEnum.VFC, 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.VFC,
+ 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);
+
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
-
+
Either<Boolean, StorageOperationStatus> validateDerivedNotExists = Either.left(false);
when(toscaOperationFacade.validateToscaResourceNameExists("kuku")).thenReturn(validateDerivedNotExists);
- when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource))).thenReturn(StorageOperationStatus.OK);
- when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource))).thenReturn(StorageOperationStatus.OK);
-
+ when(graphLockOperation.lockComponent(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource)))
+ .thenReturn(StorageOperationStatus.OK);
+ when(graphLockOperation.lockComponentByName(Mockito.anyString(), Mockito.eq(NodeTypeEnum.Resource)))
+ .thenReturn(StorageOperationStatus.OK);
+
// createResource
resourceResponse = createResourceObject(true);
Either<Resource, StorageOperationStatus> eitherCreate = Either.left(resourceResponse);
@@ -287,7 +324,7 @@ public class ResourceBusinessLogicTest {
if (afterCreate) {
resource.setName(resource.getName());
resource.setVersion("0.1");
-
+
resource.setUniqueId(resource.getName().toLowerCase() + ":" + resource.getVersion());
resource.setCreatorUserId(user.getUserId());
resource.setCreatorFullName(user.getFirstName() + " " + user.getLastName());
@@ -305,7 +342,8 @@ public class ResourceBusinessLogicTest {
@Test
public void testHappyScenario() {
Resource resource = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
if (createResponse.isRight()) {
assertEquals(new Integer(200), createResponse.right().value().getStatus());
@@ -317,15 +355,17 @@ public class ResourceBusinessLogicTest {
public void testUpdateHappyScenario() {
Resource resource = createResourceObjectCsar(true);
setCanWorkOnResource(resource);
-
+
Either<Resource, StorageOperationStatus> resourceLinkedToCsarRes = Either.left(resource);
- when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(), resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
+ when(toscaOperationFacade.getLatestComponentByCsarOrName(ComponentTypeEnum.RESOURCE, resource.getCsarUUID(),
+ resource.getSystemName())).thenReturn(resourceLinkedToCsarRes);
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
-
+
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> updateResponse = bl.validateAndUpdateResourceFromCsar(resource, user, null, null, resource.getUniqueId());
+ Either<Resource, ResponseFormat> updateResponse = bl.validateAndUpdateResourceFromCsar(resource, user, null,
+ null, resource.getUniqueId());
if (updateResponse.isRight()) {
assertEquals(new Integer(200), updateResponse.right().value().getStatus());
}
@@ -353,7 +393,7 @@ public class ResourceBusinessLogicTest {
testTagsExceedsLimitCreate();
testTagsNoServiceName();
testInvalidTag();
-
+
testContactIdTooLong();
testContactIdWrongFormatCreate();
testResourceContactIdEmpty();
@@ -381,15 +421,18 @@ public class ResourceBusinessLogicTest {
resourceExist.setName(resourceName);
resourceExist.getTags().add(resourceName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resourceName);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
+ resourceName);
}
private void testResourceNameEmpty() {
Resource resourceExist = createResourceObject(false);
resourceExist.setName(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertResponse(createResponse, ActionStatus.MISSING_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -399,9 +442,11 @@ public class ResourceBusinessLogicTest {
String tooLongResourceName = "zCRCAWjqte0DtgcAAMmcJcXeNubeX1p1vOZNTShAHOYNAHvV3iK";
resourceExccedsNameLimit.setName(tooLongResourceName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
+ "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
}
private void testResourceNameWrongFormat() {
@@ -410,7 +455,8 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "ljg?fd";
resource.setName(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -431,9 +477,11 @@ public class ResourceBusinessLogicTest {
resourceExccedsDescLimit.setDescription(tooLongResourceDesc);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsDescLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsDescLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
+ ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
private void testResourceDescNotEnglish() {
@@ -442,29 +490,35 @@ public class ResourceBusinessLogicTest {
String notEnglishDesc = "\uC2B5";
notEnglish.setDescription(notEnglishDesc);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(notEnglish, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(notEnglish,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_DESCRIPTION,
+ ComponentTypeEnum.RESOURCE.getValue());
}
private void testResourceDescriptionEmpty() {
Resource resourceExist = createResourceObject(false);
resourceExist.setDescription("");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
+ ComponentTypeEnum.RESOURCE.getValue());
}
private void testResourceDescriptionMissing() {
Resource resourceExist = createResourceObject(false);
resourceExist.setDescription(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION, ComponentTypeEnum.RESOURCE.getValue());
+ assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_DESCRIPTION,
+ ComponentTypeEnum.RESOURCE.getValue());
}
// Resource description - end
// Resource icon start
@@ -473,7 +527,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -483,7 +538,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon("kjk3453^&");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -493,10 +549,12 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setIcon("dsjfhskdfhskjdhfskjdhkjdhfkshdfksjsdkfhsdfsdfsdfsfsdfsf");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.ICON_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_ICON_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
+ "" + ValidationUtils.ICON_MAX_LENGTH);
}
// Resource icon end
@@ -505,7 +563,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setTags(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
@@ -515,7 +574,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setTags(new ArrayList<String>());
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_TAGS);
@@ -571,9 +631,11 @@ public class ResourceBusinessLogicTest {
resourceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
+ "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
}
@@ -587,9 +649,11 @@ public class ResourceBusinessLogicTest {
resourceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> 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);
+ assertResponse(createResponse, ActionStatus.COMPONENT_SINGLE_TAG_EXCEED_LIMIT,
+ "" + ValidationUtils.TAG_MAX_LENGTH);
}
@@ -600,7 +664,8 @@ public class ResourceBusinessLogicTest {
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_TAGS_NO_COMP_NAME);
@@ -613,7 +678,8 @@ public class ResourceBusinessLogicTest {
tagsList.add(tag1);
serviceExccedsNameLimit.setTags(tagsList);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(serviceExccedsNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_FIELD_FORMAT, new String[] { "Resource", "tag" });
@@ -621,14 +687,15 @@ public class ResourceBusinessLogicTest {
// Resource tags - stop
// Resource contact start
-
+
private void testContactIdTooLong() {
Resource resourceContactId = createResourceObject(false);
// 59 chars instead of 50
String contactIdTooLong = "thisNameIsVeryLongAndExeccedsTheNormalLengthForContactId";
resourceContactId.setContactId(contactIdTooLong);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -639,7 +706,8 @@ public class ResourceBusinessLogicTest {
String contactIdFormatWrong = "yrt134!!!";
resourceContactId.setContactId(contactIdFormatWrong);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceContactId,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
}
@@ -648,7 +716,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setContactId("");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -658,7 +727,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setContactId(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -669,19 +739,23 @@ public class ResourceBusinessLogicTest {
String tooLongVendorName = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsVendorNameLimit.setVendorName(tooLongVendorName);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT,
+ "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH);
}
-
+
private void testResourceVendorModelNumberExceedsLimit() {
Resource resourceExccedsVendorModelNumberLimit = createResourceObject(false);
String tooLongVendorModelNumber = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsVendorModelNumberLimit.setResourceVendorModelNumber(tooLongVendorModelNumber);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorModelNumberLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsVendorModelNumberLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT,
+ "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
}
private void testVendorNameWrongFormatCreate() {
@@ -690,7 +764,8 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "ljg*fd";
resource.setVendorName(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
}
@@ -701,7 +776,8 @@ public class ResourceBusinessLogicTest {
String nameWrongFormat = "1>2";
resource.setVendorRelease(nameWrongFormat);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_RELEASE);
@@ -712,16 +788,19 @@ public class ResourceBusinessLogicTest {
String tooLongVendorRelease = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsNameLimit.setVendorRelease(tooLongVendorRelease);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExccedsNameLimit,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
+ "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
private void testResourceVendorNameMissing() {
Resource resourceExist = createResourceObject(false);
resourceExist.setVendorName(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_VENDOR_NAME);
@@ -731,7 +810,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setVendorRelease(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_VENDOR_RELEASE);
@@ -743,7 +823,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setCategories(null);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -755,7 +836,8 @@ public class ResourceBusinessLogicTest {
resourceExist.setCategories(null);
resourceExist.addCategory("koko", "koko");
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -774,7 +856,8 @@ public class ResourceBusinessLogicTest {
String licenseType = "User";
createResourceObject.setCost(cost);
createResourceObject.setLicenseType(licenseType);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(createResourceObject, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(createResourceObject,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
if (createResponse.isRight()) {
assertEquals(new Integer(200), createResponse.right().value().getStatus());
@@ -790,7 +873,8 @@ public class ResourceBusinessLogicTest {
String cost = "12356,464";
resourceCost.setCost(cost);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceCost, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceCost,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
}
@@ -803,7 +887,8 @@ public class ResourceBusinessLogicTest {
String licenseType = "cpu";
resourceLicenseType.setLicenseType(licenseType);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceLicenseType, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceLicenseType,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_CONTENT);
}
@@ -815,7 +900,8 @@ public class ResourceBusinessLogicTest {
List<String> list = null;
resourceExist.setDerivedFrom(list);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -825,7 +911,8 @@ public class ResourceBusinessLogicTest {
Resource resourceExist = createResourceObject(false);
resourceExist.setDerivedFrom(new ArrayList<String>());
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -837,18 +924,21 @@ public class ResourceBusinessLogicTest {
derivedFrom.add("kuku");
resourceExist.setDerivedFrom(derivedFrom);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
}
// Derived from stop
- private void assertResponse(Either<Resource, ResponseFormat> createResponse, ActionStatus expectedStatus, String... variables) {
+ private void assertResponse(Either<Resource, ResponseFormat> createResponse, ActionStatus expectedStatus,
+ String... variables) {
ResponseFormat expectedResponse = responseManager.getResponseFormat(expectedStatus, variables);
ResponseFormat actualResponse = createResponse.right().value();
assertEquals(expectedResponse.getStatus(), actualResponse.getStatus());
- assertEquals("assert error description", expectedResponse.getFormattedMessage(), actualResponse.getFormattedMessage());
+ assertEquals("assert error description", expectedResponse.getFormattedMessage(),
+ actualResponse.getFormattedMessage());
}
// UPDATE tests - start
@@ -867,8 +957,9 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
-
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_COMPONENT_NAME, ComponentTypeEnum.RESOURCE.getValue());
@@ -887,11 +978,12 @@ public class ResourceBusinessLogicTest {
String name = "ljg";
updatedResource.setName(name);
resource.setVersion("1.0");
-
+
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_NAME_CANNOT_BE_CHANGED);
@@ -912,9 +1004,11 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(),
+ "" + ValidationUtils.COMPONENT_NAME_MAX_LENGTH);
}
@Test
@@ -930,9 +1024,11 @@ public class ResourceBusinessLogicTest {
updatedResource.setName(resourceName);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), resourceName);
+ assertResponse(createResponse, ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(),
+ resourceName);
}
//
@@ -958,9 +1054,11 @@ public class ResourceBusinessLogicTest {
updatedResource.setDescription(tooLongResourceDesc);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT, ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_DESCRIPTION_EXCEEDS_LIMIT,
+ ComponentTypeEnum.RESOURCE.getValue(), "" + ValidationUtils.COMPONENT_DESCRIPTION_MAX_LENGTH);
}
@@ -979,7 +1077,8 @@ public class ResourceBusinessLogicTest {
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_ICON, ComponentTypeEnum.RESOURCE.getValue());
@@ -1002,7 +1101,8 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_ICON_CANNOT_BE_CHANGED);
@@ -1066,10 +1166,12 @@ public class ResourceBusinessLogicTest {
updatedResource.setTags(tagsList);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT, "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.COMPONENT_TAGS_EXCEED_LIMIT,
+ "" + ValidationUtils.TAG_LIST_MAX_LENGTH);
}
@Test
@@ -1086,7 +1188,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setVendorName(nameWrongFormat);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.INVALID_VENDOR_NAME);
@@ -1108,7 +1211,8 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_NAME_CANNOT_BE_CHANGED);
@@ -1127,9 +1231,11 @@ public class ResourceBusinessLogicTest {
updatedResource.setVendorRelease(tooLongVendorRelease);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(), updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resource.getUniqueId(),
+ updatedResource, null, user, false);
assertTrue(createResponse.isRight());
- assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
+ assertResponse(createResponse, ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT,
+ "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH);
}
@Ignore
@@ -1147,7 +1253,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setContactId(contactIdTooLong);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CONTACT, ComponentTypeEnum.RESOURCE.getValue());
@@ -1168,7 +1275,8 @@ public class ResourceBusinessLogicTest {
updatedResource.addCategory(badCategory, "fikt");
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.COMPONENT_INVALID_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
@@ -1190,7 +1298,8 @@ public class ResourceBusinessLogicTest {
;
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.RESOURCE_CATEGORY_CANNOT_BE_CHANGED);
@@ -1211,7 +1320,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(list);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -1230,7 +1340,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(new ArrayList<String>());
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.MISSING_DERIVED_FROM_TEMPLATE);
@@ -1251,7 +1362,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_NOT_FOUND);
@@ -1266,13 +1378,16 @@ public class ResourceBusinessLogicTest {
// this is in order to prevent failing with 403 earlier
Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
-
+
Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(true);
- when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString())).thenReturn(isToscaNameExtending);
-
- Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either.left(new HashMap<>());
- when(propertyOperation.deleteAllPropertiesAssociatedToNode(Mockito.any(NodeTypeEnum.class), Mockito.anyString())).thenReturn(findPropertiesOfNode);
-
+ when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
+ .thenReturn(isToscaNameExtending);
+
+ Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either
+ .left(new HashMap<>());
+ when(propertyOperation.deleteAllPropertiesAssociatedToNode(Mockito.any(NodeTypeEnum.class),
+ Mockito.anyString())).thenReturn(findPropertiesOfNode);
+
resource.setVersion("1.0");
ArrayList<String> derivedFrom = new ArrayList<String>();
@@ -1280,10 +1395,11 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(updatedResource);
when(toscaOperationFacade.updateToscaElement(updatedResource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user, false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isLeft());
}
-
+
@Test
public void testResourceTemplateCertify_UPDATE_SAD() {
Resource resource = createResourceObject(true);
@@ -1293,7 +1409,7 @@ public class ResourceBusinessLogicTest {
// this is in order to prevent failing with 403 earlier
Either<Component, StorageOperationStatus> eitherUpdate = Either.left(setCanWorkOnResource(resource));
when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
-
+
Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(false);
when(toscaOperationFacade.validateToscaResourceNameExtends(Mockito.anyString(), Mockito.anyString()))
.thenReturn(isToscaNameExtending);
@@ -1305,8 +1421,8 @@ public class ResourceBusinessLogicTest {
updatedResource.setDerivedFrom(derivedFrom);
Either<Resource, StorageOperationStatus> dataModelResponse = Either.left(resource);
when(toscaOperationFacade.updateToscaElement(resource)).thenReturn(dataModelResponse);
- Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null, user,
- false);
+ Either<Resource, ResponseFormat> createResponse = bl.updateResourceMetadata(resourceId, updatedResource, null,
+ user, false);
assertTrue(createResponse.isRight());
assertResponse(createResponse, ActionStatus.PARENT_RESOURCE_DOES_NOT_EXTEND);
@@ -1317,22 +1433,28 @@ public class ResourceBusinessLogicTest {
public void createOrUpdateResourceAlreadyCheckout() {
Resource resourceExist = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
createResponse.left().value().setLastUpdaterUserId(user.getUserId());
assertTrue(createResponse.isLeft());
Either<Component, StorageOperationStatus> getLatestResult = Either.left(createResponse.left().value());
when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getLatestResult);
- when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class))).thenReturn(getLatestResult);
+ when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)))
+ .thenReturn(getLatestResult);
Resource resourceToUpdtae = createResourceObject(false);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
+ .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class), Mockito.any(Resource.class));
- Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Resource.class),
+ Mockito.any(Resource.class));
+ Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user),
+ Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
+ Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1340,27 +1462,34 @@ public class ResourceBusinessLogicTest {
public void createOrUpdateResourceCertified() {
Resource resourceExist = createResourceObject(false);
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resourceExist,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
Resource certifiedResource = createResponse.left().value();
certifiedResource.setLifecycleState(LifecycleStateEnum.CERTIFIED);
certifiedResource.setVersion("1.0");
-
Either<Component, StorageOperationStatus> getLatestResult = Either.left(certifiedResource);
when(toscaOperationFacade.getLatestByName(resourceExist.getName())).thenReturn(getLatestResult);
- when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class))).thenReturn(getLatestResult);
+ when(toscaOperationFacade.overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class)))
+ .thenReturn(getLatestResult);
- when(lifecycleBl.changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(createResponse);
+ when(lifecycleBl.changeState(Mockito.anyString(), Mockito.eq(user),
+ Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
+ Mockito.anyBoolean(), Mockito.anyBoolean())).thenReturn(createResponse);
Resource resourceToUpdtae = createResourceObject(false);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
+ .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class));
- Mockito.verify(lifecycleBl, Mockito.times(1)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(1)).overrideComponent(Mockito.any(Component.class),
+ Mockito.any(Component.class));
+ Mockito.verify(lifecycleBl, Mockito.times(1)).changeState(Mockito.anyString(), Mockito.eq(user),
+ Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
+ Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1371,14 +1500,20 @@ public class ResourceBusinessLogicTest {
Either<Component, StorageOperationStatus> getLatestResult = Either.right(StorageOperationStatus.NOT_FOUND);
when(toscaOperationFacade.getLatestByName(resourceToUpdtae.getName())).thenReturn(getLatestResult);
- Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either.right(StorageOperationStatus.NOT_FOUND);
- when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName())).thenReturn(getLatestToscaNameResult);
+ Either<Component, StorageOperationStatus> getLatestToscaNameResult = Either
+ .right(StorageOperationStatus.NOT_FOUND);
+ when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdtae.getToscaResourceName()))
+ .thenReturn(getLatestToscaNameResult);
- Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl.createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
+ Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> createOrUpdateResource = bl
+ .createOrUpdateResourceByImport(resourceToUpdtae, user, false, false, false, null);
assertTrue(createOrUpdateResource.isLeft());
- Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(Mockito.any(Component.class), Mockito.any(Component.class));
- Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user), Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.anyBoolean(), Mockito.anyBoolean());
+ Mockito.verify(toscaOperationFacade, Mockito.times(0)).overrideComponent(Mockito.any(Component.class),
+ Mockito.any(Component.class));
+ Mockito.verify(lifecycleBl, Mockito.times(0)).changeState(Mockito.anyString(), Mockito.eq(user),
+ Mockito.eq(LifeCycleTransitionEnum.CHECKOUT), Mockito.any(LifecycleChangeInfoWithAction.class),
+ Mockito.anyBoolean(), Mockito.anyBoolean());
}
@@ -1422,358 +1557,381 @@ public class ResourceBusinessLogicTest {
assertTrue(validatePropertiesDefaultValues.isRight());
}
-// @Test
-// public void testDeleteMarkedResourcesNoResources() {
-// List<GraphVertex> ids = new ArrayList<>();
-// Either<List<GraphVertex>, StorageOperationStatus> eitherNoResources = Either.left(ids);
-// when(topologyTemplateOperation.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources);
-//
-// Either<List<String>, 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<String> ids = new ArrayList<String>();
-// String resourceInUse = "123";
-// ids.add(resourceInUse);
-// String resourceFree = "456";
-// ids.add(resourceFree);
-// Either<List<String>, StorageOperationStatus> eitherNoResources = Either.left(ids);
-// when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources);
-//
-// Either<Boolean, StorageOperationStatus> resourceInUseResponse = Either.left(true);
-// Either<Boolean, StorageOperationStatus> resourceFreeResponse = Either.left(false);
-//
-// List<ArtifactDefinition> artifacts = new ArrayList<ArtifactDefinition>();
-// Either<List<ArtifactDefinition>, 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<Component, StorageOperationStatus> eitherDelete = Either.left(new Resource());
-// when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
-//
-// when(artifactManager.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK);
-// List<String> deletedComponents = new ArrayList<>();
-// deletedComponents.add(resourceFree);
-// when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(deletedComponents));
-//
-// Either<List<String>, ResponseFormat> deleteMarkedResources = bl.deleteMarkedComponents();
-// assertTrue(deleteMarkedResources.isLeft());
-// List<String> resourceIdList = deleteMarkedResources.left().value();
-// assertFalse(resourceIdList.isEmpty());
-// assertTrue(resourceIdList.contains(resourceFree));
-// assertFalse(resourceIdList.contains(resourceInUse));
-//
-// Mockito.verify(artifactManager, Mockito.times(1)).deleteAllComponentArtifactsIfNotOnGraph(artifacts);
-// }
+ // @Test
+ // public void testDeleteMarkedResourcesNoResources() {
+ // List<GraphVertex> ids = new ArrayList<>();
+ // Either<List<GraphVertex>, StorageOperationStatus> eitherNoResources =
+ // Either.left(ids);
+ // when(topologyTemplateOperation.getAllComponentsMarkedForDeletion(ComponentTypeEnum.RESOURCE)).thenReturn(eitherNoResources);
+ //
+ // Either<List<String>, 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<String> ids = new ArrayList<String>();
+ // String resourceInUse = "123";
+ // ids.add(resourceInUse);
+ // String resourceFree = "456";
+ // ids.add(resourceFree);
+ // Either<List<String>, StorageOperationStatus> eitherNoResources =
+ // Either.left(ids);
+ // when(toscaOperationFacade.getAllComponentsMarkedForDeletion()).thenReturn(eitherNoResources);
+ //
+ // Either<Boolean, StorageOperationStatus> resourceInUseResponse =
+ // Either.left(true);
+ // Either<Boolean, StorageOperationStatus> resourceFreeResponse =
+ // Either.left(false);
+ //
+ // List<ArtifactDefinition> artifacts = new ArrayList<ArtifactDefinition>();
+ // Either<List<ArtifactDefinition>, 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<Component, StorageOperationStatus> eitherDelete = Either.left(new
+ // Resource());
+ // when(toscaOperationFacade.deleteToscaComponent(resourceFree)).thenReturn(eitherDelete);
+ //
+ // when(artifactManager.deleteAllComponentArtifactsIfNotOnGraph(artifacts)).thenReturn(StorageOperationStatus.OK);
+ // List<String> deletedComponents = new ArrayList<>();
+ // deletedComponents.add(resourceFree);
+ // when(toscaOperationFacade.deleteMarkedElements(ComponentTypeEnum.RESOURCE)).thenReturn(Either.left(deletedComponents));
+ //
+ // Either<List<String>, ResponseFormat> deleteMarkedResources =
+ // bl.deleteMarkedComponents();
+ // assertTrue(deleteMarkedResources.isLeft());
+ // List<String> 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
public void testFindVfCsarArtifactsToHandle() {
-
+
Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
String methodName = "findVfCsarArtifactsToHandle";
Resource resource = new Resource();
String deploymentArtifactToUpdateFileName = "deploymentArtifactToUpdate.yaml";
String deploymentArtifactToDeleteFileName = "deploymentArtifactToDelete.yaml";
String deploymentArtifactToCreateFileName = "deploymentArtifactToCreate.yaml";
-
+
String artifactInfoToUpdateFileName = "infoArtifactToUpdate.yaml";
String artifactInfoToDeleteFileName = "infoArtifactToDelete.yaml";
String artifactInfoToCreateFileName = "infoArtifactToCreate.yaml";
-
+
byte[] oldPayloadData = "oldPayloadData".getBytes();
byte[] newPayloadData = "newPayloadData".getBytes();
- Map<String, ArtifactDefinition> deploymentArtifacts =new HashMap<>();
-
+ Map<String, ArtifactDefinition> deploymentArtifacts = new HashMap<>();
+
ArtifactDefinition deploymentArtifactToUpdate = new ArtifactDefinition();
deploymentArtifactToUpdate.setMandatory(false);
deploymentArtifactToUpdate.setArtifactName(deploymentArtifactToUpdateFileName);
deploymentArtifactToUpdate.setArtifactType("SNMP_POLL");
deploymentArtifactToUpdate.setPayload(oldPayloadData);
- deploymentArtifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+ deploymentArtifactToUpdate
+ .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
+
ArtifactDefinition deploymentArtifactToDelete = new ArtifactDefinition();
deploymentArtifactToDelete.setMandatory(false);
deploymentArtifactToDelete.setArtifactName(deploymentArtifactToDeleteFileName);
deploymentArtifactToDelete.setArtifactType("SNMP_TRAP");
deploymentArtifactToDelete.setPayload(oldPayloadData);
- deploymentArtifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+ deploymentArtifactToDelete
+ .setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
+
ArtifactDefinition deploymentArtifactToIgnore = new ArtifactDefinition();
-
- deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()), deploymentArtifactToUpdate);
- deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToDelete.getArtifactName()), deploymentArtifactToDelete);
+
+ deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToUpdate.getArtifactName()),
+ deploymentArtifactToUpdate);
+ deploymentArtifacts.put(ValidationUtils.normalizeArtifactLabel(deploymentArtifactToDelete.getArtifactName()),
+ deploymentArtifactToDelete);
deploymentArtifacts.put("ignore", deploymentArtifactToIgnore);
-
+
Map<String, ArtifactDefinition> artifacts = new HashMap<>();
-
+
ArtifactDefinition artifactToUpdate = new ArtifactDefinition();
artifactToUpdate.setMandatory(false);
artifactToUpdate.setArtifactName(artifactInfoToUpdateFileName);
artifactToUpdate.setArtifactType("SNMP_POLL");
artifactToUpdate.setPayload(oldPayloadData);
artifactToUpdate.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+
ArtifactDefinition artifactToDelete = new ArtifactDefinition();
artifactToDelete.setMandatory(false);
artifactToDelete.setArtifactName(artifactInfoToDeleteFileName);
artifactToDelete.setArtifactType("SNMP_TRAP");
artifactToDelete.setPayload(oldPayloadData);
artifactToDelete.setArtifactChecksum(GeneralUtility.calculateMD5Base64EncodedByByteArray(oldPayloadData));
-
+
ArtifactDefinition artifactToIgnore = new ArtifactDefinition();
-
- artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToUpdate.getArtifactName()),artifactToUpdate);
- artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToDelete.getArtifactName()),artifactToDelete);
- artifacts.put("ignore",artifactToIgnore);
-
+
+ artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToUpdate.getArtifactName()), artifactToUpdate);
+ artifacts.put(ValidationUtils.normalizeArtifactLabel(artifactToDelete.getArtifactName()), artifactToDelete);
+ artifacts.put("ignore", artifactToIgnore);
+
resource.setDeploymentArtifacts(deploymentArtifacts);
resource.setArtifacts(artifacts);
-
+
List<NonMetaArtifactInfo> artifactPathAndNameList = new ArrayList<>();
- NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo(deploymentArtifactToUpdate.getArtifactName(), null,
- ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()), ArtifactGroupTypeEnum.DEPLOYMENT,
- newPayloadData, deploymentArtifactToUpdate.getArtifactName());
-
- NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo(artifactToUpdate.getArtifactName(), null,
- ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()), ArtifactGroupTypeEnum.DEPLOYMENT,
- newPayloadData, artifactToUpdate.getArtifactName());
-
- NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName, null,
- ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToCreateFileName);
-
- NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName, null,
- ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT,
- newPayloadData, artifactInfoToCreateFileName);
-
+ NonMetaArtifactInfo deploymentArtifactInfoToUpdate = new NonMetaArtifactInfo(
+ deploymentArtifactToUpdate.getArtifactName(), null,
+ ArtifactTypeEnum.findType(deploymentArtifactToUpdate.getArtifactType()),
+ ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, deploymentArtifactToUpdate.getArtifactName());
+
+ NonMetaArtifactInfo informationalArtifactInfoToUpdate = new NonMetaArtifactInfo(
+ artifactToUpdate.getArtifactName(), null, ArtifactTypeEnum.findType(artifactToUpdate.getArtifactType()),
+ ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData, artifactToUpdate.getArtifactName());
+
+ NonMetaArtifactInfo deploymentArtifactInfoToCreate = new NonMetaArtifactInfo(deploymentArtifactToCreateFileName,
+ null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData,
+ deploymentArtifactToCreateFileName);
+
+ NonMetaArtifactInfo informationalArtifactInfoToCreate = new NonMetaArtifactInfo(artifactInfoToCreateFileName,
+ null, ArtifactTypeEnum.OTHER, ArtifactGroupTypeEnum.DEPLOYMENT, newPayloadData,
+ artifactInfoToCreateFileName);
+
artifactPathAndNameList.add(deploymentArtifactInfoToUpdate);
artifactPathAndNameList.add(informationalArtifactInfoToUpdate);
artifactPathAndNameList.add(deploymentArtifactInfoToCreate);
artifactPathAndNameList.add(informationalArtifactInfoToCreate);
-
- Object[] argObjects = {resource, artifactPathAndNameList, user};
- Class[] argClasses = {Resource.class, List.class, User.class};
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes =
- (Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat>) method.invoke(bl, argObjects);
- assertTrue(findVfCsarArtifactsToHandleRes.isLeft());
- EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> foundVfArtifacts = findVfCsarArtifactsToHandleRes.left().value();
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size()==2);
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Update).size()==2);
- assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size()==2);
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+
+ Object[] argObjects = { resource, artifactPathAndNameList, user };
+ Class[] argClasses = { Resource.class, List.class, User.class };
+ try {
+ Method method = targetClass.getDeclaredMethod(methodName, argClasses);
+ method.setAccessible(true);
+ Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat> findVfCsarArtifactsToHandleRes = (Either<EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>>, ResponseFormat>) method
+ .invoke(bl, argObjects);
+ assertTrue(findVfCsarArtifactsToHandleRes.isLeft());
+ EnumMap<ArtifactOperationEnum, List<NonMetaArtifactInfo>> foundVfArtifacts = findVfCsarArtifactsToHandleRes
+ .left().value();
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size() == 2);
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Update).size() == 2);
+ assertTrue(foundVfArtifacts.get(ArtifactOperationEnum.Create).size() == 2);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
@SuppressWarnings("rawtypes")
@Test
public void testBuildNestedVfcToscaNamespace() {
-
+
Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
String methodName = "buildNestedVfcToscaNamespace";
String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
String expectedNestedVfcToscaNamespace = "org.openecomp.resource.vfc.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- Object[] argObjects = {nodeTypeFullName};
- Class[] argClasses = {String.class};
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedVfcToscaNamespace = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedVfcToscaNamespace.isEmpty());
- assertTrue(actualNestedVfcToscaNamespace.equals(expectedNestedVfcToscaNamespace));
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ Object[] argObjects = { nodeTypeFullName };
+ Class[] argClasses = { String.class };
+ try {
+ Method method = targetClass.getDeclaredMethod(methodName, argClasses);
+ method.setAccessible(true);
+ String actualNestedVfcToscaNamespace = (String) method.invoke(bl, argObjects);
+ assertTrue(!actualNestedVfcToscaNamespace.isEmpty());
+ assertTrue(actualNestedVfcToscaNamespace.equals(expectedNestedVfcToscaNamespace));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
@SuppressWarnings("rawtypes")
@Test
public void testBuildNestedVfcToscaResourceName() {
-
+
Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
String methodName = "buildNestedVfcToscaResourceName";
String vfResourceName = "vfname";
String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
String expectedNestedVfcToscaResourceName = "org.openecomp.resource.vfc.vfname.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
- Object[] argObjects = {vfResourceName, nodeTypeFullName};
- Class[] argClasses = {String.class, String.class};
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedVfcToscaResourceName = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedVfcToscaResourceName.isEmpty());
- assertTrue(actualNestedVfcToscaResourceName.equals(expectedNestedVfcToscaResourceName));
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ Object[] argObjects = { vfResourceName, nodeTypeFullName };
+ Class[] argClasses = { String.class, String.class };
+ try {
+ Method method = targetClass.getDeclaredMethod(methodName, argClasses);
+ method.setAccessible(true);
+ String actualNestedVfcToscaResourceName = (String) method.invoke(bl, argObjects);
+ assertTrue(!actualNestedVfcToscaResourceName.isEmpty());
+ assertTrue(actualNestedVfcToscaResourceName.equals(expectedNestedVfcToscaResourceName));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
+
@SuppressWarnings("rawtypes")
@Test
public void testBuildNestedSubstituteYamlName() {
-
+
Class<ResourceBusinessLogic> targetClass = ResourceBusinessLogic.class;
String methodName = "buildNestedSubstituteYamlName";
String nodeTypeFullName = "org.openecomp.resource.abstract.nodes.heat.FEAdd_On_Module_vLBAgentTemplate";
String expectedNestedSubstituteYamlName = "Definitions/FEAdd_On_Module_vLBAgentTemplateServiceTemplate.yaml";
- Object[] argObjects = {nodeTypeFullName};
- Class[] argClasses = {String.class};
- try {
- Method method = targetClass.getDeclaredMethod(methodName, argClasses);
- method.setAccessible(true);
- String actualNestedSubstituteYamlName = (String) method.invoke(bl, argObjects);
- assertTrue(!actualNestedSubstituteYamlName.isEmpty());
- assertTrue(actualNestedSubstituteYamlName.equals(expectedNestedSubstituteYamlName));
-
- }
- catch (Exception e) {
- e.printStackTrace();
- }
+ Object[] argObjects = { nodeTypeFullName };
+ Class[] argClasses = { String.class };
+ try {
+ Method method = targetClass.getDeclaredMethod(methodName, argClasses);
+ method.setAccessible(true);
+ String actualNestedSubstituteYamlName = (String) method.invoke(bl, argObjects);
+ assertTrue(!actualNestedSubstituteYamlName.isEmpty());
+ assertTrue(actualNestedSubstituteYamlName.equals(expectedNestedSubstituteYamlName));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
-
-
+
@Test
public void testVFGeneratedInputs() {
-
+
Resource resource = createVF();
List<InputDefinition> inputs = resource.getInputs();
assertTrue(8 == inputs.size());
- for(InputDefinition input : inputs){
+ for (InputDefinition input : inputs) {
assertNotNull(input.getOwnerId());
}
assertTrue(resource.getDerivedFromGenericType().equals(genericVF.getToscaResourceName()));
assertTrue(resource.getDerivedFromGenericVersion().equals(genericVF.getVersion()));
}
-
+
@Test
public void testVFUpdateGenericInputsToLatestOnCheckout() {
-
- //create a VF that is derived from generic version 1.0
- Resource resource = createVF();
+
+ // create a VF that is derived from generic version 1.0
+ Resource resource = createVF();
// create a new generic version without properties
genericVF.setVersion("2.0");
genericVF.setProperties(null);
String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
List<InputDefinition> currentInputs = resource.getInputs();
- //verify previous inputs ownerId fields exist - user may not delete generated inputs
+ // verify previous inputs ownerId fields exist - user may not delete
+ // generated inputs
assertTrue(8 == currentInputs.stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList()).size());
Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
- //verify success
+ // verify success
assertTrue(upgradeToLatestGeneric.isLeft());
- //verify update required and valid
+ // verify update required and valid
assertTrue(upgradeToLatestGeneric.left().value());
- //verify version was upgraded
+ // verify version was upgraded
assertFalse(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
- //verify inputs were not deleted
+ // verify inputs were not deleted
assertTrue(8 == resource.getInputs().size());
- //verify inputs ownerId fields were removed - user may delete/edit inputs
- assertTrue(8 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList()).size());
+ // verify inputs ownerId fields were removed - user may delete/edit
+ // inputs
+ assertTrue(8 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
+ .size());
}
-
-
+
@Test
public void testVFUpdateGenericInputsToLatestOnCheckoutNotPerformed() {
-
- //create a VF that is derived from generic version 1.0
+
+ // create a VF that is derived from generic version 1.0
Resource resource = createVF();
-
- //add an input to the VF
+
+ // add an input to the VF
PropertyDefinition newProp = new PropertyDefinition();
newProp.setType("integer");
newProp.setName("newProp");
resource.getInputs().add(new InputDefinition(newProp));
-
- //create a new generic version with a new property which has the same name as a user defined input on the VF with a different type
+
+ // create a new generic version with a new property which has the same
+ // name as a user defined input on the VF with a different type
genericVF.setVersion("2.0");
newProp.setType("string");
genericVF.setProperties(new ArrayList<PropertyDefinition>());
genericVF.getProperties().add(newProp);
-
+
String currentDerivedFromVersion = resource.getDerivedFromGenericVersion();
- assertTrue(8 == resource.getInputs().stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList()).size());
+ assertTrue(8 == resource.getInputs().stream().filter(p -> null != p.getOwnerId()).collect(Collectors.toList())
+ .size());
Either<Boolean, ResponseFormat> upgradeToLatestGeneric = bl.shouldUpgradeToLatestGeneric(resource);
- //verify success
+ // verify success
assertTrue(upgradeToLatestGeneric.isLeft());
- //verify update is invalid an void
+ // verify update is invalid an void
assertFalse(upgradeToLatestGeneric.left().value());
- //verify version was not upgraded
+ // verify version was not upgraded
assertTrue(resource.getDerivedFromGenericVersion().equals(currentDerivedFromVersion));
- //verify inputs were not removed
+ // verify inputs were not removed
assertTrue(9 == resource.getInputs().size());
- //verify user defined input exists
- assertTrue(1 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList()).size());
- assertTrue(resource.getInputs().stream().filter(p -> null == p.getOwnerId()).findAny().get().getType().equals("integer"));
+ // verify user defined input exists
+ assertTrue(1 == resource.getInputs().stream().filter(p -> null == p.getOwnerId()).collect(Collectors.toList())
+ .size());
+ assertTrue(resource.getInputs().stream().filter(p -> null == p.getOwnerId()).findAny().get().getType()
+ .equals("integer"));
}
-
+
@Test
public void testPNFGeneratedInputsNoGeneratedInformationalArtifacts() {
-
+
Resource resource = createPNF();
List<InputDefinition> inputs = resource.getInputs();
assertTrue(8 == inputs.size());
- for(InputDefinition input : inputs){
+ for (InputDefinition input : inputs) {
assertNotNull(input.getOwnerId());
}
assertTrue(resource.getDerivedFromGenericType().equals(genericPNF.getToscaResourceName()));
assertTrue(resource.getDerivedFromGenericVersion().equals(genericPNF.getVersion()));
assertTrue(0 == resource.getArtifacts().size());
}
-
-
+
private Resource createVF() {
-
+
genericVF = setupGenericTypeMock(GENERIC_VF_NAME);
- when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_VF_NAME)).thenReturn(Either.left(genericVF));
+ when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_VF_NAME))
+ .thenReturn(Either.left(genericVF));
Resource resource = createResourceObject(true);
resource.setDerivedFrom(null);
resource.setResourceType(ResourceTypeEnum.VF);
when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
return createResponse.left().value();
}
-
- private Resource createPNF() {
-
+
+ private Resource createPNF() {
+
genericPNF = setupGenericTypeMock(GENERIC_PNF_NAME);
- when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_PNF_NAME)).thenReturn(Either.left(genericPNF));
+ when(toscaOperationFacade.getLatestCertifiedNodeTypeByToscaResourceName(GENERIC_PNF_NAME))
+ .thenReturn(Either.left(genericPNF));
Resource resource = createResourceObject(true);
resource.setDerivedFrom(null);
resource.setResourceType(ResourceTypeEnum.PNF);
when(toscaOperationFacade.createToscaComponent(resource)).thenReturn(Either.left(resource));
- Either<Resource, ResponseFormat> createResponse = bl.createResource(resource, AuditingActionEnum.CREATE_RESOURCE, user, null, null);
+ Either<Resource, ResponseFormat> createResponse = bl.createResource(resource,
+ AuditingActionEnum.CREATE_RESOURCE, user, null, null);
assertTrue(createResponse.isLeft());
return createResponse.left().value();
}
-
-
- private Resource setupGenericTypeMock(String toscaName) {
-
+ private Resource setupGenericTypeMock(String toscaName) {
+
Resource genericType = createResourceObject(true);
genericType.setVersion("1.0");
genericType.setToscaResourceName(toscaName);
- String[] propNames = {"nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming", "availability_zone_max_count", "min_instances", "max_instances"};
- String[] propTypes = {"string", "string", "string", "string", "org.openecomp.datatypes.Naming", "integer", "integer", "integer"};
+ String[] propNames = { "nf_function", "nf_role", "nf_naming_code", "nf_type", "nf_naming",
+ "availability_zone_max_count", "min_instances", "max_instances" };
+ String[] propTypes = { "string", "string", "string", "string", "org.openecomp.datatypes.Naming", "integer",
+ "integer", "integer" };
List<PropertyDefinition> genericProps = new ArrayList<>();
- for(int i = 0; i < 8; ++i){
+ for (int i = 0; i < 8; ++i) {
PropertyDefinition prop = new PropertyDefinition();
prop.setName(propNames[i]);
prop.setType(propTypes[i]);
@@ -1783,6 +1941,289 @@ public class ResourceBusinessLogicTest {
return genericType;
}
-
-
+ private ResourceBusinessLogic createTestSubject() {
+ return new ResourceBusinessLogic();
+ }
+
+ @Test
+ public void testGetCsarOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ CsarOperation result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCsarOperation();
+ }
+
+ @Test
+ public void testSetCsarOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ CsarOperation csarOperation = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCsarOperation(csarOperation);
+ }
+
+
+ @Test
+ public void testGetLifecycleBusinessLogic() throws Exception {
+ ResourceBusinessLogic testSubject;
+ LifecycleBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getLifecycleBusinessLogic();
+ }
+
+
+ @Test
+ public void testSetLifecycleManager() throws Exception {
+ ResourceBusinessLogic testSubject;
+ LifecycleBusinessLogic lifecycleBusinessLogic = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setLifecycleManager(lifecycleBusinessLogic);
+ }
+
+
+ @Test
+ public void testGetElementDao() throws Exception {
+ ResourceBusinessLogic testSubject;
+ IElementOperation result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getElementDao();
+ }
+
+
+ @Test
+ public void testSetElementDao() throws Exception {
+ ResourceBusinessLogic testSubject;
+ IElementOperation elementDao = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setElementDao(elementDao);
+ }
+
+
+ @Test
+ public void testGetUserAdmin() throws Exception {
+ ResourceBusinessLogic testSubject;
+ IUserBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getUserAdmin();
+ }
+
+
+ @Test
+ public void testSetUserAdmin() throws Exception {
+ ResourceBusinessLogic testSubject;
+ UserBusinessLogic userAdmin = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setUserAdmin(userAdmin);
+ }
+
+
+ @Test
+ public void testGetComponentsUtils() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ComponentsUtils result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getComponentsUtils();
+ }
+
+
+ @Test
+ public void testSetComponentsUtils() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ComponentsUtils componentsUtils = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setComponentsUtils(componentsUtils);
+ }
+
+
+ @Test
+ public void testGetArtifactsManager() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ArtifactsBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getArtifactsManager();
+ }
+
+
+ @Test
+ public void testSetArtifactsManager() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ArtifactsBusinessLogic artifactsManager = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setArtifactsManager(artifactsManager);
+ }
+
+
+ @Test
+ public void testSetPropertyOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ IPropertyOperation propertyOperation = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setPropertyOperation(propertyOperation);
+ }
+
+
+ @Test
+ public void testGetApplicationDataTypeCache() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ApplicationDataTypeCache result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getApplicationDataTypeCache();
+ }
+
+
+ @Test
+ public void testSetApplicationDataTypeCache() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ApplicationDataTypeCache applicationDataTypeCache = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setApplicationDataTypeCache(applicationDataTypeCache);
+ }
+
+ @Test
+ public void testSetDeploymentArtifactsPlaceHolder() throws Exception {
+ ResourceBusinessLogic testSubject;
+ Component component = new Resource() {
+ };
+ User user = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setDeploymentArtifactsPlaceHolder(component, user);
+ }
+
+
+
+ @Test
+ public void testValidateVendorReleaseName_1() throws Exception {
+ ResourceBusinessLogic testSubject;
+ String vendorRelease = "";
+ Either<Boolean, ResponseFormat> result;
+
+ // test 1
+ testSubject = createTestSubject();
+ vendorRelease = null;
+ result = testSubject.validateVendorReleaseName(vendorRelease);
+ Assert.assertEquals(false, result.left().value());
+
+ }
+
+
+
+
+
+
+ @Test
+ public void testGetCapabilityTypeOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ICapabilityTypeOperation result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCapabilityTypeOperation();
+ }
+
+
+ @Test
+ public void testSetCapabilityTypeOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ICapabilityTypeOperation capabilityTypeOperation = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCapabilityTypeOperation(capabilityTypeOperation);
+ }
+
+
+ @Test
+ public void testValidatePropertiesDefaultValues() throws Exception {
+ ResourceBusinessLogic testSubject;
+ Resource resource = new Resource();
+ Either<Boolean, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.validatePropertiesDefaultValues(resource);
+ }
+
+
+ @Test
+ public void testGetComponentInstanceBL() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ComponentInstanceBusinessLogic result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getComponentInstanceBL();
+ }
+
+
+
+ @Test
+ public void testGetComponentInstancesFilteredByPropertiesAndInputs() throws Exception {
+ ResourceBusinessLogic testSubject;
+ String componentId = "";
+ ComponentTypeEnum componentTypeEnum = null;
+ String userId = "";
+ String searchText = "";
+ Either<List<ComponentInstance>, ResponseFormat> result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getComponentInstancesFilteredByPropertiesAndInputs(componentId, componentTypeEnum, userId,
+ searchText);
+ }
+
+
+
+ @Test
+ public void testGetCacheManagerOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ICacheMangerOperation result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getCacheManagerOperation();
+ }
+
+
+ @Test
+ public void testSetCacheManagerOperation() throws Exception {
+ ResourceBusinessLogic testSubject;
+ ICacheMangerOperation cacheManagerOperation = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setCacheManagerOperation(cacheManagerOperation);
+ }
+
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
new file mode 100644
index 0000000000..b726bee926
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/impl/ComponentsUtilsTest.java
@@ -0,0 +1,308 @@
+package org.openecomp.sdc.be.impl;
+
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.codehaus.jackson.map.module.SimpleModule;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.be.auditing.api.IAuditingManager;
+import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
+import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
+import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
+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.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ConsumerDefinition;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.GroupTypeDefinition;
+import org.openecomp.sdc.be.model.PolicyTypeDefinition;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
+import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.tosca.ToscaError;
+import org.openecomp.sdc.common.datastructure.AuditingFieldsKeysEnum;
+import org.openecomp.sdc.exception.ResponseFormat;
+
+import com.fasterxml.jackson.databind.JsonDeserializer;
+
+import fj.data.Either;
+
+public class ComponentsUtilsTest {
+
+ private ComponentsUtils createTestSubject() {
+ return new ComponentsUtils();
+ }
+
+
+ @Test
+ public void testInit() throws Exception {
+ ComponentsUtils testSubject;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.Init();
+ }
+
+
+ @Test
+ public void testGetAuditingManager() throws Exception {
+ ComponentsUtils testSubject;
+ IAuditingManager result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.getAuditingManager();
+ }
+
+
+ @Test
+ public void testSetAuditingManager() throws Exception {
+ ComponentsUtils testSubject;
+ IAuditingManager auditingManager = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.setAuditingManager(auditingManager);
+ }
+
+
+ @Test
+ public void testAuditResource() throws Exception {
+ ComponentsUtils testSubject;
+ ResponseFormat responseFormat = null;
+ User modifier = null;
+ Resource resource = null;
+ String prevState = "";
+ String prevVersion = "";
+ AuditingActionEnum actionEnum = null;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = null;
+
+ // test 1
+ testSubject = createTestSubject();
+ actionEnum = null;
+ testSubject.auditResource(responseFormat, modifier, resource, prevState, prevVersion, actionEnum,
+ additionalParams);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponse() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = null;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponse(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponse_1() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = null;
+ ComponentTypeEnum type = null;
+ ActionStatus result;
+
+ // test 1
+ testSubject = createTestSubject();
+ storageResponse = null;
+ result = testSubject.convertFromStorageResponse(storageResponse, type);
+ Assert.assertEquals(ActionStatus.GENERAL_ERROR, result);
+ }
+
+
+ @Test
+ public void testConvertFromToscaError() throws Exception {
+ ComponentsUtils testSubject;
+ ToscaError toscaError = null;
+ ActionStatus result;
+
+ // test 1
+ testSubject = createTestSubject();
+ toscaError = null;
+ result = testSubject.convertFromToscaError(toscaError);
+ Assert.assertEquals(ActionStatus.GENERAL_ERROR, result);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForCapabilityType() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForCapabilityType(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForLifecycleType() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForLifecycleType(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForResourceInstance() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ boolean isRelation = false;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForResourceInstance(storageResponse, isRelation);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForResourceInstanceProperty() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForResourceInstanceProperty(storageResponse);
+ }
+
+
+ @Test
+ public void testAuditComponentAdmin() throws Exception {
+ ComponentsUtils testSubject;
+ ResponseFormat responseFormat = null;
+ User modifier = null;
+ Component component = null;
+ String prevState = "";
+ String prevVersion = "";
+ AuditingActionEnum actionEnum = null;
+ ComponentTypeEnum type = null;
+
+ // default test
+ testSubject = createTestSubject();
+ testSubject.auditComponentAdmin(responseFormat, modifier, component, prevState, prevVersion, actionEnum, type);
+ }
+
+
+ @Test
+ public void testAuditComponent() throws Exception {
+ ComponentsUtils testSubject;
+ ResponseFormat responseFormat = null;
+ User modifier = null;
+ Component component = null;
+ String prevState = "";
+ String prevVersion = "";
+ AuditingActionEnum actionEnum = null;
+ ComponentTypeEnum type = null;
+ EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = null;
+
+ // test 1
+ testSubject = createTestSubject();
+ actionEnum = null;
+ testSubject.auditComponent(responseFormat, modifier, component, prevState, prevVersion, actionEnum, type,
+ additionalParams);
+ }
+
+
+ @Test
+ public void testValidateStringNotEmpty_1() throws Exception {
+ ComponentsUtils testSubject;
+ String value = "";
+ Boolean result;
+
+ // test 1
+ testSubject = createTestSubject();
+ value = null;
+ result = testSubject.validateStringNotEmpty(value);
+ Assert.assertEquals(false, result);
+
+ // test 2
+ testSubject = createTestSubject();
+ value = "";
+ result = testSubject.validateStringNotEmpty(value);
+ Assert.assertEquals(false, result);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForAdditionalInformation() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForAdditionalInformation(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromResultStatusEnum() throws Exception {
+ ComponentsUtils testSubject;
+ ResultStatusEnum resultStatus = ResultStatusEnum.ELEMENT_NOT_FOUND;
+ JsonPresentationFields elementType = null;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromResultStatusEnum(resultStatus, elementType);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForConsumer() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForConsumer(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForGroupType() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForGroupType(storageResponse);
+ }
+
+
+ @Test
+ public void testConvertFromStorageResponseForDataType() throws Exception {
+ ComponentsUtils testSubject;
+ StorageOperationStatus storageResponse = StorageOperationStatus.ARTIFACT_NOT_FOUND;
+ ActionStatus result;
+
+ // default test
+ testSubject = createTestSubject();
+ result = testSubject.convertFromStorageResponseForDataType(storageResponse);
+ }
+
+
+
+} \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
index faf70f4047..8acfe6cfea 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/tosca/CsarUtilsTest.java
@@ -27,13 +27,18 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openecomp.sdc.be.config.ConfigurationManager;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.tosca.CsarUtils.NonMetaArtifactInfo;
import org.openecomp.sdc.common.api.ConfigurationSource;
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
+import org.openecomp.sdc.exception.ResponseFormat;
import fj.data.Either;
@@ -44,48 +49,90 @@ public class CsarUtilsTest {
// Init Configuration
String appConfigDir = "src/test/resources/config/catalog-be";
- ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), appConfigDir);
+ ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(),
+ appConfigDir);
ConfigurationManager configurationManager = new ConfigurationManager(configurationSource);
}
-
+
@Test
- public void testValidateNonMetaArtifactHappyScenario(){
+ public void testValidateNonMetaArtifactHappyScenario() {
String artifactPath = "Artifacts/Deployment/YANG_XML/myYang.xml";
byte[] payloadData = "some payload data".getBytes();
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft() );
- assertTrue(collectedWarningMessages.isEmpty() );
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+ assertTrue(collectedWarningMessages.isEmpty());
artifactPath = "Artifacts/Informational/OTHER/someArtifact.xml";
eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft() );
- assertTrue(collectedWarningMessages.isEmpty() );
+ assertTrue(eitherNonMetaArtifact.isLeft());
+ assertTrue(collectedWarningMessages.isEmpty());
}
-
+
@Test
- public void testValidateNonMetaArtifactScenarioWithWarnnings(){
+ public void testValidateNonMetaArtifactScenarioWithWarnnings() {
String artifactPath = "Artifacts/Deployment/Buga/myYang.xml";
byte[] payloadData = "some payload data".getBytes();
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft() );
-
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isLeft());
+
artifactPath = "Artifacts/Informational/Buga2/someArtifact.xml";
eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isLeft() );
-
- assertTrue(collectedWarningMessages.size() == 1 );
+ assertTrue(eitherNonMetaArtifact.isLeft());
+
+ assertTrue(collectedWarningMessages.size() == 1);
assertTrue(collectedWarningMessages.values().iterator().next().size() == 2);
}
-
+
@Test
- public void testValidateNonMetaArtifactUnhappyScenario(){
+ public void testValidateNonMetaArtifactUnhappyScenario() {
String artifactPath = "Artifacts/Buga/YANG_XML/myYang.xml";
byte[] payloadData = "some payload data".getBytes();
Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
- Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
- assertTrue(eitherNonMetaArtifact.isRight() );
- assertTrue( !collectedWarningMessages.isEmpty() );
+ Either<NonMetaArtifactInfo, Boolean> eitherNonMetaArtifact = CsarUtils.validateNonMetaArtifact(artifactPath,
+ payloadData, collectedWarningMessages);
+ assertTrue(eitherNonMetaArtifact.isRight());
+ assertTrue(!collectedWarningMessages.isEmpty());
+ }
+
+ private CsarUtils createTestSubject() {
+ return new CsarUtils();
}
+
+
+ @Test
+ public void testExtractVfcsArtifactsFromCsar() throws Exception {
+ Map<String, byte[]> csar = null;
+ Map<String, List<ArtifactDefinition>> result;
+
+ // test 1
+ csar = null;
+ result = CsarUtils.extractVfcsArtifactsFromCsar(csar);
+ Assert.assertEquals(new HashMap<String, List<ArtifactDefinition>>() , result);
+ }
+
+
+ @Test
+ public void testHandleWarningMessages() throws Exception {
+ Map<String, Set<List<String>>> collectedWarningMessages = new HashMap<>();
+
+ // default test
+ CsarUtils.handleWarningMessages(collectedWarningMessages);
+ }
+
+
+ @Test
+ public void testValidateNonMetaArtifact() throws Exception {
+ String artifactPath = "";
+ byte[] payloadData = new byte[] { ' ' };
+ Map<String, Set<List<String>>> collectedWarningMessages = null;
+ Either<NonMetaArtifactInfo, Boolean> result;
+
+ // default test
+ result = CsarUtils.validateNonMetaArtifact(artifactPath, payloadData, collectedWarningMessages);
+ }
+
}