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);
}
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);
}
}
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);
}
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();
}
}
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);
}
Aggregations