Search in sources :

Example 56 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph 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 57 with WritableGraph

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

the class DataAccessUtilitiesNGTest method testsaveDataAccessState.

@Test
public void testsaveDataAccessState() throws Exception {
    System.out.println("testsaveDataAccessState");
    // mock Tab
    final Tab tab = mock(Tab.class);
    ObservableList<Tab> observableArrayList = FXCollections.observableArrayList(tab);
    // mock TabPane
    final TabPane tabPane = mock(TabPane.class);
    when(tabPane.getTabs()).thenReturn(observableArrayList);
    final ScrollPane scrollPane = mock(ScrollPane.class);
    final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
    final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
    final PluginParameters pluginParameters = mock(PluginParameters.class);
    final PluginParameter pluginParameter = mock(PluginParameter.class);
    when(tab.getContent()).thenReturn(scrollPane);
    when(scrollPane.getContent()).thenReturn(queryPhasePane);
    when(queryPhasePane.getGlobalParametersPane()).thenReturn(globalParametersPane);
    when(globalParametersPane.getParams()).thenReturn(pluginParameters);
    when(pluginParameter.getStringValue()).thenReturn("something");
    final String someKey = "someKey";
    final Map<String, PluginParameter<?>> map = Map.of(someKey, pluginParameter);
    when(pluginParameters.getParameters()).thenReturn(map);
    // mock graph
    final Graph graph = mock(Graph.class);
    final WritableGraph wGraph = mock(WritableGraph.class);
    when(graph.getWritableGraph("Update Data Access State", true)).thenReturn(wGraph);
    DataAccessUtilities.saveDataAccessState(tabPane, graph);
    final DataAccessState expectedTab = new DataAccessState();
    expectedTab.newTab();
    expectedTab.add("someKey", "something");
    assertEquals(expectedTab.getState().size(), 1);
    verify(wGraph).setObjectValue(0, 0, expectedTab);
}
Also used : TabPane(javafx.scene.control.TabPane) DataAccessTabPane(au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) GlobalParametersPane(au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) Tab(javafx.scene.control.Tab) DataAccessState(au.gov.asd.tac.constellation.views.dataaccess.state.DataAccessState) ScrollPane(javafx.scene.control.ScrollPane) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 58 with WritableGraph

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

the class AdvancedSearchPluginNGTest method testEdit.

/**
 * Test of edit method, of class AdvancedSearchPlugin.
 */
@Test
public void testEdit() throws Exception {
    System.out.println("edit");
    setupGraph();
    GraphElementType elementType = GraphElementType.VERTEX;
    final String all = "All";
    final String any = "Any";
    final String ignore = "Ignore";
    final String addTo = "Add To";
    final String removeFrom = "Remove From";
    final String findIn = "Find In";
    boolean searchAllGraphs = false;
    // STRING | VERTEX | MATCH ANY CRITERIA | INGORE CURRENT SELECTION | SEARCH 1 GRAPH
    // Is
    List<FindCriteriaValues> findCriteriaValuesList = new ArrayList<>();
    StringCriteriaValues stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    AdvancedSearchParameters parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    AdvancedSearchPlugin advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    ReadableGraph rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is not
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is Not", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Contains
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Contains", "identifer", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Doesn't Contain
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Doesn't Contain", "identifer", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Begins With
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Begins With", "iden", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Ends With
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Ends With", "name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Matches (Regex)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Matches (Regex)", "den", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Float
    // Is
    findCriteriaValuesList = new ArrayList<>();
    FloatCriteriaValues floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is", 1);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Not", 1);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Is Less Than
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Less Than", 4);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Greater Than
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Greater Than", 0);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Between
    findCriteriaValuesList = new ArrayList<>();
    floatCriteriaValues = new FloatCriteriaValues("float", "x", "Is Between", 0, 4);
    findCriteriaValuesList.add(floatCriteriaValues);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Boolean
    // Is
    findCriteriaValuesList = new ArrayList<>();
    BooleanCriteriaValues booleanCriteriaValue = new BooleanCriteriaValues("boolean", "dim", "Is", true);
    findCriteriaValuesList.add(booleanCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Constellation Color
    // Is
    findCriteriaValuesList = new ArrayList<>();
    ColourCriteriaValues colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is", ConstellationColor.BLUE);
    findCriteriaValuesList.add(colourCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    colourCriteriaValue = new ColourCriteriaValues("color", "color", "Is Not", ConstellationColor.BLUE);
    findCriteriaValuesList.add(colourCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // Constellation Icon
    // Is
    findCriteriaValuesList = new ArrayList<>();
    IconCriteriaValues iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(iconCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    rg.close();
    // Is Not
    findCriteriaValuesList = new ArrayList<>();
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is Not", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(iconCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    rg.close();
    // DateTime
    // Occured On
    findCriteriaValuesList = new ArrayList<>();
    DateTimeCriteriaValues dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured On", formatDateTime(testTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    elementType = GraphElementType.TRANSACTION;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
    LOG.log(Level.SEVERE, dateTimeCriteriaValue.getDateTimeStringPrimaryValue());
    LOG.log(Level.SEVERE, rg.getObjectValue(dateTimeT, txId1).toString());
    assertEquals(rg.getBooleanValue(selectedT, txId1), true);
    assertEquals(rg.getBooleanValue(selectedT, txId2), true);
    assertEquals(rg.getBooleanValue(selectedT, txId3), false);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Didn't Occur On
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Didn't Occur On", formatDateTime(testTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), true);
    rg.close();
    // Occured Before
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Before", formatDateTime(plus1YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), true);
    assertEquals(rg.getBooleanValue(selectedT, txId2), true);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Occured After
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured After", formatDateTime(plus1YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), true);
    rg.close();
    // Occured Between
    findCriteriaValuesList = new ArrayList<>();
    dateTimeCriteriaValue = new DateTimeCriteriaValues("datetime", "DateTime", "Occured Between", formatDateTime(testTime), formatDateTime(plus2YearTestTime));
    findCriteriaValuesList.add(dateTimeCriteriaValue);
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedT, txId1), false);
    assertEquals(rg.getBooleanValue(selectedT, txId2), false);
    assertEquals(rg.getBooleanValue(selectedT, txId3), true);
    assertEquals(rg.getBooleanValue(selectedT, txId4), false);
    rg.close();
    // Test multiple criteria (any)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.Australia"));
    findCriteriaValuesList.add(stringCriteriaValue1);
    findCriteriaValuesList.add(iconCriteriaValue);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId6), false);
    rg.close();
    // Test multiple criteria (any)
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "a vertex", true, false);
    iconCriteriaValue = new IconCriteriaValues("icon", "background_icon", "Is", IconManager.getIcon("Flag.England"));
    findCriteriaValuesList.add(stringCriteriaValue1);
    findCriteriaValuesList.add(iconCriteriaValue);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, all, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId4), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
    rg.close();
    // Test find next
    findCriteriaValuesList = new ArrayList<>();
    stringCriteriaValue1 = new StringCriteriaValues("string", "Identifier", "Is", "identifer name", true, false);
    findCriteriaValuesList.add(stringCriteriaValue1);
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, true);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    rg.close();
    // Test find prev
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, ignore, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, false, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    // Test add to
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, addTo, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    WritableGraph wg = graph.getWritableGraph("", true);
    wg.setBooleanValue(selectedV, vxId6, true);
    wg.setBooleanValue(selectedV, vxId7, true);
    wg.commit();
    rg = graph.getReadableGraph();
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), true);
    rg.close();
    // Test Remove From
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, removeFrom, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    rg = graph.getReadableGraph();
    // all but vxId6 match the criteria, so vxId6 remains selected
    assertEquals(rg.getBooleanValue(selectedV, vxId6), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId7), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId1), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), false);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
    // Test Find In
    elementType = GraphElementType.VERTEX;
    parameters = new AdvancedSearchParameters(findCriteriaValuesList, elementType, any, findIn, searchAllGraphs);
    advancedSearchPlugin = new AdvancedSearchPlugin(parameters, true, false);
    PluginExecution.withPlugin(advancedSearchPlugin).executeNow(graph);
    wg = graph.getWritableGraph("", true);
    wg.setBooleanValue(selectedV, vxId1, true);
    wg.setBooleanValue(selectedV, vxId2, true);
    wg.commit();
    rg = graph.getReadableGraph();
    // vxId3 is not selected so will not be considered in the
    assertEquals(rg.getBooleanValue(selectedV, vxId1), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId2), true);
    assertEquals(rg.getBooleanValue(selectedV, vxId3), false);
    rg.close();
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ArrayList(java.util.ArrayList) ColourCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues) DateTimeCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.DateTimeCriteriaValues) AdvancedSearchParameters(au.gov.asd.tac.constellation.views.find2.components.advanced.utilities.AdvancedSearchParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues) FloatCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues) FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) IconCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.IconCriteriaValues) BooleanCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 59 with WritableGraph

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

