Search in sources :

Example 1 with BasicFindTab

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

the class BasicFindTabNGTest method testFindAllAction.

/**
 * Test of findAllAction method, of class BasicFindTab.
 */
@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).retriveMatchingElements(Mockito.eq(true), Mockito.eq(false));
    /**
     * Create a basicFindMock and adds a temporary choice box and textFild
     * for the functions to work.
     */
    BasicFindTab basicFindMock = mock(BasicFindTab.class);
    final ChoiceBox<String> lookForChoiceBox = new ChoiceBox<>();
    lookForChoiceBox.getItems().add("Node");
    lookForChoiceBox.getSelectionModel().select(0);
    final TextField findTextField = new TextField("test");
    // Mock the getters to return the newly made java fx element.
    when(basicFindMock.getLookForChoiceBox()).thenReturn(lookForChoiceBox);
    when(basicFindMock.getFindTextField()).thenReturn(findTextField);
    // Do nothing on saveSelected() and updateBasicFindParamters()
    doCallRealMethod().when(basicFindMock).findAllAction();
    doNothing().when(basicFindMock).saveSelected(Mockito.any());
    doNothing().when(basicFindMock).updateBasicFindParamters();
    /**
     * Create a static mock of the FindViewController. Call the
     * findAllAction() then verify that saveSelected,
     * updateBasicFindParameters and retrieveMatchingElements were all
     * called once.
     */
    try (MockedStatic<FindViewController> mockedStatic = Mockito.mockStatic(FindViewController.class)) {
        mockedStatic.when(() -> FindViewController.getDefault()).thenReturn(mockController);
        basicFindMock.findAllAction();
        verify(basicFindMock, times(1)).saveSelected(Mockito.eq(GraphElementType.VERTEX));
        verify(basicFindMock, times(1)).updateBasicFindParamters();
        verify(mockController, times(1)).retriveMatchingElements(true, false);
    }
}
Also used : TextField(javafx.scene.control.TextField) FindViewController(au.gov.asd.tac.constellation.views.find2.FindViewController) ChoiceBox(javafx.scene.control.ChoiceBox) Test(org.testng.annotations.Test)

Example 2 with BasicFindTab

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

the class BasicFindTabNGTest method testFindNextAction.

/**
 * Test of findNextAction method, of class BasicFindTab.
 */
@Test
public void testFindNextAction() {
    System.out.println("findNextAction");
    // Refer to testFindAllAction for comments
    setupGraph();
    FindViewController mockController = mock(FindViewController.class);
    mockController.init(spyTopComponent);
    doNothing().when(mockController).retriveMatchingElements(Mockito.eq(false), Mockito.eq(true));
    BasicFindTab basicFindMock = mock(BasicFindTab.class);
    final ChoiceBox<String> lookForChoiceBox = new ChoiceBox<>();
    lookForChoiceBox.getItems().add("Node");
    lookForChoiceBox.getSelectionModel().select(0);
    final TextField findTextField = new TextField("test");
    when(basicFindMock.getLookForChoiceBox()).thenReturn(lookForChoiceBox);
    when(basicFindMock.getFindTextField()).thenReturn(findTextField);
    doCallRealMethod().when(basicFindMock).findNextAction();
    doNothing().when(basicFindMock).saveSelected(Mockito.any());
    doNothing().when(basicFindMock).updateBasicFindParamters();
    try (MockedStatic<FindViewController> mockedStatic = Mockito.mockStatic(FindViewController.class)) {
        mockedStatic.when(() -> FindViewController.getDefault()).thenReturn(mockController);
        basicFindMock.findNextAction();
        verify(basicFindMock, times(1)).saveSelected(Mockito.eq(GraphElementType.VERTEX));
        verify(basicFindMock, times(1)).updateBasicFindParamters();
        verify(mockController, times(1)).retriveMatchingElements(false, true);
    }
}
Also used : TextField(javafx.scene.control.TextField) FindViewController(au.gov.asd.tac.constellation.views.find2.FindViewController) ChoiceBox(javafx.scene.control.ChoiceBox) Test(org.testng.annotations.Test)

Example 3 with BasicFindTab

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

the class BooleanCriteriaPanelNGTest 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 4 with BasicFindTab

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

the class FloatCriteriaPanelNGTest 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 5 with BasicFindTab

use of au.gov.asd.tac.constellation.views.find2.components.BasicFindTab 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)

Aggregations

FindViewTopComponent (au.gov.asd.tac.constellation.views.find2.FindViewTopComponent)4 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)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 BeforeMethod (org.testng.annotations.BeforeMethod)4 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)3 ChoiceBox (javafx.scene.control.ChoiceBox)3 TextField (javafx.scene.control.TextField)3 Test (org.testng.annotations.Test)3