Search in sources :

Example 1 with StringCriteriaPanel

use of au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel in project constellation by constellation-app.

the class AdvancedFindTab method addCriteriaPane.

/**
 * This adds a criteriaPane to the provided graphElement type list. The
 * initial pane will be of type string.
 *
 * @param type
 */
public void addCriteriaPane(final GraphElementType type) {
    // Retrieve the corresponding criteria list and grid pane for the type
    final List<AdvancedCriteriaBorderPane> criteriaList = getCorrespondingCriteriaList(type);
    final GridPane gridPane = getCorrespondingGridPane(type);
    // adds a new StrinCriteriaPanel to the end of the criteriaPaneList
    criteriaList.add(new StringCriteriaPanel(this, "Identifier", getSelectedGraphElementType()));
    gridPane.add(criteriaList.get(criteriaList.size() - 1), 0, gridPane.getRowCount());
    GridPane.setHgrow(criteriaList.get(criteriaList.size() - 1), Priority.ALWAYS);
    // update the grid colours to match the new list order
    updateGridColours(type);
}
Also used : GridPane(javafx.scene.layout.GridPane) StringCriteriaPanel(au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel) AdvancedCriteriaBorderPane(au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)

Example 2 with StringCriteriaPanel

use of au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel 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 3 with StringCriteriaPanel

use of au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel 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 4 with StringCriteriaPanel

use of au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel in project constellation by constellation-app.

the class StringCriteriaPanelNGTest method testGetSearchFieldText.

/**
 * Test of getSearchFieldText method, of class StringCriteriaPanel.
 */
@Test
public void testGetSearchFieldText() {
    System.out.println("getSearchFieldText");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    StringCriteriaPanel stringCriteriaPanel = new StringCriteriaPanel(parentComponent, "Identifier", type);
    stringCriteriaPanel.getFilterChoiceBox().getSelectionModel().select("Is");
    stringCriteriaPanel.setSearchFieldText("test");
    assertEquals(stringCriteriaPanel.getSearchFieldText(), "test");
}
Also used : AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 5 with StringCriteriaPanel

use of au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel in project constellation by constellation-app.

the class StringCriteriaPanelNGTest method testGetType.

/**
 * Test of getType method, of class StringCriteriaPanel.
 */
@Test
public void testGetType() {
    System.out.println("getType");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    StringCriteriaPanel stringCriteriaPanel = new StringCriteriaPanel(parentComponent, "Identifier", type);
    assertEquals(stringCriteriaPanel.getType(), StringAttributeDescription.ATTRIBUTE_NAME);
}
Also used : AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Aggregations

GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)8 Test (org.testng.annotations.Test)8 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)5 StringCriteriaPanel (au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel)5 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)5 ArrayList (java.util.ArrayList)5 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)4 StringCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues)4 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)3 ChoiceBox (javafx.scene.control.ChoiceBox)3 GridPane (javafx.scene.layout.GridPane)2