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