Search in sources :

Example 11 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class BasicFindPluginNGTest method getAttributes.

/**
 * Used to convert the string variant of attributes to the Attribute object
 *
 * @return the list of Attribute objects
 */
private ArrayList<Attribute> getAttributes() {
    final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
    FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
    final GraphManager gm = Mockito.mock(GraphManager.class);
    when(gm.getAllGraphs()).thenReturn(graphMap);
    ArrayList<Attribute> attributes = new ArrayList<>();
    try (MockedStatic<GraphManager> mockedStatic = Mockito.mockStatic(GraphManager.class)) {
        mockedStatic.when(() -> GraphManager.getDefault()).thenReturn(gm);
        GraphElementType type = GraphElementType.VERTEX;
        List<String> result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
        ReadableGraph rg = graph.getReadableGraph();
        for (int i = 0; i < result.size(); i++) {
            int attributeInt = rg.getAttribute(type, result.get(i));
            GraphAttribute ga = new GraphAttribute(rg, attributeInt);
            if (ga.getAttributeType().equals("string")) {
                attributes.add(new GraphAttribute(rg, attributeInt));
                System.out.println(attributes.get(i).getName() + " = attribute name");
            }
        }
        rg.close();
    }
    return attributes;
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) FindViewTopComponent(au.gov.asd.tac.constellation.views.find2.FindViewTopComponent) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) FindViewController(au.gov.asd.tac.constellation.views.find2.FindViewController)

Example 12 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class ReplacePluginNGTest method getAttributes.

/**
 * Used to convert the string variant of attributes to the Attribute object
 *
 * @return the list of Attribute objects
 */
private ArrayList<Attribute> getAttributes() {
    final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
    FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
    final GraphManager gm = Mockito.mock(GraphManager.class);
    when(gm.getAllGraphs()).thenReturn(graphMap);
    ArrayList<Attribute> attributes = new ArrayList<>();
    try (MockedStatic<GraphManager> mockedStatic = Mockito.mockStatic(GraphManager.class)) {
        mockedStatic.when(() -> GraphManager.getDefault()).thenReturn(gm);
        GraphElementType type = GraphElementType.VERTEX;
        List<String> result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
        ReadableGraph rg = graph.getReadableGraph();
        for (int i = 0; i < result.size(); i++) {
            int attributeInt = rg.getAttribute(type, result.get(i));
            GraphAttribute ga = new GraphAttribute(rg, attributeInt);
            if (ga.getAttributeType().equals("string")) {
                attributes.add(new GraphAttribute(rg, attributeInt));
            }
        }
        rg.close();
    }
    return attributes;
}
Also used : ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) Attribute(au.gov.asd.tac.constellation.graph.Attribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) FindViewTopComponent(au.gov.asd.tac.constellation.views.find2.FindViewTopComponent) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) FindViewController(au.gov.asd.tac.constellation.views.find2.FindViewController)

Example 13 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class BasicFindTabNGTest method testSaveSelected.

/**
 * Test of saveSelected method, of class BasicFindTab.
 */
@Test
public void testSaveSelected() {
    System.out.println("saveSelected");
    setupGraph();
    /**
     * Add the label and identifier attributes to the check box list and
     * check the label attribute in the checkBoxMenu inAttributesMenu
     */
    basicFindTab.inAttributesMenu.getItems().add(basicFindTab.attributes.get(0).getName());
    basicFindTab.inAttributesMenu.getItems().add(basicFindTab.attributes.get(1).getName());
    basicFindTab.inAttributesMenu.getCheckModel().check(basicFindTab.attributes.get(0).getName());
    /**
     * Save the selected attributes in the inAttributeMenu to the
     * corresponding attribute list. In this case its the selectedNodeList.
     */
    final GraphElementType elementType = GraphElementType.VERTEX;
    basicFindTab.saveSelected(elementType);
    /**
     * The selectedNodeAttribute list should be of size one since only the
     * label attribute was set as selected. The attribute in index 0 should
     * also be the label attribute.
     */
    assertEquals(basicFindTab.selectedNodeAttributes.size(), 1);
    assertEquals(basicFindTab.selectedNodeAttributes.get(0).getName(), basicFindTab.attributes.get(0).getName());
}
Also used : GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Example 14 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class ReplaceTabNGTest method setupGraph.

