Search in sources :

Example 1 with RequestSessionRefreshEvent

use of org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent in project kie-wb-common by kiegroup.

the class ProfileSelectorTest method testBind.

@Test
public void testBind() {
    when(selector.getSelectedItem()).thenReturn(profile1);
    tested.bind(() -> session);
    verify(selector, times(1)).clear();
    verify(selector, times(1)).addItem(eq(profile1));
    ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
    verify(selector, times(1)).setValueChangedCommand(commandArgumentCaptor.capture());
    Command command = commandArgumentCaptor.getValue();
    command.execute();
    verify(metadata, times(1)).setProfileId(eq(PROFILE_ID));
    ArgumentCaptor<RequestSessionRefreshEvent> eventArgumentCaptor = ArgumentCaptor.forClass(RequestSessionRefreshEvent.class);
    verify(requestSessionRefreshEvent, times(1)).fire(eventArgumentCaptor.capture());
    RequestSessionRefreshEvent event = eventArgumentCaptor.getValue();
    assertEquals(SESSION_UUID, event.getSessionUUID());
}
Also used : Command(org.uberfire.mvp.Command) RequestSessionRefreshEvent(org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent) Test(org.junit.Test)

Example 2 with RequestSessionRefreshEvent

use of org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent in project kie-wb-common by kiegroup.

the class ProfileSelector method bind.

public ProfileSelector bind(final Supplier<AbstractSession> sessionSupplier) {
    final AbstractSession session = sessionSupplier.get();
    final Metadata metadata = session.getCanvasHandler().getDiagram().getMetadata();
    final String definitionSetId = metadata.getDefinitionSetId();
    final String profileId = metadata.getProfileId();
    useDefinitionSet(definitionSetId);
    useProfile(definitionSetId, profileId);
    selector.setValueChangedCommand(() -> {
        final Profile item = selector.getSelectedItem();
        metadata.setProfileId(item.getProfileId());
        requestSessionRefreshEvent.fire(new RequestSessionRefreshEvent(session.getSessionUUID()));
    });
    return this;
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Profile(org.kie.workbench.common.stunner.core.profile.Profile) RequestSessionRefreshEvent(org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent) AbstractSession(org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)

Aggregations

RequestSessionRefreshEvent (org.kie.workbench.common.stunner.client.widgets.presenters.session.RequestSessionRefreshEvent)2 Test (org.junit.Test)1 AbstractSession (org.kie.workbench.common.stunner.core.client.session.impl.AbstractSession)1 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)1 Profile (org.kie.workbench.common.stunner.core.profile.Profile)1 Command (org.uberfire.mvp.Command)1