use of au.gov.asd.tac.constellation.graph.manager.GraphManager in project constellation by constellation-app.
the class DataAccessViewTopComponentNGTest method componentShowing.
@Test(enabled = false)
public void componentShowing() {
final GraphManager graphManager = mock(GraphManager.class);
final Graph graph = mock(Graph.class);
when(graphManager.getActiveGraph()).thenReturn(graph);
final DataAccessViewTopComponent spiedTopComponent = spy(dataAccessViewTopComponent);
doNothing().when(spiedTopComponent).handleNewGraph(graph);
try (final MockedStatic<GraphManager> graphManagerMockedStatic = Mockito.mockStatic(GraphManager.class)) {
graphManagerMockedStatic.when(GraphManager::getDefault).thenReturn(graphManager);
spiedTopComponent.componentShowing();
verify(spiedTopComponent).handleNewGraph(graph);
}
}
use of au.gov.asd.tac.constellation.graph.manager.GraphManager in project constellation by constellation-app.
the class DataAccessPaneNGTest method update_active_graph_present.
@Test
public void update_active_graph_present() {
doNothing().when(dataAccessPane).update(isNull(String.class));
doNothing().when(dataAccessPane).update(isNull(Graph.class));
try (final MockedStatic<GraphManager> graphManageMockedStatic = Mockito.mockStatic(GraphManager.class)) {
final GraphManager graphManager = mock(GraphManager.class);
graphManageMockedStatic.when(GraphManager::getDefault).thenReturn(graphManager);
final Graph graph = mock(Graph.class);
when(graphManager.getActiveGraph()).thenReturn(graph);
when(graph.getId()).thenReturn("graphId");
dataAccessPane.update();
verify(dataAccessPane).update("graphId");
}
}
use of au.gov.asd.tac.constellation.graph.manager.GraphManager in project constellation by constellation-app.
the class DataAccessPaneNGTest method update_active_graph_not_present.
@Test
public void update_active_graph_not_present() {
doNothing().when(dataAccessPane).update(isNull(String.class));
try (final MockedStatic<GraphManager> graphManageMockedStatic = Mockito.mockStatic(GraphManager.class)) {
final GraphManager graphManager = mock(GraphManager.class);
graphManageMockedStatic.when(GraphManager::getDefault).thenReturn(graphManager);
when(graphManager.getActiveGraph()).thenReturn(null);
dataAccessPane.update();
verify(dataAccessPane).update((String) null);
}
}
use of au.gov.asd.tac.constellation.graph.manager.GraphManager in project constellation by constellation-app.
the class FindViewControllerNGTest method testPopulateAttributes.
/**
* Test of populateAttributes method, of class FindViewController.
*/
@Test
public void testPopulateAttributes() {
System.out.println("populateAttributes");
/**
* Set up the graph with 4 vertexs, 4 transactions, 3 vertex attributes
* (2 of type string), 3 transaction attributes (2 of type string)
*/
setupGraph();
/**
* Create a mock of the top component, get an intsance of the
* controller, create a mock of the graph manager, when getAllGraphs is
* called return the graphMap created in this class
*/
final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
final GraphManager gm = Mockito.mock(GraphManager.class);
when(gm.getAllGraphs()).thenReturn(graphMap);
try (MockedStatic<GraphManager> mockedStatic = Mockito.mockStatic(GraphManager.class)) {
mockedStatic.when(() -> GraphManager.getDefault()).thenReturn(gm);
List<Attribute> attributes = new ArrayList<>();
GraphElementType type = GraphElementType.VERTEX;
List<String> result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
assertEquals(result.get(0), "Label");
assertEquals(result.get(1), "Identifier");
assertEquals(result.size(), 2);
type = GraphElementType.TRANSACTION;
result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
assertEquals(result.get(0), "Label");
assertEquals(result.get(1), "Identifier");
assertEquals(result.size(), 2);
type = GraphElementType.EDGE;
result = instance.populateAttributes(type, attributes, Long.MIN_VALUE);
assertEquals(result.size(), 0);
}
// TODO review the generated test code and remove the default call to fail.
}
use of au.gov.asd.tac.constellation.graph.manager.GraphManager in project constellation by constellation-app.
the class FindViewControllerNGTest method testRetriveMatchingElements.
/**
* Test of retriveMatchingElements method, of class FindViewController.
*/
@Test
public void testRetriveMatchingElements() {
System.out.println("retriveMatchingElements");
/**
* Set up the graph with 4 vertexs, 4 transactions, 3 vertex attributes
* (2 of type string), 3 transaction attributes (2 of type string)
*/
setupGraph();
/**
* Create a mock of the top component, get an instance of the
* controller, create a mock of the graph manager, when getAllGraphs is
* called return the graphMap created in this class
*/
final FindViewTopComponent findViewTopComponent = mock(FindViewTopComponent.class);
FindViewController instance = FindViewController.getDefault().init(findViewTopComponent);
final GraphManager gm = Mockito.mock(GraphManager.class);
when(gm.getAllGraphs()).thenReturn(graphMap);
when(gm.getActiveGraph()).thenReturn(graph);
System.out.println("before try");
try (MockedStatic<GraphManager> mockedStatic = Mockito.mockStatic(GraphManager.class)) {
mockedStatic.when(() -> GraphManager.getDefault()).thenReturn(gm);
System.out.println("in try");
try (MockedStatic<PluginExecution> mockedStaticPlugin = Mockito.mockStatic(PluginExecution.class)) {
PluginExecution pluginExecution = mock(PluginExecution.class);
/**
* The first test should execute the plugin once on graph as the
* parameters are not set to look at all graphs
*/
when(pluginExecution.executeLater(Mockito.eq(graph))).thenReturn(null);
mockedStaticPlugin.when(() -> PluginExecution.withPlugin(Mockito.any(Plugin.class))).thenReturn(pluginExecution);
instance.retriveMatchingElements(true, false);
verify(pluginExecution).executeLater(Mockito.eq(graph));
/**
* Set the parameters to find in all graphs and repeat the same
* process. The plugin should be executed on graph a second
* time, and should be executed on graph2 for the first time.
*/
instance.updateBasicFindParameters(parametersAllGraphs);
when(pluginExecution.executeLater(Mockito.any(Graph.class))).thenReturn(null);
mockedStaticPlugin.when(() -> PluginExecution.withPlugin(Mockito.any(Plugin.class))).thenReturn(pluginExecution);
instance.retriveMatchingElements(true, false);
verify(pluginExecution, times(2)).executeLater(Mockito.eq(graph));
verify(pluginExecution).executeLater(Mockito.eq(graph2));
}
}
}
Aggregations