Search in sources :

Example 6 with FindViewController

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);
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 7 with FindViewController

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);
}
Also used : BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 8 with FindViewController

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);
}
Also used : BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 9 with FindViewController

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.
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) Test(org.testng.annotations.Test)

Example 10 with FindViewController

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

Aggregations

Test (org.testng.annotations.Test)12 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)10 ChoiceBox (javafx.scene.control.ChoiceBox)8 ArrayList (java.util.ArrayList)7 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)5 TextField (javafx.scene.control.TextField)5 Attribute (au.gov.asd.tac.constellation.graph.Attribute)4 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)4 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)3 StringCriteriaPanel (au.gov.asd.tac.constellation.views.find2.components.advanced.StringCriteriaPanel)3 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)3 StringCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.StringCriteriaValues)3 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)2 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)2 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)2 FindViewTopComponent (au.gov.asd.tac.constellation.views.find2.FindViewTopComponent)2