the class FindViewTopComponentNGTest method setupGraph.

private void setupGraph() {
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graphMap.put(graph.getId(), graph);
    try {
        WritableGraph wg = graph.getWritableGraph("", true);
        final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
        ArrayList<Attribute> attributeList = new ArrayList<>();
        BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
        FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
        wg.setObjectValue(stateId, 0, foundResult);
        wg.commit();
    } catch (final InterruptedException ex) {
        Exceptions.printStackTrace(ex);
        Thread.currentThread().interrupt();
    }
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) FindResultsList(au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph)

Example 60 with WritableGraph

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

the class AdvancedFindTabNGTest method setupGraph.

private void setupGraph() {
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graph2 = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graphMap.put(graph.getId(), graph);
    graphMap.put(graph2.getId(), graph2);
    try {
        WritableGraph wg = graph.getWritableGraph("", true);
        // Create Selected Attributes
        selectedV = VisualConcept.VertexAttribute.SELECTED.ensure(wg);
        labelV = VisualConcept.VertexAttribute.LABEL.ensure(wg);
        identifierV = VisualConcept.VertexAttribute.IDENTIFIER.ensure(wg);
        xV = VisualConcept.VertexAttribute.X.ensure(wg);
        selectedT = VisualConcept.TransactionAttribute.SELECTED.ensure(wg);
        labelT = VisualConcept.TransactionAttribute.LABEL.ensure(wg);
        identiferT = VisualConcept.TransactionAttribute.IDENTIFIER.ensure(wg);
        widthT = VisualConcept.TransactionAttribute.WIDTH.ensure(wg);
        vxId1 = wg.addVertex();
        wg.setBooleanValue(selectedV, vxId1, false);
        wg.setStringValue(labelV, vxId1, "label name");
        wg.setStringValue(identifierV, vxId1, "identifer name");
        wg.setIntValue(xV, vxId1, 1);
        wg.commit();
    } catch (final InterruptedException ex) {
        Exceptions.printStackTrace(ex);
        Thread.currentThread().interrupt();
    }
}
Also used : DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph)

Aggregations

WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)116 Test (org.testng.annotations.Test)77 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)39 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)37 Graph (au.gov.asd.tac.constellation.graph.Graph)20 ArrayList (java.util.ArrayList)14 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)9 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)8 CompositeNodeState (au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.CompositeNodeState)8 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)6 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 Attribute (au.gov.asd.tac.constellation.graph.Attribute)5 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)4 DuplicateKeyException (au.gov.asd.tac.constellation.graph.DuplicateKeyException)3 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)3