-package org.openecomp.sdc.be.model.jsontitan.operations;
+package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
import fj.data.Either;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CompositionDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.ModelTestBase;
-import org.openecomp.sdc.be.model.jsontitan.enums.JsonConstantKeysEnum;
-import org.openecomp.sdc.be.model.jsontitan.utils.GraphTestUtils;
+import org.openecomp.sdc.be.model.jsonjanusgraph.enums.JsonConstantKeysEnum;
+import org.openecomp.sdc.be.model.jsonjanusgraph.utils.GraphTestUtils;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
private ArchiveOperation archiveOperation;
@Resource
- private TitanDao titanDao;
+ private JanusGraphDao janusGraphDao;
private boolean isInitialized;
@Before
public void beforeTest() {
if (!isInitialized) {
- GraphTestUtils.clearGraph(titanDao);
+ GraphTestUtils.clearGraph(janusGraphDao);
initGraphForTest();
isInitialized = true;
}
}
private void assertOnVspArchived(boolean expectedValue) {
- GraphVertex v = titanDao.getVertexById(vfResource0_1.getUniqueId()).left().value();
+ GraphVertex v = janusGraphDao.getVertexById(vfResource0_1.getUniqueId()).left().value();
assertThat(v.getMetadataProperty(GraphPropertyEnum.IS_VSP_ARCHIVED)).isEqualTo(expectedValue);
- v = titanDao.getVertexById(vfResource0_2.getUniqueId()).left().value();
+ v = janusGraphDao.getVertexById(vfResource0_2.getUniqueId()).left().value();
assertThat(v.getMetadataProperty(GraphPropertyEnum.IS_VSP_ARCHIVED)).isEqualTo(expectedValue);
- v = titanDao.getVertexById(vfResource1_0.getUniqueId()).left().value();
+ v = janusGraphDao.getVertexById(vfResource1_0.getUniqueId()).left().value();
assertThat(v.getMetadataProperty(GraphPropertyEnum.IS_VSP_ARCHIVED)).isEqualTo(expectedValue);
}
*************************/
private void checkoutComponent(GraphVertex serviceVertex0_5) {
- Either<GraphVertex, TitanOperationStatus> vE = titanDao.getVertexById(serviceVertex0_5.getUniqueId());
+ Either<GraphVertex, JanusGraphOperationStatus> vE = janusGraphDao.getVertexById(serviceVertex0_5.getUniqueId());
GraphVertex v = vE.left().value();
v.addMetadataProperty(GraphPropertyEnum.STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
v.setJsonMetadataField(JsonPresentationFields.LIFECYCLE_STATE, LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
- titanDao.updateVertex(v);
+ janusGraphDao.updateVertex(v);
assertOnCommit();
}
private void assertOnCommit(){
- final TitanOperationStatus commit = this.titanDao.commit();
- assertThat(commit).isEqualTo(TitanOperationStatus.OK);
+ final JanusGraphOperationStatus commit = this.janusGraphDao.commit();
+ assertThat(commit).isEqualTo(JanusGraphOperationStatus.OK);
}
private void assertArchived(String componentUniqueId) {
}
private void assertArchivedOrRestored(ArchiveOperation.Action action, String componentUniqueId) {
- GraphVertex v = titanDao.getVertexById(componentUniqueId).left().value();
+ GraphVertex v = janusGraphDao.getVertexById(componentUniqueId).left().value();
EdgeLabelEnum requiredEdge = action == ArchiveOperation.Action.ARCHIVE ? EdgeLabelEnum.ARCHIVE_ELEMENT : EdgeLabelEnum.CATALOG_ELEMENT;
EdgeLabelEnum otherEdge = action == ArchiveOperation.Action.ARCHIVE ? EdgeLabelEnum.CATALOG_ELEMENT : EdgeLabelEnum.ARCHIVE_ELEMENT;
GraphVertex parent = null;
- Either<GraphVertex, TitanOperationStatus> otherLookup = null;
+ Either<GraphVertex, JanusGraphOperationStatus> otherLookup = null;
Boolean isHighest = (Boolean) v.getMetadataProperty(GraphPropertyEnum.IS_HIGHEST_VERSION);
if (isHighest != null && isHighest) {
//Highest version are linked to Archive/Catalog Root
- parent = titanDao.getParentVertex(v, requiredEdge, JsonParseFlagEnum.NoParse).left().value();
- otherLookup = titanDao.getParentVertex(v, otherEdge, JsonParseFlagEnum.NoParse);
+ parent = janusGraphDao.getParentVertex(v, requiredEdge, JsonParseFlagEnum.NoParse).left().value();
+ otherLookup = janusGraphDao.getParentVertex(v, otherEdge, JsonParseFlagEnum.NoParse);
assertThat(otherLookup.isRight()).isTrue(); //Verify that component is not linked to Catalog/Archive Root
assertThat(parent.getUniqueId()).isEqualTo(action == ArchiveOperation.Action.ARCHIVE ? this.archiveVertex.getUniqueId() : this.catalogVertex.getUniqueId()); //Verify that parent is indeed Archive Root
}
private void assertArchivedProps(String uniqueId) {
GraphVertex v =
- titanDao.getVertexById(uniqueId).left().value();
+ janusGraphDao.getVertexById(uniqueId).left().value();
assertArchivedOrRestoredProps(ArchiveOperation.Action.ARCHIVE, v);
}
private void assertRestoredProps(String uniqueId) {
GraphVertex v =
- titanDao.getVertexById(uniqueId).left().value();
+ janusGraphDao.getVertexById(uniqueId).left().value();
assertArchivedOrRestoredProps(ArchiveOperation.Action.RESTORE, v);
}
*******************************/
private void initGraphForTest() {
//Create Catalog Root
- this.catalogVertex = GraphTestUtils.createRootCatalogVertex(titanDao);
+ this.catalogVertex = GraphTestUtils.createRootCatalogVertex(janusGraphDao);
//Create Archive Root
- this.archiveVertex = GraphTestUtils.createRootArchiveVertex(titanDao);
+ this.archiveVertex = GraphTestUtils.createRootArchiveVertex(janusGraphDao);
createScenario1_SingleVersionNode();
createScenario2_TwoHighestVersions();
private void createScenario1_SingleVersionNode() {
//Create Service for Scenario 1 Tests (1 Service)
- this.serviceVertex1 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
+ this.serviceVertex1 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
//Connect Service to Catalog Root
- titanDao.createEdge(catalogVertex, serviceVertex1, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao.createEdge(catalogVertex, serviceVertex1, EdgeLabelEnum.CATALOG_ELEMENT, null);
}
private void createScenario2_TwoHighestVersions() {
//Create Service for Scenario 2 Tests (1 Service)
- this.serviceVertex1_0 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
- this.serviceVertex1_1 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
+ this.serviceVertex1_0 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
+ this.serviceVertex1_1 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
- titanDao.createEdge(serviceVertex1_0, serviceVertex1_1, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex1_0, serviceVertex1_1, EdgeLabelEnum.VERSION, null);
//Connect 1.0 and 1.1 to Catalog Root
- titanDao.createEdge(catalogVertex, serviceVertex1_0, EdgeLabelEnum.CATALOG_ELEMENT, null);
- titanDao.createEdge(catalogVertex, serviceVertex1_1, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao
+ .createEdge(catalogVertex, serviceVertex1_0, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao
+ .createEdge(catalogVertex, serviceVertex1_1, EdgeLabelEnum.CATALOG_ELEMENT, null);
}
private void createScenario3_TwoHighestVersionsOneLowest() {
//Create Service for Scenario 1 Tests (1 Service)
- this.serviceVertex2_0 = GraphTestUtils.createServiceVertex(titanDao, propsForNonHighestVersion()); //NonHighestVersion
- this.serviceVertex3_0 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
- this.serviceVertex3_1 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
+ this.serviceVertex2_0 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForNonHighestVersion()); //NonHighestVersion
+ this.serviceVertex3_0 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
+ this.serviceVertex3_1 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
//Connect version edges
- titanDao.createEdge(serviceVertex2_0, serviceVertex3_0, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(serviceVertex3_0, serviceVertex3_1, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex2_0, serviceVertex3_0, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex3_0, serviceVertex3_1, EdgeLabelEnum.VERSION, null);
//Connect 3.0 and 3.1 to Catalog Root
- titanDao.createEdge(catalogVertex, serviceVertex3_0, EdgeLabelEnum.CATALOG_ELEMENT, null);
- titanDao.createEdge(catalogVertex, serviceVertex3_1, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao
+ .createEdge(catalogVertex, serviceVertex3_0, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao
+ .createEdge(catalogVertex, serviceVertex3_1, EdgeLabelEnum.CATALOG_ELEMENT, null);
}
private void createScenario4_1Highest4LowestVersions() {
//2 Lowest version only
- this.serviceVertex0_1 = GraphTestUtils.createServiceVertex(titanDao, propsForNonHighestVersion());
- this.serviceVertex0_2 = GraphTestUtils.createServiceVertex(titanDao, propsForNonHighestVersion());
- this.serviceVertex0_3 = GraphTestUtils.createServiceVertex(titanDao, propsForNonHighestVersion());
- this.serviceVertex0_4 = GraphTestUtils.createServiceVertex(titanDao, propsForNonHighestVersion());
- this.serviceVertex0_5 = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
+ this.serviceVertex0_1 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForNonHighestVersion());
+ this.serviceVertex0_2 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForNonHighestVersion());
+ this.serviceVertex0_3 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForNonHighestVersion());
+ this.serviceVertex0_4 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForNonHighestVersion());
+ this.serviceVertex0_5 = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
- titanDao.createEdge(serviceVertex0_1, serviceVertex0_2, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(serviceVertex0_2, serviceVertex0_3, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(serviceVertex0_3, serviceVertex0_4, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(serviceVertex0_4, serviceVertex0_5, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex0_1, serviceVertex0_2, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex0_2, serviceVertex0_3, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex0_3, serviceVertex0_4, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(serviceVertex0_4, serviceVertex0_5, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(catalogVertex, serviceVertex0_5, EdgeLabelEnum.CATALOG_ELEMENT, null);
+ janusGraphDao
+ .createEdge(catalogVertex, serviceVertex0_5, EdgeLabelEnum.CATALOG_ELEMENT, null);
}
private void createResourcesForArchivedVsp(){
vfPropsHighest.put(GraphPropertyEnum.CSAR_UUID, csarUuid);
vfPropsHighest.put(GraphPropertyEnum.IS_VSP_ARCHIVED, false);
- this.vfResource0_1 = GraphTestUtils.createResourceVertex(titanDao, vfPropsNonHighest, ResourceTypeEnum.VF);
- this.vfResource0_2 = GraphTestUtils.createResourceVertex(titanDao, vfPropsNonHighest, ResourceTypeEnum.VF);
- this.vfResource1_0 = GraphTestUtils.createResourceVertex(titanDao, vfPropsHighest, ResourceTypeEnum.VF);
+ this.vfResource0_1 = GraphTestUtils.createResourceVertex(janusGraphDao, vfPropsNonHighest, ResourceTypeEnum.VF);
+ this.vfResource0_2 = GraphTestUtils.createResourceVertex(janusGraphDao, vfPropsNonHighest, ResourceTypeEnum.VF);
+ this.vfResource1_0 = GraphTestUtils.createResourceVertex(janusGraphDao, vfPropsHighest, ResourceTypeEnum.VF);
- titanDao.createEdge(vfResource0_1, vfResource0_2, EdgeLabelEnum.VERSION, null);
- titanDao.createEdge(vfResource0_2, vfResource1_0, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(vfResource0_1, vfResource0_2, EdgeLabelEnum.VERSION, null);
+ janusGraphDao.createEdge(vfResource0_2, vfResource1_0, EdgeLabelEnum.VERSION, null);
}
private void createMiscServices() {
//Create Service for Scenario 1 Tests (1 Service)
- this.archivedVertex1 = GraphTestUtils.createServiceVertex(titanDao, new HashMap<>());
+ this.archivedVertex1 = GraphTestUtils.createServiceVertex(janusGraphDao, new HashMap<>());
//Connect Service to Catalog Root
- titanDao.createEdge(archiveVertex, archivedVertex1, EdgeLabelEnum.ARCHIVE_ELEMENT, null);
+ janusGraphDao.createEdge(archiveVertex, archivedVertex1, EdgeLabelEnum.ARCHIVE_ELEMENT, null);
}
private void createServiceCompositionForCalculatingArchivedOrigins(){
//Service that point to another service in composition
- this.compositionService = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
- this.compositionAnotherService = GraphTestUtils.createServiceVertex(titanDao, propsForHighestVersion());
-
- this.compositionResource1 = GraphTestUtils.createResourceVertex(titanDao, propsForHighestVersion(), ResourceTypeEnum.CP);
- this.compositionResource2 = GraphTestUtils.createResourceVertex(titanDao, propsForHighestVersion(), ResourceTypeEnum.VL);
- this.compositionServiceProxy = GraphTestUtils.createResourceVertex(titanDao, propsForHighestVersion(), ResourceTypeEnum.ServiceProxy);
-
- titanDao.createEdge(compositionService, compositionResource1, EdgeLabelEnum.INSTANCE_OF, null);
- titanDao.createEdge(compositionService, compositionResource2, EdgeLabelEnum.INSTANCE_OF, null);
- titanDao.createEdge(compositionService, compositionServiceProxy, EdgeLabelEnum.INSTANCE_OF, null);
- titanDao.createEdge(compositionService, compositionAnotherService, EdgeLabelEnum.PROXY_OF, null);
+ this.compositionService = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
+ this.compositionAnotherService = GraphTestUtils.createServiceVertex(janusGraphDao, propsForHighestVersion());
+
+ this.compositionResource1 = GraphTestUtils.createResourceVertex(janusGraphDao, propsForHighestVersion(), ResourceTypeEnum.CP);
+ this.compositionResource2 = GraphTestUtils.createResourceVertex(janusGraphDao, propsForHighestVersion(), ResourceTypeEnum.VL);
+ this.compositionServiceProxy = GraphTestUtils.createResourceVertex(janusGraphDao, propsForHighestVersion(), ResourceTypeEnum.ServiceProxy);
+
+ janusGraphDao
+ .createEdge(compositionService, compositionResource1, EdgeLabelEnum.INSTANCE_OF, null);
+ janusGraphDao
+ .createEdge(compositionService, compositionResource2, EdgeLabelEnum.INSTANCE_OF, null);
+ janusGraphDao
+ .createEdge(compositionService, compositionServiceProxy, EdgeLabelEnum.INSTANCE_OF, null);
+ janusGraphDao
+ .createEdge(compositionService, compositionAnotherService, EdgeLabelEnum.PROXY_OF, null);
createAndAttachCompositionJson(compositionService);
}
//Add Full Json to vertex
compositionService.setJson(compositions);
//System.out.println(JsonParserUtils.toJson(compositions));
- titanDao.updateVertex(compositionService);
+ janusGraphDao.updateVertex(compositionService);
}
private Map<GraphPropertyEnum, Object> propsForHighestVersion(){