Search in sources :

Example 11 with Plugin

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);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 12 with Plugin

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);
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 13 with Plugin

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);
}
Also used : PluginSynchronizer(au.gov.asd.tac.constellation.plugins.PluginSynchronizer) Graph(au.gov.asd.tac.constellation.graph.Graph) ExecutorService(java.util.concurrent.ExecutorService) CompletableFuture(java.util.concurrent.CompletableFuture) Future(java.util.concurrent.Future) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Callable(java.util.concurrent.Callable) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 14 with Plugin

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);
}
Also used : GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 15 with Plugin

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);
}
Also used : GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Aggregations

Plugin (au.gov.asd.tac.constellation.plugins.Plugin)85 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)52 Test (org.testng.annotations.Test)43 Graph (au.gov.asd.tac.constellation.graph.Graph)24 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)19 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)14 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)10 PluginSynchronizer (au.gov.asd.tac.constellation.plugins.PluginSynchronizer)9 Future (java.util.concurrent.Future)9 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)8 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)8 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)8 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)8 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 ExecutorService (java.util.concurrent.ExecutorService)7 ArrayList (java.util.ArrayList)6 Callable (java.util.concurrent.Callable)6 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5