Search in sources :

Example 11 with AdvancedFindTab

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

the class StringCriteriaPanelNGTest method setUpMethod.

@BeforeMethod
public void setUpMethod() throws Exception {
    findViewTopComponent = mock(FindViewTopComponent.class);
    spyTopComponent = spy(findViewTopComponent);
    findViewPane = mock(FindViewPane.class);
    findViewTabs = mock(FindViewTabs.class);
    FindViewController.getDefault();
    basicFindTab = mock(BasicFindTab.class);
    replaceTab = mock(ReplaceTab.class);
    when(findViewTabs.getParentComponent()).thenReturn(findViewPane);
    when(findViewPane.getTabs()).thenReturn(findViewTabs);
    when(findViewTabs.getBasicFindTab()).thenReturn(basicFindTab);
    when(findViewTabs.getReplaceTab()).thenReturn(replaceTab);
    when(findViewTabs.getAdvancedFindTab()).thenReturn(advancedTab);
    advancedTab = new AdvancedFindTab(findViewTabs);
}
Also used : ReplaceTab(au.gov.asd.tac.constellation.views.find2.components.ReplaceTab) AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) FindViewTabs(au.gov.asd.tac.constellation.views.find2.components.FindViewTabs) BasicFindTab(au.gov.asd.tac.constellation.views.find2.components.BasicFindTab) FindViewTopComponent(au.gov.asd.tac.constellation.views.find2.FindViewTopComponent) FindViewPane(au.gov.asd.tac.constellation.views.find2.components.FindViewPane) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 12 with AdvancedFindTab

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

the class AdvancedFindTabNGTest method testFindAllAction.

/**
 * Test of findAllAction method, of class AdvancedFindTab.
 */
@Test
public void testFindAllAction() {
    System.out.println("findAllAction");
    setupGraph();
    // Create a controller mock and do nothing on retriveMatchingElements()
    FindViewController mockController = mock(FindViewController.class);
    mockController.init(spyTopComponent);
    doNothing().when(mockController).retrieveAdvancedSearch(Mockito.eq(true), Mockito.eq(false));
    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).findAllAction();
    // Do nothing on updateAdvancedSearchParameters()
    doNothing().when(advancedFindMock).updateAdvancedSearchParameters(graphElementType);
    /**
     * Create a static mock of the FindViewController. Call the
     * findAllAction() 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.findAllAction();
        verify(advancedFindMock, times(1)).updateAdvancedSearchParameters(graphElementType);
        verify(mockController, times(1)).retrieveAdvancedSearch(true, false);
    }
}
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 13 with AdvancedFindTab

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

the class AdvancedFindTabNGTest method testFindPreviousAction.

/**
 * Test of findPreviousAction method, of class AdvancedFindTab.
 */
@Test
public void testFindPreviousAction() {
    System.out.println("findPreviousAction");
    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(false));
    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).findPreviousAction();
    // 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.findPreviousAction();
        verify(advancedFindMock, times(1)).updateAdvancedSearchParameters(graphElementType);
        verify(mockController, times(1)).retrieveAdvancedSearch(false, false);
    }
}
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 14 with AdvancedFindTab

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

the class AdvancedFindTabNGTest method testUpdateAdvancedSearchParameters.

/**
 * Test of updateAdvancedSearchParameters method, of class AdvancedFindTab.
 */
@Test
public void testUpdateAdvancedSearchParameters() {
    System.out.println("updateAdvancedSearchParameters");
    final AdvancedSearchParameters controlllerParameters = FindViewController.getDefault().getCurrentAdvancedSearchParameters();
    final GraphElementType elementType = GraphElementType.VERTEX;
    /**
     * Call the updateBasicFindParamters function. Check that each of the
     * javaFX elements passes their corresponding data correctly to the
     * controllers basicFindParamters
     */
    advancedTab.updateAdvancedSearchParameters(elementType);
    /**
     * All parameters should equal the current value of the advancedFindTabs
     * elements
     */
    assertEquals(controlllerParameters.getCriteriaValuesList().size(), advancedTab.getCorrespondingCriteriaList(elementType).size());
    assertEquals(controlllerParameters.getGraphElementType(), elementType);
    assertEquals(controlllerParameters.getAllOrAny(), advancedTab.getMatchCriteriaChoiceBox().getSelectionModel().getSelectedItem());
    assertEquals(controlllerParameters.getCurrentSelection(), advancedTab.getCurrentSelectionChoiceBox().getSelectionModel().getSelectedItem());
    assertEquals(controlllerParameters.isSearchAllGraphs(), advancedTab.getSearchAllGraphs().isPressed());
}
Also used : AdvancedSearchParameters(au.gov.asd.tac.constellation.views.find2.components.advanced.utilities.AdvancedSearchParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 15 with AdvancedFindTab

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

the class ColourCriteriaPanelNGTest method testGetType.

/**
 * Test of getType method, of class ColourCriteriaPanel.
 */
@Test
public void testGetType() {
    System.out.println("getType");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    ColourCriteriaPanel colourCriteriaPanel = new ColourCriteriaPanel(parentComponent, "color", type);
    assertEquals(colourCriteriaPanel.getType(), ColorAttributeDescription.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)15 Test (org.testng.annotations.Test)15 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)14 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)8 ArrayList (java.util.ArrayList)8 FindViewTopComponent (au.gov.asd.tac.constellation.views.find2.FindViewTopComponent)4 BasicFindTab (au.gov.asd.tac.constellation.views.find2.components.BasicFindTab)4 FindViewPane (au.gov.asd.tac.constellation.views.find2.components.FindViewPane)4 FindViewTabs (au.gov.asd.tac.constellation.views.find2.components.FindViewTabs)4 ReplaceTab (au.gov.asd.tac.constellation.views.find2.components.ReplaceTab)4 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)4 StringCriteriaPanel (au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel)4 StringCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues)4 GridPane (javafx.scene.layout.GridPane)4 BeforeMethod (org.testng.annotations.BeforeMethod)4 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)3 ChoiceBox (javafx.scene.control.ChoiceBox)3 BooleanCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.BooleanCriteriaValues)1 ColourCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.ColourCriteriaValues)1 FloatCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FloatCriteriaValues)1