use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore in project constellation by constellation-app.
the class GraphRecordStoreUtilitiesNGTest method addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema.
@Test
public void addedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema() {
final RecordStore recordStore = new GraphRecordStore();
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.IDENTIFIER, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.IDENTIFIER, "vx1");
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + GraphRecordStoreUtilities.DIRECTED_KEY, false);
// the communication type is directed
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + AnalyticConcept.TransactionAttribute.TYPE, AnalyticConcept.TransactionType.COMMUNICATION);
final boolean initializeWithSchema = true;
final boolean completeWithSchema = false;
final List<String> vertexIdAttributes = new ArrayList<>();
final Map<String, Integer> vertexMap = new HashMap<>();
final Map<String, Integer> transactionMap = new HashMap<>();
final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes, vertexMap, transactionMap);
assertEquals(2, veritices.size());
assertEquals(2, graph.getVertexCount());
assertEquals(1, graph.getTransactionCount());
// try {
// SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddedRecordStoreSupportsTypesWithOverriddenDirectionWithInitialiseSchema");
// } catch (IOException ex) {
// Assert.fail(ex.getLocalizedMessage());
// }
final int transactionTypeId = AnalyticConcept.TransactionAttribute.TYPE.get(graph);
SchemaTransactionType type = (SchemaTransactionType) graph.getObjectValue(transactionTypeId, 0);
Assert.assertFalse(type.isDirected());
}
use of au.gov.asd.tac.constellation.graph.processing.GraphRecordStore in project constellation by constellation-app.
the class GraphRecordStoreUtilitiesNGTest method testAddRecordStoreToGraphIncludesAllRecords.
@Test
public void testAddRecordStoreToGraphIncludesAllRecords() {
final RecordStore recordStore = new GraphRecordStore();
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx1");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx2");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx3");
recordStore.set(GraphRecordStoreUtilities.SOURCE + "CustomAttribute", "Removed");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx4");
recordStore.set(GraphRecordStoreUtilities.SOURCE + "CustomAttribute", "Changed");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.LABEL, "vx1");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.LABEL, "vx4");
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + "CustomAttribute", "Removed");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx1");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx2");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx4");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx5");
recordStore.set(GraphRecordStoreUtilities.SOURCE + "CustomAttribute", "Added");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.LABEL, "vx1");
recordStore.add();
recordStore.set(GraphRecordStoreUtilities.SOURCE + VisualConcept.VertexAttribute.LABEL, "vx0");
recordStore.set(GraphRecordStoreUtilities.DESTINATION + VisualConcept.VertexAttribute.LABEL, "vx5");
recordStore.set(GraphRecordStoreUtilities.TRANSACTION + "CustomAttribute", "Added");
// add recordstore to graph
final boolean initializeWithSchema = true;
final boolean completeWithSchema = false;
final List<String> vertexIdAttributes = new ArrayList<>();
vertexIdAttributes.add(VisualConcept.VertexAttribute.LABEL.getName() + "<string>");
final List<Integer> veritices = GraphRecordStoreUtilities.addRecordStoreToGraph(graph, recordStore, initializeWithSchema, completeWithSchema, vertexIdAttributes);
// check counts
assertEquals(veritices.size(), 6);
final int vxCount = graph.getVertexCount();
assertEquals(vxCount, 6);
final int txCount = graph.getTransactionCount();
assertEquals(txCount, 4);
// check that all vertices start with vx
final int vxNameAttribute = VisualConcept.VertexAttribute.LABEL.get(graph);
for (int i = 0; i < vxCount; i++) {
int vxId = graph.getVertex(i);
assertEquals(graph.getStringValue(vxNameAttribute, vxId), String.valueOf("vx" + vxId));
}
// try {
// SaveGraphUtilities.saveGraphToTemporaryDirectory(graph, "testAddRecordStoreToGraphIncludesAllRecords");
// } catch (IOException ex) {
// Assert.fail(ex.getLocalizedMessage());
// }
}
Aggregations