Search in sources :

Example 16 with GraphElementType

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

the class BooleanCriteriaPanelNGTest method testGetCriteriaValues.

/**
 * Test of getCriteriaValues method, of class BooleanCriteriaPanel.
 */
@Test
public void testGetCriteriaValues() {
    System.out.println("getCriteriaValues");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    BooleanCriteriaPanel booleanCriteriaPanel = new BooleanCriteriaPanel(parentComponent, "dim", type);
    final List<AdvancedCriteriaBorderPane> tempList = new ArrayList<>();
    final GridPane tempGrid = new GridPane();
    tempList.add(booleanCriteriaPanel);
    tempGrid.add(tempList.get(0), 0, 0);
    when(parentComponent.getCorrespondingCriteriaList(Mockito.eq(type))).thenReturn(tempList);
    when(parentComponent.getCorrespondingGridPane(Mockito.eq(type))).thenReturn(tempGrid);
    final List<AdvancedCriteriaBorderPane> criteriaList = parentComponent.getCorrespondingCriteriaList(type);
    final FindCriteriaValues result = criteriaList.get(0).getCriteriaValues();
    final BooleanCriteriaValues boolResult = (BooleanCriteriaValues) result;
    assertEquals(boolResult.getAttribute(), "dim");
    assertEquals(boolResult.getAttributeType(), "boolean");
    assertEquals(boolResult.getFilter(), "Is");
    assertEquals(boolResult.getBoolValue(), true);
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) GridPane(javafx.scene.layout.GridPane) AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) ArrayList(java.util.ArrayList) BooleanCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 17 with GraphElementType

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

the class AdvancedFindTabNGTest method testGetCriteriaValues.

/**
 * Test of getCriteriaValues method, of class AdvancedFindTab.
 */
@Test
public void testGetCriteriaValues() {
    System.out.println("getCriteriaValues");
    setupGraph();
    GraphElementType type = GraphElementType.VERTEX;
    List<AdvancedCriteriaBorderPane> criteriaList = new ArrayList<>();
    AdvancedCriteriaBorderPane pane1 = new StringCriteriaPanel(advancedTab, "Identifier", type);
    AdvancedCriteriaBorderPane pane2 = new StringCriteriaPanel(advancedTab, "Label", type);
    criteriaList.add(pane1);
    criteriaList.add(pane2);
    List<FindCriteriaValues> resultsList = advancedTab.getCriteriaValues(criteriaList);
    assertEquals(resultsList.get(0).getAttribute(), "Identifier");
    assertEquals(resultsList.get(1).getAttribute(), "Label");
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) ArrayList(java.util.ArrayList) StringCriteriaPanel(au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) AdvancedCriteriaBorderPane(au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane) Test(org.testng.annotations.Test)

Example 18 with GraphElementType

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

the class AdvancedFindTabNGTest method testFindNextAction.

/**
 * Test of findNextAction method, of class AdvancedFindTab.
 */
@Test
public void testFindNextAction() {
    System.out.println("findNextAction");
    setupGraph();
    // Create a controller mock and do nothing on retriveMatchingElements()
    FindViewController mockController = mock(FindViewController.class);
    mockController.init(spyTopComponent);
    doNothing().when(mockController).retrieveAdvancedSearch(Mockito.eq(false), Mockito.eq(true));
    GraphElementType graphElementType = GraphElementType.VERTEX;
    /**
     * Create temporary advancedFindMock, pane, criteriaPaneList,
     * LookForChoiceBox, findCriteriaValuesList and a stringCriteriaValue
     */
    AdvancedFindTab advancedFindMock = mock(AdvancedFindTab.class);
    StringCriteriaPanel tempPane = new StringCriteriaPanel(advancedTab, "Identifer", graphElementType);
    tempPane.setSearchFieldText("hello");
    final List<AdvancedCriteriaBorderPane> criteriaPaneList = new ArrayList<>();
    criteriaPaneList.add(tempPane);
    final ChoiceBox<String> lookForChoiceBox = new ChoiceBox<>();
    lookForChoiceBox.getItems().add("Node");
    lookForChoiceBox.getSelectionModel().select(0);
    final List<FindCriteriaValues> findCriteriaValues = new ArrayList<>();
    final StringCriteriaValues stringCriteriaValue = new StringCriteriaValues("string", "Identifer", "Is", "hello", false, false);
    findCriteriaValues.add(stringCriteriaValue);
    // When each function is called return the temporarily created elements above
    when(advancedFindMock.getCorrespondingCriteriaList(graphElementType)).thenReturn(criteriaPaneList);
    when(advancedFindMock.getCriteriaValues(criteriaPaneList)).thenReturn(findCriteriaValues);
    when(advancedFindMock.getLookForChoiceBox()).thenReturn(lookForChoiceBox);
    // Do real call on findAllAction
    doCallRealMethod().when(advancedFindMock).findNextAction();
    // Do nothing on updateAdvancedSearchParameters()
    doNothing().when(advancedFindMock).updateAdvancedSearchParameters(graphElementType);
    /**
     * Create a static mock of the FindViewController. Call the
     * findNextAction() then verify that updateAdvancedSearchParameters and
     * retrieveAdvancedSearch were all called once.
     */
    try (MockedStatic<FindViewController> mockedStatic = Mockito.mockStatic(FindViewController.class)) {
        mockedStatic.when(() -> FindViewController.getDefault()).thenReturn(mockController);
        advancedFindMock.findNextAction();
        verify(advancedFindMock, times(1)).updateAdvancedSearchParameters(graphElementType);
        verify(mockController, times(1)).retrieveAdvancedSearch(false, true);
    }
}
Also used : ArrayList(java.util.ArrayList) StringCriteriaPanel(au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) AdvancedCriteriaBorderPane(au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane) StringCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues) ChoiceBox(javafx.scene.control.ChoiceBox) FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) FindViewController(au.gov.asd.tac.constellation.views.find2.FindViewController) Test(org.testng.annotations.Test)

