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));
}
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));
}
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);
}
Aggregations