Search in sources :

Example 1 with ManagedInstance

use of org.jboss.errai.ioc.client.api.ManagedInstance in project kie-wb-common by kiegroup.

the class InstanceUtilsTest method testDestroy.

@Test
public void testDestroy() {
    final ManagedInstance managedInstance = mock(ManagedInstance.class);
    final Object control = mock(Object.class);
    final Consumer<Object> consumer = mock(Consumer.class);
    InstanceUtils.destroy(managedInstance, control, consumer);
    verify(consumer, times(1)).accept(eq(control));
    verify(managedInstance, times(1)).destroy(eq(control));
}
Also used : ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Test(org.junit.Test)

Example 2 with ManagedInstance

use of org.jboss.errai.ioc.client.api.ManagedInstance in project kie-wb-common by kiegroup.

the class ManagedClientSessionCommandsTest method testDestroyCommands.

@Test
public void testDestroyCommands() {
    final ClientSession clientSession = mock(ClientSession.class);
    final CanvasHandler canvasHandler = mock(CanvasHandler.class);
    final Diagram diagram = mock(Diagram.class);
    final Metadata metadata = mock(Metadata.class);
    final String definitionSetId = "definitionSetId";
    when(clientSession.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getDefinitionSetId()).thenReturn(definitionSetId);
    final Annotation qualifier = mock(Annotation.class);
    when(definitionUtils.getQualifier(eq(definitionSetId))).thenReturn(qualifier);
    final ManagedInstance managedInstance = mock(ManagedInstance.class);
    final ClientSessionCommand clientSessionCommand = mock(ClientSessionCommand.class);
    when(sessionCommands.select(eq(MockClientSessionCommand.class), eq(qualifier))).thenReturn(managedInstance);
    when(managedInstance.get()).thenReturn(clientSessionCommand);
    tested.register(MockClientSessionCommand.class);
    tested.bind(clientSession);
    tested.clearCommands();
    verify(clientSessionCommand, times(1)).destroy();
    verify(sessionCommands, times(1)).destroy(eq(clientSessionCommand));
}
Also used : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Annotation(java.lang.annotation.Annotation) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 3 with ManagedInstance

use of org.jboss.errai.ioc.client.api.ManagedInstance in project kie-wb-common by kiegroup.

the class FormsContainerTest method testGetDisplayer.

@Test
public void testGetDisplayer() {
    FormDisplayer formDisplayer1 = mock(FormDisplayer.class);
    FormDisplayer formDisplayer2 = mock(FormDisplayer.class);
    ManagedInstance managedInstance = mock(ManagedInstance.class);
    when(managedInstance.get()).thenReturn(formDisplayer2);
    FormsContainerView formsContainerView = mock(FormsContainerView.class);
    FormsContainer formsContainer = new FormsContainer(formsContainerView, managedInstance, null);
    formsContainer.formDisplayers.put(new FormDisplayerKey(GRAPH_UUID, FIRST_ELEMENT_UUID), formDisplayer1);
    FormDisplayer result1 = formsContainer.getDisplayer(GRAPH_UUID, FIRST_ELEMENT_UUID);
    FormDisplayer result2 = formsContainer.getDisplayer(GRAPH_UUID, SECOND_ELEMENT_UUID);
    assertEquals(formDisplayer1, result1);
    assertEquals(formDisplayer2, result2);
}
Also used : FormDisplayer(org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) Test(org.junit.Test)

Aggregations

ManagedInstance (org.jboss.errai.ioc.client.api.ManagedInstance)3 Test (org.junit.Test)3 Annotation (java.lang.annotation.Annotation)1 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)1 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 FormDisplayer (org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer)1