Example 19 with GraphElementType

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

the class AdvancedFindTabNGTest method testDeleteCriteriaPane.

/**
 * Test of deleteCriteriaPane method, of class AdvancedFindTab.
 */
@Test
public void testDeleteCriteriaPane() {
    System.out.println("deleteCriteriaPane");
    setupGraph();
    GraphElementType type = GraphElementType.VERTEX;
    /**
     * Check the the criteriaList increases in size as we add a new
     * criteriaPane
     */
    assertEquals(advancedTab.getCorrespondingCriteriaList(type).size(), 0);
    advancedTab.addCriteriaPane(type);
    assertEquals(advancedTab.getCorrespondingCriteriaList(type).size(), 1);
    advancedTab.addCriteriaPane(type);
    assertEquals(advancedTab.getCorrespondingCriteriaList(type).size(), 2);
    advancedTab.deleteCriteriaPane(advancedTab.getCorrespondingCriteriaList(type).get(1), type, 1);
    assertEquals(advancedTab.getCorrespondingCriteriaList(type).size(), 1);
}
Also used : GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 20 with GraphElementType

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

the class FloatCriteriaPanelNGTest method testGetCriteriaValues.

/**
 * Test of getCriteriaValues method, of class FloatCriteriaPanel.
 */
@Test
public void testGetCriteriaValues() {
    System.out.println("getCriteriaValues");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    FloatCriteriaPanel floatCriteriaPanel = new FloatCriteriaPanel(parentComponent, "x", type);
    floatCriteriaPanel.getFilterChoiceBox().getSelectionModel().select("Is Between");
    floatCriteriaPanel.getSearchField().setText("22");
    floatCriteriaPanel.getSearchFieldTwo().setText("44");
    final List<AdvancedCriteriaBorderPane> tempList = new ArrayList<>();
    final GridPane tempGrid = new GridPane();
    tempList.add(floatCriteriaPanel);
    tempGrid.add(tempList.get(0), 0, 0);
    when(parentComponent.getCorrespondingCriteriaList(Mockito.eq(type))).thenReturn(tempList);
    when(parentComponent.getCorrespondingGridPane(Mockito.eq(type))).thenReturn(tempGrid);
    final List<AdvancedCriteriaBorderPane> criteriaList = parentComponent.getCorrespondingCriteriaList(type);
    final FindCriteriaValues result = criteriaList.get(0).getCriteriaValues();
    final FloatCriteriaValues floatResult = (FloatCriteriaValues) result;
    assertEquals(floatResult.getAttribute(), "x");
    assertEquals(floatResult.getAttributeType(), "float");
    assertEquals(floatResult.getFilter(), "Is Between");
    assertEquals(floatResult.getFloatValuePrimary(), 22f);
    assertEquals(floatResult.getFloatValueSecondary(), 44f);
}
Also used : FindCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues) GridPane(javafx.scene.layout.GridPane) AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) ArrayList(java.util.ArrayList) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) FloatCriteriaValues(au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues) Test(org.testng.annotations.Test)

Aggregations

GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)85 Test (org.testng.annotations.Test)34 ArrayList (java.util.ArrayList)28 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)17 Attribute (au.gov.asd.tac.constellation.graph.Attribute)16 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 HashMap (java.util.HashMap)11 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)10 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)9 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)8 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 Graph (au.gov.asd.tac.constellation.graph.Graph)7 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)5 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)5 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)5 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)5 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)5 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)5 List (java.util.List)5