Search in sources :

Example 6 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters 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 7 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters 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 8 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class FindViewTopComponentNGTest method setupGraph.

private void setupGraph() {
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graphMap.put(graph.getId(), graph);
    try {
        WritableGraph wg = graph.getWritableGraph("", true);
        final int stateId = FindViewConcept.MetaAttribute.FINDVIEW_STATE.ensure(wg);
        ArrayList<Attribute> attributeList = new ArrayList<>();
        BasicFindReplaceParameters parameters = new BasicFindReplaceParameters("label name", "", GraphElementType.GRAPH.VERTEX, attributeList, true, false, false, false, false, false, false, false, false);
        FindResultsList foundResult = new FindResultsList(2, parameters, graph.getId());
        wg.setObjectValue(stateId, 0, foundResult);
        wg.commit();
    } catch (final InterruptedException ex) {
        Exceptions.printStackTrace(ex);
        Thread.currentThread().interrupt();
    }
}
Also used : Attribute(au.gov.asd.tac.constellation.graph.Attribute) ArrayList(java.util.ArrayList) BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) FindResultsList(au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph)

Example 9 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class BasicFindTabNGTest method testUpdateBasicFindParamters.

/**
 * This test should test the updateBasicFindParamters function. It should
 * take all the UI element selections by the user and update the
 * basicFindParameters in the controller. To check this works the
 * controllers parameters should be the same as the UI elements.
 */
@Test
public void testUpdateBasicFindParamters() {
    System.out.println("updateBasicFindParamters");
    final BasicFindReplaceParameters controlllerParameters = FindViewController.getDefault().getCurrentBasicFindParameters();
    basicFindTab.lookForChoiceBox.getSelectionModel().select(0);
    basicFindTab.getFindTextField().setText("test");
    final GraphElementType elementType = GraphElementType.getValue(basicFindTab.lookForChoiceBox.getSelectionModel().getSelectedItem());
    basicFindTab.currentSelectionChoiceBox.getSelectionModel().select(0);
    /**
     * Call the updateBasicFindParamters function. Check that each of the
     * javaFX elements passes their corresponding data correctly to the
     * controllers basicFindParamters
     */
    basicFindTab.updateBasicFindParamters();
    /**
     * All parameters should equal the current value of the basicFindTabs
     * elements
     */
    assertEquals(controlllerParameters.getFindString(), basicFindTab.getFindTextField().getText());
    assertEquals(controlllerParameters.getReplaceString(), "");
    assertEquals(controlllerParameters.getGraphElement(), elementType);
    assertEquals(controlllerParameters.getAttributeList(), basicFindTab.getMatchingAttributeList(elementType));
    assertEquals(controlllerParameters.isStandardText(), basicFindTab.standardRadioBtn.isSelected());
    assertEquals(controlllerParameters.isRegEx(), basicFindTab.regExBtn.isSelected());
    assertEquals(controlllerParameters.isIgnoreCase(), basicFindTab.ignoreCaseCB.isSelected());
    /**
     * All 4 should be false as currentSelectionChoiceBox is set to select
     * index 0 which is "Ignore"
     */
    assertEquals(controlllerParameters.isFindIn(), false);
    assertEquals(controlllerParameters.isAddTo(), false);
    assertEquals(controlllerParameters.isRemoveFrom(), false);
    assertEquals(controlllerParameters.isReplaceIn(), false);
    assertEquals(controlllerParameters.isSearchAllGraphs(), basicFindTab.searchAllGraphs.isSelected());
}
Also used : BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 10 with BasicFindReplaceParameters

use of au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters in project constellation by constellation-app.

the class ReplaceTabNGTest method testUpdateBasicReplaceParamters.

/**
 * Test of updateBasicReplaceParamters method, of class ReplaceTab.
 */
@Test
public void testUpdateBasicReplaceParamters() {
    System.out.println("updateBasicReplaceParamters");
    final BasicFindReplaceParameters controlllerParameters = FindViewController.getDefault().getCurrentBasicReplaceParameters();
    replaceTab.lookForChoiceBox.getSelectionModel().select(0);
    replaceTab.getFindTextField().setText("test");
    replaceTab.getReplaceTextField().setText("replace");
    final GraphElementType elementType = GraphElementType.getValue(replaceTab.lookForChoiceBox.getSelectionModel().getSelectedItem());
    replaceTab.currentSelectionChoiceBox.getSelectionModel().select(0);
    /**
     * Call the updateBasicFindParamters function. Check that each of the
     * javaFX elements passes their corresponding data correctly to the
     * controllers basicFindParamters
     */
    replaceTab.updateBasicReplaceParamters();
    /**
     * All parameters should equal the current value of the basicFindTabs
     * elements
     */
    assertEquals(controlllerParameters.getFindString(), replaceTab.getFindTextField().getText());
    assertEquals(controlllerParameters.getReplaceString(), replaceTab.getReplaceTextField().getText());
    assertEquals(controlllerParameters.getGraphElement(), elementType);
    assertEquals(controlllerParameters.getAttributeList(), replaceTab.getMatchingAttributeList(elementType));
    assertEquals(controlllerParameters.isStandardText(), replaceTab.standardRadioBtn.isSelected());
    assertEquals(controlllerParameters.isRegEx(), replaceTab.regExBtn.isSelected());
    assertEquals(controlllerParameters.isIgnoreCase(), replaceTab.ignoreCaseCB.isSelected());
    /**
     * All 4 should be false as currentSelectionChoiceBox is set to select
     * index 0 which is "Ignore"
     */
    assertEquals(controlllerParameters.isFindIn(), false);
    assertEquals(controlllerParameters.isAddTo(), false);
    assertEquals(controlllerParameters.isRemoveFrom(), false);
    assertEquals(controlllerParameters.isReplaceIn(), false);
    assertEquals(controlllerParameters.isSearchAllGraphs(), replaceTab.searchAllGraphs.isSelected());
// TODO review the generated test code and remove the default call to fail.
}
Also used : BasicFindReplaceParameters(au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Aggregations

BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)13 Attribute (au.gov.asd.tac.constellation.graph.Attribute)9 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)6 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)5 FindResultsList (au.gov.asd.tac.constellation.views.find2.utilities.FindResultsList)5 FindResult (au.gov.asd.tac.constellation.views.find2.utilities.FindResult)3 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)2 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)2 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1