Search in sources :

Example 16 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultPluginEnvironmentNGTest method testExecuteReadPluginNowThrowsInterruptedException.

@Test(expectedExceptions = InterruptedException.class)
public void testExecuteReadPluginNowThrowsInterruptedException() throws Exception {
    System.out.println("executeReadPluginNow");
    GraphReadMethods graph = mock(GraphReadMethods.class);
    Plugin plugin = mock(Plugin.class);
    PluginParameters parameters = mock(PluginParameters.class);
    InterruptedException interruptedException = mock(InterruptedException.class);
    boolean interactive = false;
    DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
    doThrow(interruptedException).when(plugin).run(any(GraphReadMethods.class), any(PluginInteraction.class), any(PluginParameters.class));
    Object expResult = null;
    Object result = instance.executeReadPluginNow(graph, plugin, parameters, interactive);
    assertEquals(result, expResult);
}
Also used : GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) 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 17 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultPluginEnvironmentNGTest method testExecutePluginNow.

/**
 * Test of executePluginNow method, of class DefaultPluginEnvironment.
 */
@Test
public void testExecutePluginNow() throws Exception {
    System.out.println("executePluginNow");
    Graph graph = mock(Graph.class);
    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 18 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultPluginEnvironmentNGTest method testExecuteEditPluginNowThrowsRuntimeException.

@Test(expectedExceptions = RuntimeException.class)
public void testExecuteEditPluginNowThrowsRuntimeException() throws Exception {
    System.out.println("executeEditPluginNow");
    GraphWriteMethods graph = mock(GraphWriteMethods.class);
    Plugin plugin = mock(Plugin.class);
    RuntimeException runtimeException = mock(RuntimeException.class);
    PluginParameters parameters = mock(PluginParameters.class);
    boolean interactive = false;
    doThrow(runtimeException).when(plugin).run(any(GraphWriteMethods.class), any(PluginInteraction.class), any(PluginParameters.class));
    DefaultPluginEnvironment instance = new DefaultPluginEnvironment();
    instance.executeEditPluginNow(graph, plugin, parameters, interactive);
}
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 19 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultPluginEnvironmentNGTest method testExecutePluginLaterThrowsRuntimeException.

@Test
public void testExecutePluginLaterThrowsRuntimeException() throws ExecutionException, InterruptedException, PluginException {
    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);
    List<Future<?>> async = null;
    RuntimeException runtimeException = mock(RuntimeException.class);
    final ExecutorService executorService = mock(ExecutorService.class);
    doThrow(runtimeException).when(plugin).run(any(PluginGraphs.class), any(PluginInteraction.class), any(PluginParameters.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) PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) Callable(java.util.concurrent.Callable) Graph(au.gov.asd.tac.constellation.graph.Graph) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) ExecutorService(java.util.concurrent.ExecutorService) CompletableFuture(java.util.concurrent.CompletableFuture) Future(java.util.concurrent.Future) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 20 with Plugin

use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.

the class DefaultPluginEnvironmentNGTest method testExecuteEditPluginNow.

/**
 * Test of executeEditPluginNow method, of class DefaultPluginEnvironment.
 */
@Test
public void testExecuteEditPluginNow() throws Exception {
    System.out.println("executeEditPluginNow");
    GraphWriteMethods graph = mock(GraphWriteMethods.class);
    Plugin plugin = mock(Plugin.class);
    PluginParameters parameters = mock(PluginParameters.class);
    boolean interactive = false;
    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) 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