summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/test/java/org
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-07-17 21:12:03 +0300
committerMichael Lando <ml636r@att.com>2017-07-17 21:12:03 +0300
commit75aacbbe1acf78fa53378f07f0a8c7769449a17e (patch)
tree68a9799eb8f4704dd9a3d513401df9bb11af7739 /catalog-be/src/test/java/org
parentdec02e7cc74e1c401be51bd9d266575e1e008f5f (diff)
[SDC] rebase 1710 code
Change-Id: I532ed68979fee7840ea8a5395e7e965b155fb9f9 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-be/src/test/java/org')
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java18
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java69
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java5
4 files changed, 74 insertions, 26 deletions
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
index 6af338ebcf..68d47590f0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/HealthCheckBusinessLogicTest.java
@@ -23,19 +23,30 @@ package org.openecomp.sdc.be.components;
import java.util.ArrayList;
import java.util.List;
+import javax.annotation.Resource;
+
import org.junit.Test;
import org.openecomp.sdc.be.components.impl.HealthCheckBusinessLogic;
+import org.openecomp.sdc.be.dao.cassandra.schema.SdcSchemaUtils;
+import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
+import org.openecomp.sdc.be.resources.data.UserData;
import org.openecomp.sdc.common.api.HealthCheckInfo;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckComponent;
import org.openecomp.sdc.common.api.HealthCheckInfo.HealthCheckStatus;
+import com.datastax.driver.core.Cluster;
+
+import fj.data.Either;
+
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
public class HealthCheckBusinessLogicTest {
HealthCheckBusinessLogic healthCheckBusinessLogic = new HealthCheckBusinessLogic();
-
+
@Test
public void checkStausUpdated() {
@@ -51,18 +62,13 @@ public class HealthCheckBusinessLogicTest {
HealthCheckInfo checkInfoTitanUp = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.UP, null, null);
HealthCheckInfo checkInfoTitanDown = new HealthCheckInfo(HealthCheckComponent.TITAN, HealthCheckStatus.DOWN, null, null);
- HealthCheckInfo checkInfoEsUp = new HealthCheckInfo(HealthCheckComponent.ES, HealthCheckStatus.UP, null, null);
- HealthCheckInfo checkInfoEsDown = new HealthCheckInfo(HealthCheckComponent.ES, HealthCheckStatus.DOWN, null, null);
-
/*
* HealthCheckInfo checkInfoUebUp = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.UP, null, null); HealthCheckInfo checkInfoUebDown = new HealthCheckInfo(HealthCheckComponent.DE, HealthCheckStatus.DOWN, null, null);
*/
checkInfosLeft.add(checkInfoTitanUp);
- checkInfosLeft.add(checkInfoEsUp);
checkInfosRight.add(checkInfoTitanUp);
- checkInfosRight.add(checkInfoEsUp);
statusChanged = healthCheckBusinessLogic.anyStatusChanged(checkInfosLeft, checkInfosRight);
assertFalse("check false", statusChanged);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
index 09f2570a35..f0b2865373 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
@@ -130,7 +130,7 @@ public class ResourceImportManagerTest {
testSetDerivedFrom(resource);
testSetProperties(resource);
- Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true));
+ Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false));
}
@Test
@@ -159,7 +159,7 @@ public class ResourceImportManagerTest {
Mockito.verify(resourceBusinessLogic, Mockito.times(0)).createOrUpdateResourceByImport(Mockito.any(Resource.class), Mockito.eq(user), Mockito.eq(true), Mockito.eq(false), Mockito.eq(true));
- Mockito.verify(resourceBusinessLogic, Mockito.times(0)).propagateStateToCertified(Mockito.eq(user), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true));
+ Mockito.verify(resourceBusinessLogic, Mockito.times(0)).propagateStateToCertified(Mockito.eq(user), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false));
}
@@ -181,7 +181,7 @@ public class ResourceImportManagerTest {
Resource resource = createResource.left().value().left;
testSetCapabilities(resource);
- Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true));
+ Mockito.verify(resourceBusinessLogic, Mockito.times(1)).propagateStateToCertified(Mockito.eq(user), Mockito.eq(resource), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false));
Mockito.verify(resourceBusinessLogic, Mockito.times(1)).createOrUpdateResourceByImport(resource, user, true, false, true);
}
@@ -215,7 +215,7 @@ public class ResourceImportManagerTest {
}
});
- when(resourceBusinessLogic.propagateStateToCertified(Mockito.any(User.class), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true)))
+ when(resourceBusinessLogic.propagateStateToCertified(Mockito.any(User.class), Mockito.any(Resource.class), Mockito.any(LifecycleChangeInfoWithAction.class), Mockito.eq(false), Mockito.eq(true), Mockito.eq(false)))
.thenAnswer(new Answer<Either<Resource, ResponseFormat>>() {
public Either<Resource, ResponseFormat> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
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 f6d2b6bf84..bbfa8bf236 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
@@ -49,9 +49,7 @@ import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
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.GraphVertex;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -67,6 +65,7 @@ import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
+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;
@@ -110,6 +109,7 @@ public class ResourceBusinessLogicTest {
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";
final ServletContext servletContext = Mockito.mock(ServletContext.class);
IAuditingManager iAuditingManager = null;
@@ -118,6 +118,7 @@ public class ResourceBusinessLogicTest {
UserBusinessLogic mockUserAdmin = Mockito.mock(UserBusinessLogic.class);
ToscaOperationFacade toscaOperationFacade = Mockito.mock(ToscaOperationFacade.class);
NodeTypeOperation nodeTypeOperation = Mockito.mock(NodeTypeOperation.class);
+ NodeTemplateOperation nodeTemplateOperation = Mockito.mock(NodeTemplateOperation.class);
TopologyTemplateOperation topologyTemplateOperation = Mockito.mock(TopologyTemplateOperation.class);
final LifecycleBusinessLogic lifecycleBl = Mockito.mock(LifecycleBusinessLogic.class);
final ICapabilityTypeOperation capabilityTypeOperation = Mockito.mock(ICapabilityTypeOperation.class);
@@ -135,8 +136,9 @@ public class ResourceBusinessLogicTest {
Resource resourceResponse = null;
Resource genericVF = null;
Resource genericVFC = null;
+ Resource genericPNF = null;
ComponentsUtils componentsUtils = new ComponentsUtils();
- ArtifactsBusinessLogic artifactManager = Mockito.mock(ArtifactsBusinessLogic.class);
+ ArtifactsBusinessLogic artifactManager = new ArtifactsBusinessLogic();
CsarOperation csarOperation = Mockito.mock(CsarOperation.class);
Map<String, DataTypeDefinition> emptyDataTypes = new HashMap<String, DataTypeDefinition>();
@@ -187,6 +189,7 @@ public class ResourceBusinessLogicTest {
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);
Either<Boolean, StorageOperationStatus> validateDerivedExists = Either.left(true);
when(toscaOperationFacade.validateToscaResourceNameExists("Root")).thenReturn(validateDerivedExists);
@@ -195,14 +198,7 @@ public class ResourceBusinessLogicTest {
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);
-
- ArtifactDefinition artifactDef = new ArtifactDefinition();
- artifactDef.setUniqueId("123.123");
- Either<ArtifactDefinition, StorageOperationStatus> returnEither = Either.left(artifactDef);
- when(artifactManager.createArtifactPlaceHolderInfo(Mockito.anyString(), Mockito.anyString(), Mockito.anyMap(), Mockito.any(User.class), Mockito.any(ArtifactGroupTypeEnum.class))).thenReturn(artifactDef);
-
- when(artifactManager.addHeatEnvArtifact(Mockito.any(ArtifactDefinition.class), Mockito.any(ArtifactDefinition.class), Mockito.anyString(), Mockito.any(NodeTypeEnum.class), Mockito.anyString())).thenReturn(returnEither);
-
+
// createResource
resourceResponse = createResourceObject(true);
Either<Resource, StorageOperationStatus> eitherCreate = Either.left(resourceResponse);
@@ -213,6 +209,7 @@ public class ResourceBusinessLogicTest {
when(applicationDataTypeCache.getAll()).thenReturn(Either.left(emptyDataTypes));
// BL object
+ artifactManager.nodeTemplateOperation = nodeTemplateOperation;
bl = new ResourceBusinessLogic();
bl.setElementDao(mockElementDao);
bl.setUserAdmin(mockUserAdmin);
@@ -281,6 +278,7 @@ public class ResourceBusinessLogicTest {
resource.setDerivedFrom(template);
resource.setVendorName("Motorola");
resource.setVendorRelease("1.0.0");
+ resource.setResourceVendorModelNumber("");
resource.setContactId("ya5467");
resource.setIcon("MyIcon");
resource.setCsarUUID("valid_vf.csar");
@@ -364,6 +362,7 @@ public class ResourceBusinessLogicTest {
testVendorNameWrongFormatCreate();
testVendorReleaseWrongFormat();
testVendorReleaseExceedsLimitCreate();
+ testResourceVendorModelNumberExceedsLimit();
testResourceVendorNameMissing();
testResourceVendorReleaseMissing();
testResourceCategoryExist();
@@ -667,13 +666,23 @@ public class ResourceBusinessLogicTest {
private void testVendorNameExceedsLimit() {
Resource resourceExccedsVendorNameLimit = createResourceObject(false);
- String tooLongVendorName = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
+ String tooLongVendorName = "h1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9Eh1KSyJh9E";
resourceExccedsVendorNameLimit.setVendorName(tooLongVendorName);
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);
}
+
+ 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);
+ assertTrue(createResponse.isRight());
+ assertResponse(createResponse, ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH);
+ }
private void testVendorNameWrongFormatCreate() {
Resource resource = createResourceObject(false);
@@ -1641,7 +1650,7 @@ public class ResourceBusinessLogicTest {
@Test
- public void testGeneratedInputs() {
+ public void testVFGeneratedInputs() {
Resource resource = createVF();
List<InputDefinition> inputs = resource.getInputs();
@@ -1654,7 +1663,7 @@ public class ResourceBusinessLogicTest {
}
@Test
- public void testUpdateGenericInputsToLatestOnCheckout() {
+ public void testVFUpdateGenericInputsToLatestOnCheckout() {
//create a VF that is derived from generic version 1.0
Resource resource = createVF();
@@ -1680,7 +1689,7 @@ public class ResourceBusinessLogicTest {
@Test
- public void testUpdateGenericInputsToLatestOnCheckoutNotPerformed() {
+ public void testVFUpdateGenericInputsToLatestOnCheckoutNotPerformed() {
//create a VF that is derived from generic version 1.0
Resource resource = createVF();
@@ -1713,6 +1722,21 @@ public class ResourceBusinessLogicTest {
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){
+ 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);
@@ -1726,6 +1750,19 @@ public class ResourceBusinessLogicTest {
return createResponse.left().value();
}
+ private Resource createPNF() {
+
+ genericPNF = setupGenericTypeMock(GENERIC_PNF_NAME);
+ 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);
+ assertTrue(createResponse.isLeft());
+ return createResponse.left().value();
+ }
+
private Resource setupGenericTypeMock(String toscaName) {
@@ -1746,4 +1783,6 @@ public class ResourceBusinessLogicTest {
return genericType;
}
+
+
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
index 69b08bd1c1..1488f13015 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/lifecycle/LifecycleTestBase.java
@@ -50,6 +50,7 @@ import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
@@ -168,7 +169,8 @@ public class LifecycleTestBase {
resource.setVendorRelease("1.0.0");
resource.setContactId("yavivi");
resource.setIcon("MyIcon.jpg");
-
+ resource.setToscaType(ToscaElementTypeEnum.NodeType.getValue());
+
return resource;
}
@@ -191,6 +193,7 @@ public class LifecycleTestBase {
resource.setVendorRelease("1.0.0");
resource.setContactId("yavivi");
resource.setIcon("MyIcon.jpg");
+ resource.setToscaType(ToscaElementTypeEnum.NodeType.getValue());
return resource;
}