Search in sources :

Example 16 with Schema

use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.

the class ResourceAllocationIndexPluginNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    // create an analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    // add attributes
    transactionRaiAttribute = SnaConcept.TransactionAttribute.RESOURCE_ALLOCATION_INDEX.ensure(graph);
    vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // add vertices
    vxId0 = graph.addVertex();
    vxId1 = graph.addVertex();
    vxId2 = graph.addVertex();
    vxId3 = graph.addVertex();
    vxId4 = graph.addVertex();
    // add transactions
    graph.addTransaction(vxId0, vxId1, true);
    graph.addTransaction(vxId0, vxId2, true);
    graph.addTransaction(vxId0, vxId3, true);
    graph.addTransaction(vxId0, vxId4, true);
    graph.addTransaction(vxId1, vxId2, true);
    graph.addTransaction(vxId1, vxId3, true);
    graph.addTransaction(vxId1, vxId4, true);
    graph.addTransaction(vxId2, vxId3, true);
    graph.addTransaction(vxId2, vxId4, true);
    graph.addTransaction(vxId3, vxId4, true);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 17 with Schema

use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.

the class MergeNodesBySuffixNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    // create an analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    // add attributes
    vertexIdentifierAttribute = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // add vertices
    vxId1 = graph.addVertex();
    vxId2 = graph.addVertex();
    vxId3 = graph.addVertex();
    vxId4 = graph.addVertex();
    vxId5 = graph.addVertex();
    vxId6 = graph.addVertex();
    // set the identifier of each vertex to something unique
    graph.setStringValue(vertexIdentifierAttribute, vxId1, "d1");
    graph.setStringValue(vertexIdentifierAttribute, vxId2, "One Id1");
    graph.setStringValue(vertexIdentifierAttribute, vxId3, "Id2");
    graph.setStringValue(vertexIdentifierAttribute, vxId4, "One Id2");
    graph.setStringValue(vertexIdentifierAttribute, vxId5, "Pine Id2");
    graph.setStringValue(vertexIdentifierAttribute, vxId6, "Id3");
    // select all
    graph.setBooleanValue(vertexSelectedAttribute, vxId1, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId2, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId3, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId4, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId5, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId6, true);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 18 with Schema

use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.

the class MergeNodesByTypeNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    // create an analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    graph = new StoreGraph(schema);
    // add attributes
    vertexIdentifierAttribute = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    vertexTypeAttribute = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
    vertexSelectedAttribute = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
    // add vertices
    vxId1 = graph.addVertex();
    vxId2 = graph.addVertex();
    vxId3 = graph.addVertex();
    vxId4 = graph.addVertex();
    vxId5 = graph.addVertex();
    vxId6 = graph.addVertex();
    // set the identifier of each vertex to something unique
    graph.setStringValue(vertexIdentifierAttribute, vxId1, "V1");
    graph.setStringValue(vertexIdentifierAttribute, vxId2, "V2");
    graph.setStringValue(vertexIdentifierAttribute, vxId3, "V2");
    graph.setStringValue(vertexIdentifierAttribute, vxId4, "V3");
    graph.setStringValue(vertexIdentifierAttribute, vxId5, "V3");
    // add transactions
    txId1 = graph.addTransaction(vxId1, vxId2, false);
    txId2 = graph.addTransaction(vxId3, vxId4, false);
    txId3 = graph.addTransaction(vxId5, vxId3, false);
    txId4 = graph.addTransaction(vxId1, vxId3, false);
    txId5 = graph.addTransaction(vxId4, vxId6, false);
    // select all
    graph.setBooleanValue(vertexSelectedAttribute, vxId1, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId2, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId3, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId4, true);
    graph.setBooleanValue(vertexSelectedAttribute, vxId5, true);
}
Also used : Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 19 with Schema

use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.

the class MergeNodesByTypeNGTest method testGetNodesToMerge_NoIdentifierAttribute.

/**
 * Test of getNodesToMerge method, of class MergeNodesByType, with no
 * identifier Attribute
 */
@Test
public void testGetNodesToMerge_NoIdentifierAttribute() throws Exception {
    System.out.println("testGetNodesToMerge_NoTypes");
    Comparator<String> leadVertexChooser = null;
    int threshold = 0;
    boolean selectedOnly = false;
    MergeNodesByType instance = new MergeNodesByType();
    Map<Integer, Set<Integer>> expResult = new HashMap<>();
    // create a new analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    StoreGraph graph = new StoreGraph(schema);
    // add attributes
    int vertexTypeAttribute = AnalyticConcept.VertexAttribute.TYPE.ensure(graph);
    // add vertices
    int vxId1 = graph.addVertex();
    int vxId2 = graph.addVertex();
    int vxId3 = graph.addVertex();
    // set the identifier of each vertex to something unique
    graph.setStringValue(vertexTypeAttribute, vxId1, AnalyticConcept.VertexType.DOCUMENT.getName());
    graph.setStringValue(vertexTypeAttribute, vxId2, AnalyticConcept.VertexType.DOCUMENT.getName());
    graph.setStringValue(vertexTypeAttribute, vxId3, AnalyticConcept.VertexType.ONLINE_IDENTIFIER.getName());
    Map<Integer, Set<Integer>> result = instance.getNodesToMerge(graph, leadVertexChooser, threshold, selectedOnly);
    assertEquals(result, expResult);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Example 20 with Schema

use of au.gov.asd.tac.constellation.graph.schema.Schema in project constellation by constellation-app.

the class MergeNodesByTypeNGTest method testGetNodesToMerge_NoTypeAttribute.

/**
 * Test of getNodesToMerge method, of class MergeNodesByType, with no types
 * Attribute
 */
@Test
public void testGetNodesToMerge_NoTypeAttribute() throws Exception {
    System.out.println("testGetNodesToMerge_NoTypes");
    Comparator<String> leadVertexChooser = null;
    int threshold = 0;
    boolean selectedOnly = false;
    MergeNodesByType instance = new MergeNodesByType();
    Map<Integer, Set<Integer>> expResult = new HashMap<>();
    // create a new analytic graph
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    StoreGraph graph = new StoreGraph(schema);
    // add attributes
    int vertexIdentifierAttribute = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
    // add vertices
    int vxId1 = graph.addVertex();
    int vxId2 = graph.addVertex();
    int vxId3 = graph.addVertex();
    // set the identifier of each vertex to something unique
    graph.setStringValue(vertexIdentifierAttribute, vxId1, "V1");
    graph.setStringValue(vertexIdentifierAttribute, vxId2, "V2");
    graph.setStringValue(vertexIdentifierAttribute, vxId3, "V2");
    Map<Integer, Set<Integer>> result = instance.getNodesToMerge(graph, leadVertexChooser, threshold, selectedOnly);
    assertEquals(result, expResult);
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) Test(org.testng.annotations.Test)

Aggregations

Schema (au.gov.asd.tac.constellation.graph.schema.Schema)74 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)63 BeforeMethod (org.testng.annotations.BeforeMethod)50 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)17 Graph (au.gov.asd.tac.constellation.graph.Graph)15 Test (org.testng.annotations.Test)13 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)10 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)8 ArrayList (java.util.ArrayList)8 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)7 IOException (java.io.IOException)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)5 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)5 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)3 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)3 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)2 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)2