use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecutePluginNowWithNullGraph.
@Test
public void testExecutePluginNowWithNullGraph() throws Exception {
System.out.println("executePluginNow");
Graph graph = null;
Plugin plugin = mock(Plugin.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
Object expResult = null;
Object result = instance.executePluginNow(graph, plugin, parameters, interactive);
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecuteEditPluginNowThrowsInterruptedException.
@Test(expectedExceptions = InterruptedException.class)
public void testExecuteEditPluginNowThrowsInterruptedException() throws Exception {
System.out.println("executeEditPluginNow");
GraphWriteMethods graph = mock(GraphWriteMethods.class);
Plugin plugin = mock(Plugin.class);
InterruptedException interruptedException = mock(InterruptedException.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
doThrow(interruptedException).when(plugin).run(any(GraphWriteMethods.class), any(PluginInteraction.class), any(PluginParameters.class));
DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
Object expResult = null;
Object result = instance.executeEditPluginNow(graph, plugin, parameters, interactive);
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecutePluginLaterWithAsyncThrowsExecutionException.
@Test
public void testExecutePluginLaterWithAsyncThrowsExecutionException() throws ExecutionException, InterruptedException {
System.out.println("executePluginLater");
Graph graph = mock(Graph.class);
Plugin plugin = mock(Plugin.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
PluginSynchronizer synchronizer = mock(PluginSynchronizer.class);
Future<Object> mockedFuture = mock(Future.class);
List<Future<?>> async = Arrays.asList(mockedFuture);
when(mockedFuture.get()).thenThrow(ExecutionException.class);
final ExecutorService executorService = mock(ExecutorService.class);
DefaultPluginEnvironment instance = spy(new DefaultPluginEnvironment());
doReturn(executorService).when(instance).getPluginExecutor();
when(executorService.submit(any(Callable.class))).thenAnswer(iom -> {
final Callable callable = iom.getArgument(0);
callable.call();
return CompletableFuture.completedFuture(null);
});
Object expResult = null;
Future future = instance.executePluginLater(graph, plugin, parameters, interactive, async, synchronizer);
Object result = future.get();
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecuteReadPluginNow.
/**
* Test of executeReadPluginNow method, of class DefaultPluginEnvironment.
*/
@Test
public void testExecuteReadPluginNow() throws Exception {
System.out.println("executeReadPluginNow");
GraphReadMethods graph = mock(GraphReadMethods.class);
Plugin plugin = mock(Plugin.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
Object expResult = null;
Object result = instance.executeReadPluginNow(graph, plugin, parameters, interactive);
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecuteReadPluginNowThrowsPluginException.
@Test(expectedExceptions = PluginException.class)
public void testExecuteReadPluginNowThrowsPluginException() throws Exception {
System.out.println("executeReadPluginNow");
GraphReadMethods graph = mock(GraphReadMethods.class);
Plugin plugin = mock(Plugin.class);
PluginParameters parameters = mock(PluginParameters.class);
PluginException pluginException = mock(PluginException.class);
boolean interactive = false;
DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
doThrow(pluginException).when(plugin).run(any(GraphReadMethods.class), any(PluginInteraction.class), any(PluginParameters.class));
when(pluginException.getNotificationLevel()).thenReturn(PluginNotificationLevel.FATAL);
instance.executeReadPluginNow(graph, plugin, parameters, interactive);
}
Aggregations