Search in sources :

Example 36 with DualGraph

use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.

the class BlazeUtilitiesNGTest method testGetSelectionColourInput.

/**
 * Test of getSelection method, of class BlazeUtilities. Colour input added
 */
@Test
public void testGetSelectionColourInput() {
    System.out.println("getSelectionColourInput");
    final Graph g = new DualGraph(schema, graph);
    final Pair<BitSet, ConstellationColor> result = BlazeUtilities.getSelection(g, ConstellationColor.BANANA);
    final BitSet resultBitSet = result.getKey();
    final ConstellationColor resultColour = result.getValue();
    assertEquals(resultBitSet.cardinality(), 3);
    assertTrue(resultBitSet.get(vxId1));
    assertFalse(resultBitSet.get(vxId2));
    assertTrue(resultBitSet.get(vxId3));
    assertTrue(resultBitSet.get(vxId4));
    assertEquals(resultColour, ConstellationColor.BANANA);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) BitSet(java.util.BitSet) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 37 with DualGraph

use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.

the class SphereGraphWelcomePlugin method run.

/**
 * This method describes what action should be taken when the link is
 * clicked on the Welcome Page
 */
@Override
public void run() {
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    final StoreGraph sg = new StoreGraph(schema);
    schema.newGraph(sg);
    final Graph dualGraph = new DualGraph(sg, false);
    final Future<?> f = PluginExecutor.startWith(CoreTestingPluginRegistry.SPHERE_GRAPH_BUILDER).set(SphereGraphBuilderPlugin.ADD_CHARS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.DRAW_MANY_DECORATORS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.DRAW_MANY_TX_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.N_PARAMETER_ID, 100).set(SphereGraphBuilderPlugin.OPTION_PARAMETER_ID, "Random vertices").set(SphereGraphBuilderPlugin.T_PARAMETER_ID, 50).set(SphereGraphBuilderPlugin.USE_ALL_DISPLAYABLE_CHARS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.USE_LABELS_PARAMETER_ID, true).set(SphereGraphBuilderPlugin.USE_RANDOM_ICONS_PARAMETER_ID, true).executeWriteLater(dualGraph);
    try {
        // ensure sphere graph has finished before opening the graph
        f.get();
        final String graphName = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).getLabel().trim().toLowerCase();
        GraphOpener.getDefault().openGraph(dualGraph, graphName);
    } catch (final InterruptedException ex) {
        Thread.currentThread().interrupt();
        LOGGER.log(Level.SEVERE, "Sphere graph creation was interrupted", ex);
    } catch (final ExecutionException ex) {
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) ExecutionException(java.util.concurrent.ExecutionException) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph)

Example 38 with DualGraph

use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.

the class DirectedShortestPathsPluginNGTest method testUpdateParameters.

/**
 * Test of updateParameters method, of class DirectedShortestPathsPlugin.
 */
@Test
public void testUpdateParameters() {
    System.out.println("updateParameters");
    final DirectedShortestPathsPlugin instance = new DirectedShortestPathsPlugin();
    final PluginParameters params = instance.createParameters();
    final PluginParameter<SingleChoiceParameterValue> sourceNode = (PluginParameter<SingleChoiceParameterType.SingleChoiceParameterValue>) params.getParameters().get(SOURCE_NODE_PARAMETER_ID);
    assertTrue(SingleChoiceParameterType.getOptions(sourceNode).isEmpty());
    instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
    assertEquals(SingleChoiceParameterType.getOptions(sourceNode).size(), 5);
    graph.setBooleanValue(vertexSelectedAttribute, vxId4, false);
    instance.updateParameters(new DualGraph(graph.getSchema(), graph), params);
    // confirm the options are only set once (i.e. the graph change won't affect this)
    assertEquals(SingleChoiceParameterType.getOptions(sourceNode).size(), 5);
}
Also used : SingleChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) Test(org.testng.annotations.Test)

Example 39 with DualGraph

use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.

the class SelectAllPluginNGTest method testEdit1.

/**
 * Test of edit method, of class SelectAllPlugin. select all edit with only
 * vx on graph
 */
@Test
public void testEdit1() throws Exception {
    System.out.println("select all edit with only vx on graph");
    // Open a new graph
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    int vxCount = 0;
    final WritableGraph wg = graph.getWritableGraph("TEST", true);
    try {
        // Create Selected Attributes
        selectedV = VisualConcept.VertexAttribute.SELECTED.ensure(wg);
        selectedT = VisualConcept.TransactionAttribute.SELECTED.ensure(wg);
        // Add vertices
        vxId1 = wg.addVertex();
        vxId2 = wg.addVertex();
        // check default value is unselected
        assertFalse(wg.getBooleanValue(selectedV, vxId1));
        assertFalse(wg.getBooleanValue(selectedV, vxId2));
        vxCount = wg.getVertexCount();
    } finally {
        wg.commit();
    }
    // run select all plugin
    PluginExecution.withPlugin(new SelectAllPlugin()).executeNow(graph);
    // Verify both selected and same amount of vx are present
    final ReadableGraph rg = graph.getReadableGraph();
    try {
        assertTrue(rg.getBooleanValue(selectedV, vxId1));
        assertTrue(rg.getBooleanValue(selectedV, vxId2));
        assertEquals(rg.getVertexCount(), vxCount);
    } finally {
        rg.close();
    }
    // rerun plugin to ensure values are not only toggled, but are set explicitly as selected
    // run select all plugin
    PluginExecution.withPlugin(new SelectAllPlugin()).executeNow(graph);
    // Verify both selected and same amount of vx are present
    final ReadableGraph rg2 = graph.getReadableGraph();
    try {
        assertTrue(rg2.getBooleanValue(selectedV, vxId1));
        assertTrue(rg2.getBooleanValue(selectedV, vxId2));
        assertEquals(rg2.getVertexCount(), vxCount);
    } finally {
        rg2.close();
    }
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 40 with DualGraph

use of au.gov.asd.tac.constellation.graph.locking.DualGraph in project constellation by constellation-app.

the class WorkflowQueryPluginNGTest method testExecute.

/**
 * Test of execute method, of class WorkflowQueryPlugin.
 */
@Test
public void testExecute() throws Exception {
    System.out.println("execute");
    final Schema schema = SchemaFactoryUtilities.getSchemaFactory(AnalyticSchemaFactory.ANALYTIC_SCHEMA_ID).createSchema();
    final DualGraph graph = new DualGraph(schema);
    // mock PluginGraphs
    final PluginGraphs pluginGraphs = mock(PluginGraphs.class);
    when(pluginGraphs.getGraph()).thenReturn(graph);
    final PluginInteraction interaction = new TextPluginInteraction();
    final WorkflowQueryPlugin instance = new WorkflowQueryPluginImpl();
    final PluginParameters parameters = instance.createParameters();
    instance.execute(pluginGraphs, interaction, parameters);
}
Also used : PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Schema(au.gov.asd.tac.constellation.graph.schema.Schema) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) TextPluginInteraction(au.gov.asd.tac.constellation.plugins.text.TextPluginInteraction) Test(org.testng.annotations.Test)

Aggregations

DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)66 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)41 Test (org.testng.annotations.Test)30 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)21 Graph (au.gov.asd.tac.constellation.graph.Graph)19 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)18 ArrayList (java.util.ArrayList)13 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)10 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)10 BeforeMethod (org.testng.annotations.BeforeMethod)9 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)7 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)6 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)3 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)3 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)3 VisualConcept (au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept)3 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)3 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)3