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);
}
}
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);
}
}
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);
}
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);
}
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);
}
Aggregations