private void setupGraph() {
    graph = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graph2 = new DualGraph(SchemaFactoryUtilities.getSchemaFactory(VisualSchemaFactory.VISUAL_SCHEMA_ID).createSchema());
    graphMap.put(graph.getId(), graph);
    graphMap.put(graph2.getId(), graph2);
    try {
        WritableGraph wg = graph.getWritableGraph("", true);
        // Create Selected Attributes
        selectedV = VisualConcept.VertexAttribute.SELECTED.ensure(wg);
        labelV = VisualConcept.VertexAttribute.LABEL.ensure(wg);
        identifierV = VisualConcept.VertexAttribute.IDENTIFIER.ensure(wg);
        xV = VisualConcept.VertexAttribute.X.ensure(wg);
        selectedT = VisualConcept.TransactionAttribute.SELECTED.ensure(wg);
        labelT = VisualConcept.TransactionAttribute.LABEL.ensure(wg);
        identiferT = VisualConcept.TransactionAttribute.IDENTIFIER.ensure(wg);
        widthT = VisualConcept.TransactionAttribute.WIDTH.ensure(wg);
        vxId1 = wg.addVertex();
        wg.setBooleanValue(selectedV, vxId1, false);
        wg.setStringValue(labelV, vxId1, "label name");
        wg.setStringValue(identifierV, vxId1, "identifer name");
        wg.setIntValue(xV, vxId1, 1);
        /**
         * Get the label and the identifier vertex attributes and add them
         * to the attributes list
         */
        GraphElementType elementType = GraphElementType.VERTEX;
        // The label attribute
        int attributeInt = wg.getAttribute(elementType, 1);
        labelAttributeV = new GraphAttribute(wg, attributeInt);
        replaceTab.attributes.add(labelAttributeV);
        // The identifier attribute
        attributeInt = wg.getAttribute(elementType, 2);
        identifierAttributeV = new GraphAttribute(wg, attributeInt);
        replaceTab.attributes.add(identifierAttributeV);
        elementType = GraphElementType.TRANSACTION;
        attributeInt = wg.getAttribute(elementType, 1);
        labelAttributeT = new GraphAttribute(wg, attributeInt);
        attributeInt = wg.getAttribute(elementType, 2);
        identifierAttributeT = new GraphAttribute(wg, attributeInt);
        wg.commit();
    } catch (final InterruptedException ex) {
        Exceptions.printStackTrace(ex);
        Thread.currentThread().interrupt();
    }
}
Also used : GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) DualGraph(au.gov.asd.tac.constellation.graph.locking.DualGraph) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType)

Example 15 with GraphElementType

use of au.gov.asd.tac.constellation.graph.GraphElementType in project constellation by constellation-app.

the class BooleanCriteriaPanelNGTest method testGetType.

/**
 * Test of getType method, of class BooleanCriteriaPanel.
 */
@Test
public void testGetType() {
    System.out.println("getType");
    setupGraph();
    AdvancedFindTab parentComponent = spy(advancedTab);
    final GraphElementType type = GraphElementType.VERTEX;
    BooleanCriteriaPanel booleanCriteriaPanel = new BooleanCriteriaPanel(parentComponent, "dim", type);
    assertEquals(booleanCriteriaPanel.getType(), BooleanAttributeDescription.ATTRIBUTE_NAME);
}
Also used : AdvancedFindTab(au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Test(org.testng.annotations.Test)

Aggregations

GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)85 Test (org.testng.annotations.Test)34 ArrayList (java.util.ArrayList)28 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)17 Attribute (au.gov.asd.tac.constellation.graph.Attribute)16 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)12 HashMap (java.util.HashMap)11 AdvancedFindTab (au.gov.asd.tac.constellation.views.find2.components.AdvancedFindTab)10 FindCriteriaValues (au.gov.asd.tac.constellation.views.find2.components.advanced.criteriavalues.FindCriteriaValues)9 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)8 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)8 Graph (au.gov.asd.tac.constellation.graph.Graph)7 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)5 SchemaAttribute (au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)5 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)5 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)5 FindViewController (au.gov.asd.tac.constellation.views.find2.FindViewController)5 AdvancedCriteriaBorderPane (au.gov.asd.tac.constellation.views.find2.components.advanced.AdvancedCriteriaBorderPane)5 BasicFindReplaceParameters (au.gov.asd.tac.constellation.views.find2.utilities.BasicFindReplaceParameters)5 List (java.util.List)5