diff options
author | ys9693 <ys9693@att.com> | 2020-01-19 13:50:02 +0200 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-01-22 12:33:31 +0000 |
commit | 16a9fce0e104a38371a9e5a567ec611ae3fc7f33 (patch) | |
tree | 03a2aff3060ddb5bc26a90115805a04becbaffc9 /catalog-model/src/test | |
parent | aa83a2da4f911c3ac89318b8e9e8403b072942e1 (diff) |
Catalog alignment
Issue-ID: SDC-2724
Signed-off-by: ys9693 <ys9693@att.com>
Change-Id: I52b4aacb58cbd432ca0e1ff7ff1f7dd52099c6fe
Diffstat (limited to 'catalog-model/src/test')
26 files changed, 342 insertions, 235 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java index 487bd7d859..d256cd15c8 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstInputsMapTest.java @@ -71,7 +71,7 @@ public class ComponentInstInputsMapTest { // default test testSubject = createTestSubject(); - testSubject.setComponentInstanceProperties(componentInstanceProperties); + testSubject.setComponentInstancePropertiesToPolicies(componentInstanceProperties); } @Test @@ -100,7 +100,7 @@ public class ComponentInstInputsMapTest { testSubject.setComponentInstanceInputsMap(inputs); testSubject.resolvePropertiesToDeclare(); testSubject = createTestSubject(); - testSubject.setComponentInstanceProperties(inputs); + testSubject.setComponentInstancePropertiesToPolicies(inputs); testSubject.resolvePropertiesToDeclare(); testSubject = createTestSubject(); testSubject.setPolicyProperties(inputs); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstancePropertyTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstancePropertyTest.java index d36ef9ebba..c6e96569ae 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstancePropertyTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ComponentInstancePropertyTest.java @@ -20,13 +20,13 @@ package org.openecomp.sdc.be.model; +import org.junit.Ignore; import org.junit.Test; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyRule; import java.util.List; - public class ComponentInstancePropertyTest { private ComponentInstanceProperty createTestSubject() { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java index b4336e491d..9ae89148c1 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/LifeCycleTransitionEnumTest.java @@ -59,7 +59,6 @@ public class LifeCycleTransitionEnumTest { result = LifeCycleTransitionEnum.getFromDisplayName("mock"); } catch (Exception e) { // TODO Auto-generated catch block - e.printStackTrace(); } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java index 046161ab40..3cd14d8b27 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ModelTestBase.java @@ -45,6 +45,8 @@ public class ModelTestBase { protected static ConfigurationManager configurationManager; protected static final String CONTAINER_ID = "containerId"; protected static final String CONTAINER_NAME = "containerName"; + static Configuration.EnvironmentContext environmentContext = new Configuration.EnvironmentContext(); + static Configuration.HeatDeploymentArtifactTimeout heatDeploymentArtifactTimeout = new Configuration.HeatDeploymentArtifactTimeout(); public static void init() { String appConfigDir = "src/test/resources/config"; @@ -55,7 +57,11 @@ public class ModelTestBase { Configuration configuration = new Configuration(); configuration.setJanusGraphInMemoryGraph(true); + environmentContext.setDefaultValue("General_Revenue-Bearing"); + configuration.setEnvironmentContext(environmentContext); + heatDeploymentArtifactTimeout.setDefaultMinutes(30); + configuration.setHeatArtifactDeploymentTimeout(heatDeploymentArtifactTimeout); Map<String, Object> deploymentRIArtifacts = new HashMap<>(); ArtifactDataDefinition artifactInfo = new ArtifactDataDefinition(); Object artifactDataObj = new HashMap<String, Object>(); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java index 7a7d91b953..790ce10653 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ResourceTest.java @@ -444,7 +444,7 @@ public class ResourceTest extends ModelConfDependentTest{ testSubject = createTestSubject(); Resource resource = new Resource(); resource.setComponentInstancesRelations(new LinkedList<RequirementCapabilityRelDef>()); - result = testSubject.groupRelationsByInstanceName(resource); + result = testSubject.groupRelationsFromCsarByInstanceName(resource); } @Test diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java index 2cf808e99e..b677548773 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/ServiceTest.java @@ -20,13 +20,38 @@ package org.openecomp.sdc.be.model; +import org.junit.BeforeClass; import org.junit.Test; +import org.openecomp.sdc.be.config.Configuration; +import org.openecomp.sdc.be.config.ConfigurationManager; import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition; +import org.openecomp.sdc.common.api.ConfigurationSource; +import org.openecomp.sdc.common.impl.ExternalConfiguration; +import org.openecomp.sdc.common.impl.FSConfigurationSource; import java.util.Map; public class ServiceTest { + protected static ConfigurationManager configurationManager; + static Configuration.EnvironmentContext environmentContext = new Configuration.EnvironmentContext(); + + @BeforeClass + public static void init() { + String appConfigDir = "src/test/resources/config"; + ConfigurationSource configurationSource = new FSConfigurationSource(ExternalConfiguration.getChangeListener(), + appConfigDir); + configurationManager = new ConfigurationManager(configurationSource); + + Configuration configuration = new Configuration(); + + configuration.setJanusGraphInMemoryGraph(true); + environmentContext.setDefaultValue("General_Revenue-Bearing"); + configuration.setEnvironmentContext(environmentContext); + + configurationManager.setConfiguration(configuration); + } + private Service createTestSubject() { return new Service(); } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java index 645f857f31..35d943d573 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/GroupsOperationTest.java @@ -117,7 +117,7 @@ public class GroupsOperationTest extends ModelTestBase { private GroupDefinition createGroupDefinition(String id) { GroupDefinition groupDefinition = new GroupDefinition(); groupDefinition.setUniqueId(id); - groupDefinition.setName("name" + id); + groupDefinition.setInvariantName("name" + id); return groupDefinition; } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java index ef820ed5ad..15653c0bbd 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaElementOperationCatalogTest.java @@ -21,6 +21,8 @@ package org.openecomp.sdc.be.model.jsonjanusgraph.operations; import fj.data.Either; +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.junit.Before; @@ -37,6 +39,7 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.model.catalog.CatalogComponent; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import static org.junit.Assert.assertEquals; @@ -46,14 +49,23 @@ import static org.mockito.Mockito.when; @RunWith(MockitoJUnitRunner.class) public class ToscaElementOperationCatalogTest { + private static final String UPDATER_ID = "m08740"; private ArrayList<Vertex> vertexList = new ArrayList<>(); @Mock Vertex vertex; @Mock + Edge edge; + @Mock + Vertex outVertex; + @Mock + Iterator<Edge> edges; + @Mock JanusGraphDao janusGraphDao; @Mock VertexProperty<Object> property; + @Mock + VertexProperty<Object> updaterProperty; @InjectMocks private ToscaElementOperation toscaOperation = new TopologyTemplateOperation(); @@ -67,6 +79,20 @@ public class ToscaElementOperationCatalogTest { when(vertex.property(GraphPropertiesDictionary.METADATA.getProperty())).thenReturn(property); } + private void stubEmptyUpdater() { + when(vertex.edges(Direction.IN, EdgeLabelEnum.STATE.name())).thenReturn(edges); + when(edges.hasNext()).thenReturn(false); + } + + private void stubExistingUpdater() { + when(vertex.edges(Direction.IN, EdgeLabelEnum.STATE.name())).thenReturn(edges); + when(edges.hasNext()).thenReturn(true); + when(edges.next()).thenReturn(edge); + when(edge.outVertex()).thenReturn(outVertex); + when(updaterProperty.value()).thenReturn(UPDATER_ID); + when(outVertex.property(GraphPropertiesDictionary.USERID.getProperty())).thenReturn(updaterProperty); + } + @Test public void getComponentFromCatalogWhenDeleteIsTrue() { final String vertexJsonIsDeletedTrue = "{\"lifecycleState\":\"CERTIFIED\",\"componentType\":\"RESOURCE\",\"vendorRelease\":\"1\",\"contactId\":\"ah7840\",\"lastUpdateDate\":1496119811038,\"icon\":\"att\",\"description\":\"Cloud\",\"creationDate\":1459432094781,\"vendorName\":\"AT&T\",\"mandatory\":false,\"version\":\"1.0\",\"tags\":[\"Cloud\"],\"highestVersion\":true,\"systemName\":\"Cloud\",\"name\":\"Cloud\",\"isDeleted\":true,\"invariantUuid\":\"ab5263fd-115c-41f2-8d0c-8b9279bce2b2\",\"UUID\":\"208cf7df-68a1-4ae7-afc9-409ea8012332\",\"normalizedName\":\"cloud\",\"toscaResourceName\":\"org.openecomp.resource.Endpoint.Cloud\",\"uniqueId\":\"9674e7e1-bc1a-41fe-b503-fbe996801475\",\"resourceType\":\"VFC\"}"; @@ -77,6 +103,7 @@ public class ToscaElementOperationCatalogTest { @Test public void getComponentFromCatalogWhenDeleteNotFound() { + stubEmptyUpdater(); final String vertexJsonIsDeletedNotFound = "{\"lifecycleState\":\"CERTIFIED\",\"componentType\":\"RESOURCE\",\"vendorRelease\":\"1\",\"contactId\":\"ah7840\",\"lastUpdateDate\":1496119811038,\"icon\":\"att\",\"description\":\"Cloud\",\"creationDate\":1459432094781,\"vendorName\":\"AT&T\",\"mandatory\":false,\"version\":\"1.0\",\"tags\":[\"Cloud\"],\"highestVersion\":true,\"systemName\":\"Cloud\",\"name\":\"Cloud\",\"invariantUuid\":\"ab5263fd-115c-41f2-8d0c-8b9279bce2b2\",\"UUID\":\"208cf7df-68a1-4ae7-afc9-409ea8012332\",\"normalizedName\":\"cloud\",\"toscaResourceName\":\"org.openecomp.resource.Endpoint.Cloud\",\"uniqueId\":\"9674e7e1-bc1a-41fe-b503-fbe996801475\",\"resourceType\":\"VFC\"}"; when(property.value()).thenReturn(vertexJsonIsDeletedNotFound); List<CatalogComponent> componentList = toscaOperation.getElementCatalogData(true, null).left().value(); @@ -85,9 +112,12 @@ public class ToscaElementOperationCatalogTest { @Test public void getComponentFromCatalogWhenDeleteIsFalse() { + stubExistingUpdater(); final String vertexJsonIsDeletedFalse = "{\"lifecycleState\":\"CERTIFIED\",\"componentType\":\"RESOURCE\",\"vendorRelease\":\"1\",\"contactId\":\"ah7840\",\"lastUpdateDate\":1496119811038,\"icon\":\"att\",\"description\":\"Cloud\",\"creationDate\":1459432094781,\"vendorName\":\"AT&T\",\"mandatory\":false,\"version\":\"1.0\",\"tags\":[\"Cloud\"],\"highestVersion\":true,\"systemName\":\"Cloud\",\"name\":\"Cloud\",\"isDeleted\":false,\"invariantUuid\":\"ab5263fd-115c-41f2-8d0c-8b9279bce2b2\",\"UUID\":\"208cf7df-68a1-4ae7-afc9-409ea8012332\",\"normalizedName\":\"cloud\",\"toscaResourceName\":\"org.openecomp.resource.Endpoint.Cloud\",\"uniqueId\":\"9674e7e1-bc1a-41fe-b503-fbe996801475\",\"resourceType\":\"VFC\"}"; when(property.value()).thenReturn(vertexJsonIsDeletedFalse); List<CatalogComponent> componentList = toscaOperation.getElementCatalogData(true, null).left().value(); assertEquals(1, componentList.size()); + assertEquals(UPDATER_ID, componentList.get(0).getLastUpdaterUserId()); } + } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java index 424ea2bd17..caf1805b83 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java @@ -49,6 +49,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum; import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields; +import org.openecomp.sdc.be.datatypes.enums.PromoteVersionEnum; import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum; import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum; import org.openecomp.sdc.be.model.Component; @@ -442,10 +443,7 @@ public class ToscaOperationFacadeTest { Set<LifecycleStateEnum> lastStateStates = new HashSet<>(); lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); lifecycleStates.add(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); - lifecycleStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION); - lifecycleStates.add(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS); lifecycleStates.add(LifecycleStateEnum.CERTIFIED); - lastStateStates.add(LifecycleStateEnum.READY_FOR_CERTIFICATION); ComponentTypeEnum componentType = ComponentTypeEnum.RESOURCE; List<ToscaElement> toscaEleList = new ArrayList<>(); ToscaElement toscaElement = getToscaElementForTest(); @@ -702,7 +700,7 @@ public class ToscaOperationFacadeTest { GraphVertex vertex = getTopologyTemplateVertex(); when(janusGraphDaoMock.getVertexById(eq(componentId), eq(JsonParseFlagEnum.NoParse))).thenReturn(Either.left(vertex)); when(topologyTemplateOperationMock.updatePolicyOfToscaElement(eq(vertex), any(PolicyDefinition.class))).thenReturn(status); - return testInstance.updatePolicyOfComponent(componentId, policy); + return testInstance.updatePolicyOfComponent(componentId, policy, PromoteVersionEnum.NONE); } private void removePolicyFromComponentWithStatus(StorageOperationStatus status) { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java index 4df2c5b79b..98cec1977e 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/UpgradeOperationTest.java @@ -119,9 +119,8 @@ public class UpgradeOperationTest extends ModelTestBase { private void initGraphForTest() { user = new User("Jim", "Tom", "jt123a", "1@mail.com", "DESIGNER", System.currentTimeMillis()); - Either<User, StorageOperationStatus> saveUserData = userAdminOperation.saveUserData(user); - assertThat(saveUserData.isLeft()).isTrue(); - + userAdminOperation.saveUserData(user); + GraphTestUtils.createRootCatalogVertex(janusGraphDao); resourceCategory = createResourceCategories(); serviceCategory = createServiceCategory(); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java index dedf84cd76..169a844e3a 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/AdditionalInformationOperationTest.java @@ -38,7 +38,6 @@ import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.AdditionalInformationDefinition; import org.openecomp.sdc.be.model.ModelTestBase; -import org.openecomp.sdc.be.model.operations.api.IAdditionalInformationOperation; import org.openecomp.sdc.be.model.operations.impl.util.OperationTestsUtil; import org.openecomp.sdc.be.resources.data.UserData; import org.springframework.test.context.ContextConfiguration; @@ -65,7 +64,7 @@ public class AdditionalInformationOperationTest extends ModelTestBase { private JanusGraphGenericDao janusGraphDao; @javax.annotation.Resource(name = "additional-information-operation") - private IAdditionalInformationOperation additionalInformationOperation; + private AdditionalInformationOperation additionalInformationOperation; @Before public void createUserAndCategory() { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java index 10553a0f89..7c8dc3c805 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ArtifactOperationTest.java @@ -49,9 +49,6 @@ import java.util.List; import java.util.Map; import static org.junit.Assert.*; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") @@ -341,6 +338,9 @@ public class ArtifactOperationTest extends ModelTestBase { assertTrue(result.isLeft()); Service resultService = result.left().value(); + // assertEquals("check resource unique id", + // UniqueIdBuilder.buildServiceUniqueId(serviceName, serviceVersion), + // resultService.getUniqueId()); assertEquals("check resource state", LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT, resultService.getLifecycleState()); return resultService; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java index b003c93fc1..5391410431 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java @@ -62,7 +62,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.*; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:application-context-test.xml") @@ -130,6 +130,10 @@ public class CapabilityTypeOperationTest extends ModelTestBase { CapabilityTypeDefinition capabilityTypeDefinition = createCapabilityTypeDef("tosca.capabilities.Container2", "desc1", "derivedFrom"); Either<CapabilityTypeDefinition, StorageOperationStatus> addCapabilityType1 = capabilityTypeOperation.addCapabilityType(capabilityTypeDefinition, true); + // assertEquals("check capability type parent not exist", + // StorageOperationStatus.INVALID_ID, + // addCapabilityType1.right().value()); + // TODO: esofer change to INVALID_ID assertEquals("check capability type parent not exist", StorageOperationStatus.NOT_FOUND, addCapabilityType1.right().value()); } @@ -510,4 +514,5 @@ public class CapabilityTypeOperationTest extends ModelTestBase { return false; } } + } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java index 029c638711..6ef4a61fcd 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java @@ -71,6 +71,7 @@ public class ComponentInstanceOperationTest { componentInstanceOperation.setJanusGraphGenericDao(janusGraphGenericDao); } + @Test public void testUpdateInputValueInResourceInstance() { ComponentInstanceInput input = null; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java index 2c00d3d952..17e2430d82 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java @@ -456,17 +456,6 @@ public class ElementOperationTest extends ModelTestBase { @Test - public void testGetDefaultHeatTimeout() throws Exception { - ElementOperation testSubject; - Either<Integer, ActionStatus> result; - - // default test - testSubject = createTestSubject(); - result = testSubject.getDefaultHeatTimeout(); - } - - - @Test public void testGetResourceTypesMap() throws Exception { ElementOperation testSubject; Either<Map<String, String>, ActionStatus> result; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java index 532e76bba8..975181d471 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/InterfaceLifecycleOperationTest.java @@ -58,7 +58,6 @@ import org.junit.Assert; import static org.junit.Assert.assertNotNull; - import java.util.ArrayList; import java.util.Collections; import java.util.List; diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverterTest.java deleted file mode 100644 index f5bfc96ca4..0000000000 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/Neo4jStatusConverterTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2019 Nokia. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdc.be.model.operations.impl; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openecomp.sdc.be.dao.neo4j.Neo4jOperationStatus; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; - -public class Neo4jStatusConverterTest { - - @Test - public void shouldConvertNeo4jStatusToStorageStatus() { - assertEquals(StorageOperationStatus.GENERAL_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(null)); - assertEquals(StorageOperationStatus.OK, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.OK)); - assertEquals(StorageOperationStatus.CONNECTION_FAILURE, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.NOT_CONNECTED)); - assertEquals(StorageOperationStatus.PERMISSION_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.NOT_AUTHORIZED)); - assertEquals(StorageOperationStatus.STORAGE_NOT_AVAILABLE, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.DB_NOT_AVAILABLE)); - assertEquals(StorageOperationStatus.HTTP_PROTOCOL_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.HTTP_PROTOCOL_ERROR)); - assertEquals(StorageOperationStatus.READ_ONLY_STORAGE, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.DB_READ_ONLY)); - assertEquals(StorageOperationStatus.BAD_REQUEST, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.BAD_REQUEST)); - assertEquals(StorageOperationStatus.STORAGE_LEGACY_INDEX_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.LEGACY_INDEX_ERROR)); - assertEquals(StorageOperationStatus.SCHEMA_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.SCHEMA_ERROR)); - assertEquals(StorageOperationStatus.TRANSACTION_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.TRANSACTION_ERROR)); - assertEquals(StorageOperationStatus.EXEUCTION_FAILED, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.EXECUTION_FAILED)); - assertEquals(StorageOperationStatus.ENTITY_ALREADY_EXISTS, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.ENTITY_ALREADY_EXIST)); - assertEquals(StorageOperationStatus.BAD_REQUEST, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.WRONG_INPUT)); - assertEquals(StorageOperationStatus.GENERAL_ERROR, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.GENERAL_ERROR)); - assertEquals(StorageOperationStatus.OPERATION_NOT_SUPPORTED, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.NOT_SUPPORTED)); - assertEquals(StorageOperationStatus.NOT_FOUND, - Neo4jStatusConverter.convertNeo4jStatusToStorageStatus(Neo4jOperationStatus.NOT_FOUND)); - } -}
\ No newline at end of file diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java index aef1642e3f..a8a201d9eb 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ToscaElementLifecycleOperationTest.java @@ -23,6 +23,7 @@ package org.openecomp.sdc.be.model.operations.impl; import org.janusgraph.core.JanusGraph; import org.janusgraph.core.JanusGraphVertex; import fj.data.Either; +import org.apache.tinkerpop.gremlin.structure.io.IoCore; import org.junit.*; import org.junit.rules.TestName; import org.junit.runner.RunWith; @@ -59,6 +60,10 @@ import org.openecomp.sdc.common.util.ValidationUtils; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; import java.util.*; import static org.junit.Assert.assertEquals; @@ -170,14 +175,6 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop66, JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - - res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(res.isLeft()); id = res.left().value().getUniqueId(); @@ -212,14 +209,6 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop88, JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - - res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - res = lifecycleOperation.certifyToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(res.isLeft()); id = res.left().value().getUniqueId(); @@ -238,33 +227,10 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { status = nodeTypeOperation.addToscaDataToToscaElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, prop99, JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - res = lifecycleOperation.requestCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - - res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - status = nodeTypeOperation.deleteToscaDataElement(id, EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, "prop99", JsonPresentationFields.NAME); assertSame(status, StorageOperationStatus.OK); - // cancel certification - res = lifecycleOperation.cancelOrFailCertification(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), LifecycleStateEnum.READY_FOR_CERTIFICATION); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - - res = lifecycleOperation.startCertificationToscaElement(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); - - // fail certification - res = lifecycleOperation.cancelOrFailCertification(id, modifierVertex.getUniqueId(), ownerVertex.getUniqueId(), LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); - assertTrue(res.isLeft()); - id = res.left().value().getUniqueId(); verifyInCatalogData(4, null); - // exportGraphMl(janusGraphDao.getGraph().left().value()); - } @Test @@ -296,7 +262,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { expectedIds.add(vertex4.getUniqueId()); verifyInCatalogData(4, expectedIds); - Either<ToscaElement, StorageOperationStatus> res = lifecycleOperation.undoCheckout(vertex4.getUniqueId()); + lifecycleOperation.undoCheckout(vertex4.getUniqueId()); expectedIds.remove(vertex4.getUniqueId()); verifyInCatalogData(3, expectedIds); @@ -304,7 +270,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { expectedIds.add(vertex4.getUniqueId()); verifyInCatalogData(4, expectedIds); - res = lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) vertex4.getMetadataProperty(GraphPropertyEnum.STATE)), vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + lifecycleOperation.checkinToscaELement(LifecycleStateEnum.findState((String) vertex4.getMetadataProperty(GraphPropertyEnum.STATE)), vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); Either<ToscaElement, StorageOperationStatus> certifyToscaElement = lifecycleOperation.certifyToscaElement(vertex4.getUniqueId(), modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(certifyToscaElement.isLeft()); expectedIds.remove(vertex4.getUniqueId()); @@ -312,7 +278,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { expectedIds.add(certifiedId); verifyInCatalogData(4, expectedIds); - res = lifecycleOperation.checkoutToscaElement(certifiedId, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); + Either<ToscaElement, StorageOperationStatus> res = lifecycleOperation.checkoutToscaElement(certifiedId, modifierVertex.getUniqueId(), ownerVertex.getUniqueId()); assertTrue(certifyToscaElement.isLeft()); expectedIds.add(res.left().value().getUniqueId()); verifyInCatalogData(5, expectedIds); @@ -435,6 +401,24 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { derivedFrom.add("root"); vf.setDerivedFrom(derivedFrom); + // Map<String, PropertyDataDefinition> properties = new HashMap<>(); + // PropertyDataDefinition prop1 = new PropertyDataDefinition(); + // prop1.setName("prop1"); + // prop1.setDefaultValue("def1"); + // + // properties.put("prop1", prop1); + // + // PropertyDataDefinition prop2 = new PropertyDataDefinition(); + // prop2.setName("prop2"); + // prop2.setDefaultValue("def2"); + // properties.put("prop2", prop2); + // + // PropertyDataDefinition prop3 = new PropertyDataDefinition(); + // prop3.setName("prop3"); + // prop3.setDefaultValue("def3"); + // properties.put("prop3", prop3); + // + // vf.setProperties(properties); vf.setComponentType(ComponentTypeEnum.RESOURCE); Either<NodeType, StorageOperationStatus> createVFRes = nodeTypeOperation.createNodeType(vf); assertTrue(createVFRes.isLeft()); @@ -591,7 +575,7 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { public void verifyInCatalogData(int expected, List<String> expectedIds) { - Either<List<CatalogComponent>, StorageOperationStatus> highestResourcesRes = topologyTemplateOperation.getElementCatalogData(true, null); + Either<List<CatalogComponent>, StorageOperationStatus> highestResourcesRes = topologyTemplateOperation.getElementCatalogData(true, null); assertTrue(highestResourcesRes.isLeft()); List<CatalogComponent> highestResources = highestResourcesRes.left().value(); // calculate expected count value @@ -620,4 +604,22 @@ public class ToscaElementLifecycleOperationTest extends ModelTestBase { } janusGraphDao.commit(); } + + private String exportGraphMl(JanusGraph graph) { + String result = null; + String outputFile = outputDirectory + File.separator + "exportGraph." + System.currentTimeMillis() + ".graphml"; + try { + try (final OutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile))) { + graph.io(IoCore.graphml()).writer().normalize(true).create().writeGraph(os, graph); + } + result = outputFile; + graph.tx().commit(); + } catch (Exception e) { + graph.tx().rollback(); + e.printStackTrace(); + } + return result; + + } + } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java index c094999ebc..e17c61e248 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/UserAdminOperationTest.java @@ -20,12 +20,17 @@ package org.openecomp.sdc.be.model.operations.impl; +import fj.data.Either; +import org.apache.tinkerpop.gremlin.structure.Direction; +import org.apache.tinkerpop.gremlin.structure.Edge; +import org.apache.tinkerpop.gremlin.structure.Graph; +import org.apache.tinkerpop.gremlin.structure.Property; +import org.apache.tinkerpop.gremlin.structure.Vertex; +import org.apache.tinkerpop.gremlin.structure.VertexProperty; import org.janusgraph.core.*; import org.janusgraph.graphdb.relations.StandardVertexProperty; import org.janusgraph.graphdb.types.system.EmptyVertex; import org.janusgraph.graphdb.types.system.ImplicitKey; -import fj.data.Either; -import org.apache.tinkerpop.gremlin.structure.*; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -41,13 +46,12 @@ import org.openecomp.sdc.be.dao.utils.UserStatusEnum; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import org.openecomp.sdc.be.model.ModelTestBase; import org.openecomp.sdc.be.model.User; -import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; +import org.openecomp.sdc.be.model.jsonjanusgraph.operations.ToscaOperationFacade; import org.openecomp.sdc.be.resources.data.UserData; import org.openecomp.sdc.common.api.UserRoleEnum; import java.time.Instant; import java.util.ArrayList; -import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -56,13 +60,18 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class UserAdminOperationTest extends ModelTestBase { - private static final JanusGraphGenericDao JANUS_GRAPH_GENERIC_DAO = mock(JanusGraphGenericDao.class); + private static final JanusGraphGenericDao janusGraphGenericDao = mock(JanusGraphGenericDao.class); + private static final ToscaOperationFacade toscaOperationFacade = mock(ToscaOperationFacade.class); + @InjectMocks - private static final UserAdminOperation userAdminOperation = new UserAdminOperation( - JANUS_GRAPH_GENERIC_DAO); + private static final UserAdminOperation userAdminOperation = new UserAdminOperation(janusGraphGenericDao, toscaOperationFacade); private static final String ADMIN = "admin"; @BeforeClass @@ -73,7 +82,7 @@ public class UserAdminOperationTest extends ModelTestBase { @Before public void initMocks() { MockitoAnnotations.initMocks(this); - Mockito.reset(JANUS_GRAPH_GENERIC_DAO); + Mockito.reset(janusGraphGenericDao); mockJanusGraphUpdate(); mockJanusGraphDelete(); @@ -83,12 +92,10 @@ public class UserAdminOperationTest extends ModelTestBase { public void testDeActivateUserDataSuccess() { UserData userData = mockJanusGraphGet(ADMIN, UserRoleEnum.ADMIN, true); - Either<User, StorageOperationStatus> eitherUser = userAdminOperation.deActivateUser(userAdminOperation.convertToUser(userData)); + User user = userAdminOperation.deActivateUser(userAdminOperation.convertToUser(userData)); - verify(JANUS_GRAPH_GENERIC_DAO, times(1)).updateNode(eq(userData), eq(UserData.class)); - verify(JANUS_GRAPH_GENERIC_DAO, times(0)).deleteNode(any(UserData.class), eq(UserData.class)); - assertTrue(eitherUser.isLeft()); - User user = eitherUser.left().value(); + verify(janusGraphGenericDao, times(1)).updateNode(eq(userData), eq(UserData.class)); + verify(janusGraphGenericDao, times(0)).deleteNode(any(UserData.class), eq(UserData.class)); assertSame(user.getStatus(), UserStatusEnum.INACTIVE); } @@ -99,11 +106,11 @@ public class UserAdminOperationTest extends ModelTestBase { List<Edge> edgesList = new ArrayList<>(); Either<List<Edge>, JanusGraphOperationStatus> eitherResult = Either.left(edgesList); - when(JANUS_GRAPH_GENERIC_DAO.getEdgesForNode(userData, Direction.BOTH)).thenReturn(eitherResult); + when(janusGraphGenericDao.getEdgesForNode(userData, Direction.BOTH)).thenReturn(eitherResult); Either<User, ActionStatus> eitherUser = userAdminOperation.deleteUserData(ADMIN); - verify(JANUS_GRAPH_GENERIC_DAO, times(0)).updateNode(any(UserData.class), eq(UserData.class)); - verify(JANUS_GRAPH_GENERIC_DAO, times(1)).deleteNode(userData, UserData.class); + verify(janusGraphGenericDao, times(0)).updateNode(any(UserData.class), eq(UserData.class)); + verify(janusGraphGenericDao, times(1)).deleteNode(userData, UserData.class); assertTrue(eitherUser.isLeft()); } @@ -116,11 +123,11 @@ public class UserAdminOperationTest extends ModelTestBase { edgesList.add(getEmptyEdgeImpl()); Either<List<Edge>, JanusGraphOperationStatus> eitherResult = Either.left(edgesList); - when(JANUS_GRAPH_GENERIC_DAO.getEdgesForNode(userData, Direction.BOTH)).thenReturn(eitherResult); + when(janusGraphGenericDao.getEdgesForNode(userData, Direction.BOTH)).thenReturn(eitherResult); Either<User, ActionStatus> eitherUser = userAdminOperation.deleteUserData(ADMIN); - verify(JANUS_GRAPH_GENERIC_DAO, times(0)).updateNode(any(UserData.class), eq(UserData.class)); - verify(JANUS_GRAPH_GENERIC_DAO, times(0)).deleteNode(any(UserData.class), eq(UserData.class)); + verify(janusGraphGenericDao, times(0)).updateNode(any(UserData.class), eq(UserData.class)); + verify(janusGraphGenericDao, times(0)).deleteNode(any(UserData.class), eq(UserData.class)); assertTrue(eitherUser.isRight()); assertSame(eitherUser.right().value(), ActionStatus.USER_HAS_ACTIVE_ELEMENTS); @@ -143,11 +150,11 @@ public class UserAdminOperationTest extends ModelTestBase { edges.add(edge1); edges.add(edge2); edges.add(edge3); - when(JANUS_GRAPH_GENERIC_DAO.getVertexByProperty(userKey, userId)).thenReturn(Either.left(userVertex)); - when(JANUS_GRAPH_GENERIC_DAO.getOutgoingEdgesByCriteria(any(), any(), any())).thenReturn(Either.left(edges)); - Either<List<Edge>, StorageOperationStatus> result = userAdminOperation.getUserPendingTasksList(user, new HashMap<>()); - assertThat(result.isLeft()).isTrue(); - List<Edge> pendingTasks = result.left().value(); + when(janusGraphGenericDao.getVertexByProperty(userKey, userId)).thenReturn(Either.left(userVertex)); + when(janusGraphGenericDao.getOutgoingEdgesByCriteria(any(), any(), any())).thenReturn(Either.left(edges)); + ArrayList<Object> states = new ArrayList<>(); + states.add("state"); + List<Edge> pendingTasks = userAdminOperation.getUserPendingTasksList(user, states); assertThat(pendingTasks.size()).isEqualTo(2); assertThat(((TestEdge)pendingTasks.get(0)).getName()).isNotEqualTo("2"); assertThat(((TestEdge)pendingTasks.get(1)).getName()).isNotEqualTo("2"); @@ -373,7 +380,7 @@ public class UserAdminOperationTest extends ModelTestBase { private UserData mockJanusGraphGet(String userId, UserRoleEnum role, boolean isActive) { UserData userData = buildUserData(userId, role, isActive); Either<UserData, JanusGraphOperationStatus> eitherUserData = Either.left(userData); - when(JANUS_GRAPH_GENERIC_DAO + when(janusGraphGenericDao .getNode(UniqueIdBuilder.getKeyByNodeType(NodeTypeEnum.User), userId, UserData.class)).thenReturn(eitherUserData); return userData; } @@ -383,7 +390,7 @@ public class UserAdminOperationTest extends ModelTestBase { Object[] args = invocation.getArguments(); UserData retValue = (UserData) args[0]; return Either.left(retValue); - }).when(JANUS_GRAPH_GENERIC_DAO).updateNode(any(UserData.class), eq(UserData.class)); + }).when(janusGraphGenericDao).updateNode(any(UserData.class), eq(UserData.class)); } private static void mockJanusGraphDelete() { @@ -391,7 +398,7 @@ public class UserAdminOperationTest extends ModelTestBase { Object[] args = invocation.getArguments(); UserData retValue = (UserData) args[0]; return Either.left(retValue); - }).when(JANUS_GRAPH_GENERIC_DAO).deleteNode(any(UserData.class), eq(UserData.class)); + }).when(janusGraphGenericDao).deleteNode(any(UserData.class), eq(UserData.class)); } private static UserData buildUserData(String userId, UserRoleEnum role, boolean isActive) { diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java index 6bd206725b..caf0ebd05d 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/util/PrintGraph.java @@ -34,9 +34,10 @@ import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; import java.util.*; import java.util.Map.Entry; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; +//import com.tinkerpop.blueprints.Direction; +//import com.tinkerpop.blueprints.Edge; +//import com.tinkerpop.blueprints.Vertex; +//import com.tinkerpop.blueprints.util.ElementHelper; public class PrintGraph { @@ -48,6 +49,10 @@ public class PrintGraph { Iterator<JanusGraphVertex> iterator = vertices.iterator(); while (iterator.hasNext()) { Vertex vertex = iterator.next(); + + // System.out.println(vertex); + // System.out.println(ElementHelper.getProperties(vertex)); + // System.out.println("======================================="); } } @@ -56,6 +61,7 @@ public class PrintGraph { } public void printGraphEdges(JanusGraph graph) { + Iterable<JanusGraphEdge> vertices = graph.query().edges(); if (vertices != null) { @@ -63,9 +69,16 @@ public class PrintGraph { while (iterator.hasNext()) { Edge edge = iterator.next(); + // System.out.println(edge); + // System.out.println("edge=" + edge.getLabel() + ", + // properties="+ ElementHelper.getProperties(edge)); + // System.out.println("edge=" + edge.label() + ", properties="+ + // getProperties(edge)); + // System.out.println("======================================="); } } + // graph.commit(); graph.tx().commit(); } @@ -75,6 +88,9 @@ public class PrintGraph { builder.append("digraph finite_state_machine {\n"); builder.append("rankdir=LR;\n"); builder.append("size=\"15,10\" \n"); + // node [shape = doublecircle]; LR_0 LR_3 LR_4 LR_8; + // node [shape = circle]; + Iterable<JanusGraphVertex> vertices = graph.query().vertices(); if (vertices != null) { @@ -82,6 +98,11 @@ public class PrintGraph { while (iterator.hasNext()) { Vertex vertex = iterator.next(); + // System.out.println(vertex); + // System.out.println(ElementHelper.getProperties(vertex)); + // System.out.println(getProperties(vertex)); + // System.out.println("======================================="); + Map<String, Object> properties = getProperties(vertex); String nodeLabel = (String) properties.get(GraphPropertiesDictionary.LABEL.getProperty()); @@ -90,10 +111,22 @@ public class PrintGraph { String uid = getNodeIdByLabel(nodeLabel, properties); + // System.out.println("uid=" + uid); + String nodeRecord = buildNodeRecord(uid, color, properties); + // System.out.println(nodeRecord); + builder.append(nodeRecord); + // if (nodeLabel.equals(NodeTypeEnum.Category)) { + // + // String + // + // } else (nodeLabel.equals(NodeTypeEnum.User)) { + // + // } + } } @@ -105,18 +138,38 @@ public class PrintGraph { while (iterator.hasNext()) { Edge edge = iterator.next(); + // Vertex vertexFrom = edge.getVertex(Direction.OUT); + // Vertex vertexTo = edge.getVertex(Direction.IN); Vertex vertexFrom = edge.outVertex(); Vertex vertexTo = edge.inVertex(); + + // String fromUid = + // getNodeIdByLabel((String)vertexFrom.getProperty(GraphPropertiesDictionary.LABEL.getProperty()), + // ElementHelper.getProperties(vertexFrom)); + // String toUid = + // getNodeIdByLabel((String)vertexTo.getProperty(GraphPropertiesDictionary.LABEL.getProperty()), + // ElementHelper.getProperties(vertexTo)); String fromUid = getNodeIdByLabel(vertexFrom.value(GraphPropertiesDictionary.LABEL.getProperty()), getProperties(vertexFrom)); String toUid = getNodeIdByLabel(vertexTo.value(GraphPropertiesDictionary.LABEL.getProperty()), getProperties(vertexTo)); + // String edgeLabel = edge.getLabel(); String edgeLabel = edge.label(); + // String edgeRecord = buildEdgeRecord(fromUid, toUid, + // edgeLabel, ElementHelper.getProperties(edge)); String edgeRecord = buildEdgeRecord(fromUid, toUid, edgeLabel, getProperties(edge)); builder.append(edgeRecord); + + // System.out.println(edge); + // System.out.println("edge=" + edge.getLabel() + ", + // properties=" + // + ElementHelper.getProperties(edge)); + // System.out.println("edge=" + edge.label() + ", properties=" + // + getProperties(edge)); + // System.out.println("======================================="); } } @@ -127,6 +180,25 @@ public class PrintGraph { } + // LR_0 [ style = "bold" color = "red" shape = "Mrecord" label = + // "hello\nworld | { name | apache } | { version | 1.0 } | { uid | + // apache.1.0 } | { state| CERTIFIED } |{ b |{c|<here> d|e}| f}| g | h" + // ] + + // LR_0 -> LR_2 [ label = "SS(B)" ]; + // LR_0 -> LR_1 [ label = "SS(S)" ]; + // LR_1 -> LR_3 [ label = "S($end)" ]; + // LR_2 -> LR_6 [ label = "SS(b)" ]; + // LR_2 -> LR_5 [ label = "SS(a)" ]; + // LR_2 -> LR_4 [ label = "S(A)" ]; + // LR_5 -> LR_7 [ label = "S(b)" ]; + // LR_5 -> LR_5 [ label = "S(a)" ]; + // LR_6 -> LR_6 [ label = "S(b)" ]; + // LR_6 -> LR_5 [ label = "S(a)" ]; + // LR_7 -> LR_8 [ label = "S(b)" ]; + // LR_7 -> LR_5 [ label = "S(a)" ]; + // LR_8 -> LR_6 [ label = "S(b)" ]; + // LR_8 -> LR_5 [ label = "S(a)" ]; private String buildEdgeRecord(String fromUid, String toUid, String edgeLabel, Map<String, Object> properties) { @@ -220,6 +292,12 @@ public class PrintGraph { builder.append("label = \"" + label + "\" "); builder.append(" ] "); + + // LR_0 [ style = "bold" color = "red" shape = "Mrecord" label = + // "hello\nworld | { name | apache } | { version | 1.0 } | { uid | + // apache.1.0 } | { state| CERTIFIED } |{ b |{c|<here> d|e}| f}| g | h" + // ] + builder.append(" \n "); return builder.toString(); } @@ -334,6 +412,13 @@ public class PrintGraph { while (iterator.hasNext()) { Vertex vertex = iterator.next(); + // System.out.println(vertex); + // System.out.println(ElementHelper.getProperties(vertex)); + // System.out.println(getProperties(vertex)); + // System.out.println("======================================="); + + // Map<String, Object> properties = + // ElementHelper.getProperties(vertex); Map<String, Object> properties = getProperties(vertex); String nodeLabel = (String) properties.get(GraphPropertiesDictionary.LABEL.getProperty()); diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/utils/ComponentValidationUtilsTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/utils/ComponentValidationUtilsTest.java index 1b5b9cb5f8..6c9387a372 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/utils/ComponentValidationUtilsTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/utils/ComponentValidationUtilsTest.java @@ -69,7 +69,7 @@ public class ComponentValidationUtilsTest { public void testCanWorkOnBadResourceAndBadUser() { assertFalse(ComponentValidationUtils.canWorkOnResource(resource, BAD_USER_ID)); - resource.setLifecycleState(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS); + resource.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); assertFalse(ComponentValidationUtils.canWorkOnResource(resource, USER_ID)); resource.setIsDeleted(true); @@ -100,7 +100,7 @@ public class ComponentValidationUtilsTest { public void testCanWorkOnBadComponent() { // given when(component.getLifecycleState()) - .thenReturn(LifecycleStateEnum.CERTIFICATION_IN_PROGRESS); + .thenReturn(LifecycleStateEnum.NOT_CERTIFIED_CHECKIN); when(component.getLastUpdaterUserId()).thenReturn(resource.getLastUpdaterUserId()); when(toscaOperationFacade.getToscaElement(eq(COMPONENT_ID), diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/serialize/TestResourceSerialization.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/serialize/TestResourceSerialization.java index ba066d2d14..590be7ecf5 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/serialize/TestResourceSerialization.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/serialize/TestResourceSerialization.java @@ -94,6 +94,8 @@ public class TestResourceSerialization { if (type.toString().contains(".List")) { ParameterizedType stringListType = (ParameterizedType) field.getGenericType(); Class<?> stringListClass = (Class<?>) stringListType.getActualTypeArguments()[0]; + // System.out.println(stringListClass); // class + // java.lang.String. allClasses.add(stringListClass); } @@ -135,12 +137,27 @@ public class TestResourceSerialization { } + // System.out.println(type); allClasses.add(type); } } } + + private void addInternalTypeOfList(Class clazz) { + + // clazz. + // ParameterizedType stringListType = (ParameterizedType) + // field.getGenericType(); + // Class<?> stringListClass = (Class<?>) + // stringListType.getActualTypeArguments()[0]; + // //System.out.println(stringListClass); // class java.lang.String. + // allClasses.add(stringListClass); + // + } + private boolean isClassImplementedSerialize(Class clazz) { + Type[] genericInterfaces = clazz.getGenericInterfaces(); if (genericInterfaces != null) { Type orElse = Arrays.stream(genericInterfaces).filter(p -> p.getTypeName().equals("java.io.Serializable")) @@ -149,6 +166,47 @@ public class TestResourceSerialization { return true; } } + return false; } + + // @Test + public void testSimpleResourceSerialize() { + + Resource resource = new Resource(); + String name = "res1"; + Map<String, String> allVersions = new HashMap<>(); + allVersions.put("keya", "valuea"); + + resource.setName(name); + // all versions + resource.setAllVersions(allVersions); + List<ComponentInstance> resourceInstances = new ArrayList<>(); + // component instances + ComponentInstance componentInstance = new ComponentInstance(); + componentInstance.setDescription("desc1"); + componentInstance.setComponentUid("comUid"); + resourceInstances.add(componentInstance); + + resource.setComponentInstances(resourceInstances); + + Either<byte[], Boolean> serialize = SerializationUtils.serialize(resource); + assertTrue("check object serialized", serialize.isLeft()); + byte[] value = serialize.left().value(); + + Either<Object, Boolean> deserialize = SerializationUtils.deserialize(value); + assertTrue("check object deserialized", deserialize.isLeft()); + Object obj = deserialize.left().value(); + Resource desResource = (Resource) obj; + assertEquals("check name", name, desResource.getName()); + verifyAllVersions(desResource); + + } + + private void verifyAllVersions(Resource desResource) { + assertNotNull("check all versions", desResource.getAllVersions()); + assertEquals("check all version size", 1, desResource.getAllVersions().size()); + assertEquals("check all version key", "keya", desResource.getAllVersions().keySet().iterator().next()); + assertEquals("check all version value", "valuea", desResource.getAllVersions().values().iterator().next()); + } } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraintTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraintTest.java index 82d039439a..6fd578856d 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraintTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractPropertyConstraintTest.java @@ -24,9 +24,11 @@ package org.openecomp.sdc.be.model.tosca.constraints; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException; +import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; import org.openecomp.sdc.be.model.tosca.version.Version; public class AbstractPropertyConstraintTest { @@ -107,6 +109,16 @@ class TestPropertyConstraint extends AbstractPropertyConstraint { } @Override + public ConstraintType getConstraintType() { + return null; + } + + @Override + public void validateValueOnUpdate(PropertyConstraint newConstraint) throws PropertyConstraintException { + + } + + @Override public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException exception, String propertyName) { return null; } diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraintTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraintTest.java index 5788f03a6e..376bac8ca9 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraintTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/constraints/AbstractStringPropertyConstraintTest.java @@ -24,10 +24,12 @@ package org.openecomp.sdc.be.model.tosca.constraints; import static org.junit.Assert.assertEquals; import org.junit.Test; +import org.openecomp.sdc.be.model.PropertyConstraint; import org.openecomp.sdc.be.model.tosca.ToscaType; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintFunctionalException; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintValueDoNotMatchPropertyTypeException; import org.openecomp.sdc.be.model.tosca.constraints.exception.ConstraintViolationException; +import org.openecomp.sdc.be.model.tosca.constraints.exception.PropertyConstraintException; public class AbstractStringPropertyConstraintTest { @@ -79,6 +81,16 @@ class TestStringPropertyConstraint extends AbstractStringPropertyConstraint { } @Override + public ConstraintType getConstraintType() { + return null; + } + + @Override + public void validateValueOnUpdate(PropertyConstraint newConstraint) throws PropertyConstraintException { + + } + + @Override public String getErrorMessage(ToscaType toscaType, ConstraintFunctionalException exception, String propertyName) { return null; } diff --git a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml index ebe8f2ebe0..a1aaa3ab1f 100644 --- a/catalog-model/src/test/resources/config/catalog-model/configuration.yaml +++ b/catalog-model/src/test/resources/config/catalog-model/configuration.yaml @@ -36,8 +36,6 @@ janusGraphReconnectIntervalInSeconds: 3 # The read timeout towards JanusGraph DB when health check is invoked: janusGraphHealthCheckReadTimeout: 1 -# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup: -esReconnectIntervalInSeconds: 3 uebHealthCheckReconnectIntervalInSeconds: 15 uebHealthCheckReadTimeout: 4 @@ -88,28 +86,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} -#Application-specific settings of ES -elasticSearch: - # Mapping of index prefix to time-based frame. For example, if below is configured: - # - # - indexPrefix: auditingevents - # creationPeriod: minute - # - # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index. - # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index. - # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index. - # - # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana. - # - # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour). - # - # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month. - - indicesTimeFrequency: - - indexPrefix: auditingevents - creationPeriod: month - - indexPrefix: monitoring_events - creationPeriod: month artifactTypes: - CHEF @@ -292,7 +268,10 @@ systemMonitoring: isProxy: false probeIntervalInSeconds: 15 -defaultHeatArtifactTimeoutMinutes: 60 +heatArtifactDeploymentTimeout: + defaultMinutes: 30 + minMinutes: 1 + maxMinutes: 120 serviceDeploymentArtifacts: YANG_XML: @@ -546,10 +525,6 @@ resourceInformationalArtifacts: resourceInformationalDeployedArtifacts: -requirementsToFulfillBeforeCert: - -capabilitiesToConsumeBeforeCert: - unLoggedUrls: - /sdc2/rest/healthCheck @@ -688,5 +663,4 @@ dmaapConsumerConfiguration: password: hmXYcznAljMSisdy8zgcag== dmeConfiguration: - dme2Search: DME2SEARCH - dme2Resolve: DME2RESOLVE + lookupUriFormat: "http://DME2RESOLVE/service=%s/version=1.0.0/envContext=%s/routeOffer=DEFAULT" diff --git a/catalog-model/src/test/resources/config/configuration.yaml b/catalog-model/src/test/resources/config/configuration.yaml index 90d2b880f2..767fc424b0 100644 --- a/catalog-model/src/test/resources/config/configuration.yaml +++ b/catalog-model/src/test/resources/config/configuration.yaml @@ -36,8 +36,6 @@ janusGraphReconnectIntervalInSeconds: 3 # The read timeout towards JanusGraph DB when health check is invoked: janusGraphHealthCheckReadTimeout: 1 -# The interval to try and reconnect to Elasticsearch when it is down during ASDC startup: -esReconnectIntervalInSeconds: 3 uebHealthCheckReconnectIntervalInSeconds: 15 uebHealthCheckReadTimeout: 4 @@ -88,28 +86,6 @@ cassandraConfig: - { name: sdccomponent, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} - { name: sdcrepository, replicationStrategy: SimpleStrategy, replicationInfo: ['1']} -#Application-specific settings of ES -elasticSearch: - # Mapping of index prefix to time-based frame. For example, if below is configured: - # - # - indexPrefix: auditingevents - # creationPeriod: minute - # - # then ES object of type which is mapped to "auditingevents-*" template, and created on 2015-12-23 13:24:54, will enter "auditingevents-2015-12-23-13-24" index. - # Another object created on 2015-12-23 13:25:54, will enter "auditingevents-2015-12-23-13-25" index. - # If creationPeriod: month, both of the above will enter "auditingevents-2015-12" index. - # - # PLEASE NOTE: the timestamps are created in UTC/GMT timezone! This is needed so that timestamps will be correctly presented in Kibana. - # - # Legal values for creationPeriod - year, month, day, hour, minute, none (meaning no time-based behaviour). - # - # If no creationPeriod is configured for indexPrefix, default behavour is creationPeriod: month. - - indicesTimeFrequency: - - indexPrefix: auditingevents - creationPeriod: month - - indexPrefix: monitoring_events - creationPeriod: month artifactTypes: - CHEF @@ -292,7 +268,10 @@ systemMonitoring: isProxy: false probeIntervalInSeconds: 15 -defaultHeatArtifactTimeoutMinutes: 60 +heatArtifactDeploymentTimeout: + defaultMinutes: 30 + minMinutes: 1 + maxMinutes: 120 serviceDeploymentArtifacts: YANG_XML: @@ -538,10 +517,6 @@ resourceInformationalArtifacts: resourceInformationalDeployedArtifacts: -requirementsToFulfillBeforeCert: - -capabilitiesToConsumeBeforeCert: - unLoggedUrls: - /sdc2/rest/healthCheck |