use of au.gov.asd.tac.constellation.views.find2.FindViewController in project constellation by constellation-app.
the class FindViewControllerNGTest method testUpdateBasicReplaceParameters.
/**
* Test of updateBasicReplaceParameters method, of class FindViewController.
*/
@Test
public void testUpdateBasicReplaceParameters() {
System.out.println("updateBasicReplaceParameters");
FindViewController instance = FindViewController.getDefault();
List<Attribute> attributeList = new ArrayList<>();
instance.updateBasicReplaceParameters(parameters);
BasicFindReplaceParameters result = instance.getCurrentBasicReplaceParameters();
// The object is copied in the updateBasicFindParameters function
// This will cause a direct comparison of the object to be false
assertEquals(result, parameters);
assertNotEquals(result, parameters2);
}
use of au.gov.asd.tac.constellation.views.find2.FindViewController in project constellation by constellation-app.
the class FindViewControllerNGTest method testGetCurrentBasicFindParameters.
/**
* Test of getCurrentBasicFindParameters method, of class
* FindViewController.
*/
@Test
public void testGetCurrentBasicFindParameters() {
System.out.println("getCurrentBasicFindParameters");
final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
/**
* Check getting getCurrentBasicReplaceParamters returns the default
* parameters
*/
BasicFindReplaceParameters defaultParameters = new BasicFindReplaceParameters();
instance.updateBasicFindParameters(defaultParameters);
assertEquals(instance.getCurrentBasicFindParameters(), defaultParameters);
/**
* Check getting getCurrentBasicReplaceParamters returns the matching
* parameters of what it was set to
*/
instance.updateBasicFindParameters(parameters);
assertEquals(instance.getCurrentBasicFindParameters(), parameters);
}
use of au.gov.asd.tac.constellation.views.find2.FindViewController in project constellation by constellation-app.
the class FindViewControllerNGTest method testGetCurrentBasicReplaceParameters.
/**
* Test of getCurrentBasicReplaceParameters method, of class
* FindViewController.
*/
@Test
public void testGetCurrentBasicReplaceParameters() {
System.out.println("getCurrentBasicReplaceParameters");
final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
// Check getting getCurrentBasicReplaceParamters returns the default
// when it has not been set
BasicFindReplaceParameters defaultParameters = new BasicFindReplaceParameters();
instance.updateBasicReplaceParameters(defaultParameters);
assertEquals(instance.getCurrentBasicReplaceParameters(), defaultParameters);
// Check getting getCurrentBasicReplaceParamters returns the parameters it has been set to
// it has been set to when it has not been set
instance.updateBasicReplaceParameters(parameters2);
assertEquals(instance.getCurrentBasicReplaceParameters(), parameters2);
}
use of au.gov.asd.tac.constellation.views.find2.FindViewController in project constellation by constellation-app.
the class FindViewControllerNGTest method testUpdateBasicFindParameters.
/**
* Test of updateBasicFindParameters method, of class FindViewController.
*/
@Test
public void testUpdateBasicFindParameters() {
System.out.println("updateBasicFindParameters");
FindViewController instance = FindViewController.getDefault();
List<Attribute> attributeList = new ArrayList<>();
BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("equal", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
instance.updateBasicFindParameters(parameters);
BasicFindReplaceParameters result = instance.getCurrentBasicFindParameters();
// The object is copied in the updateBasicFindParameters function
// This will cause a direct comparison of the object to be false
assertEquals(result, parameters);
BasicFindReplaceParameters parameters2 = new BasicFindReplaceParameters("notEqual", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
assertNotEquals(result, parameters2);
// TODO review the generated test code and remove the default call to fail.
}
use of au.gov.asd.tac.constellation.views.find2.FindViewController 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);
}
}
Aggregations