use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewFileUploaderTest method testCreateFailure.
@Test
public void testCreateFailure() {
final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
uploader.create(pkg, "file", presenter);
verify(moduleService, times(1)).resolveDefaultPath(pkg, "txt");
verify(busyIndicatorView, times(1)).showBusyIndicator(any(String.class));
verify(options, times(1)).upload(any(Command.class), commandArgumentCaptor.capture());
// Emulate a successful upload
final Command command = commandArgumentCaptor.getValue();
assertNotNull(command);
command.execute();
verify(busyIndicatorView, times(1)).hideBusyIndicator();
verify(presenter, never()).complete();
verify(placeManager, never()).goTo(any(Path.class));
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewFileUploaderTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
final ArgumentCaptor<Path> pathArgumentCaptor = ArgumentCaptor.forClass(Path.class);
final ArgumentCaptor<NewResourceSuccessEvent> newResourceSuccessEventArgumentCaptor = ArgumentCaptor.forClass(NewResourceSuccessEvent.class);
uploader.create(pkg, "file", presenter);
verify(moduleService, times(1)).resolveDefaultPath(pkg, "txt");
verify(busyIndicatorView, times(1)).showBusyIndicator(any(String.class));
verify(options, times(1)).upload(commandArgumentCaptor.capture(), any(Command.class));
// Emulate a successful upload
final Command command = commandArgumentCaptor.getValue();
assertNotNull(command);
command.execute();
verify(busyIndicatorView, times(1)).hideBusyIndicator();
verify(presenter, times(1)).complete();
verify(newResourceSuccessEventMock, times(1)).fire(newResourceSuccessEventArgumentCaptor.capture());
verify(placeManager, times(1)).goTo(pathArgumentCaptor.capture());
// Check navigation
final Path routedPath = pathArgumentCaptor.getValue();
assertEquals("default://p0/src/main/resources/file.txt", routedPath.toURI());
final NewResourceSuccessEvent newResourceSuccessEvent = newResourceSuccessEventArgumentCaptor.getValue();
assertEquals("default://p0/src/main/resources/file.txt", newResourceSuccessEvent.getPath().toURI());
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ContainerCardPresenter method setup.
public void setup(final Container container) {
final LinkTitlePresenter linkTitlePresenter = presenterProvider.select(LinkTitlePresenter.class).get();
linkTitlePresenter.setup(container.getContainerName(), new Command() {
@Override
public void execute() {
containerSpecSelectedEvent.fire(new ContainerSpecSelected(buildContainerSpecKey(container)));
}
});
final InfoTitlePresenter infoTitlePresenter = presenterProvider.select(InfoTitlePresenter.class).get();
infoTitlePresenter.setup(container.getResolvedReleasedId());
final BodyPresenter bodyPresenter = presenterProvider.select(BodyPresenter.class).get();
bodyPresenter.setup(container.getMessages());
final FooterPresenter footerPresenter = presenterProvider.select(FooterPresenter.class).get();
footerPresenter.setup(container.getUrl(), container.getResolvedReleasedId().getVersion());
CardPresenter card = presenterProvider.select(CardPresenter.class).get();
card.addTitle(linkTitlePresenter);
card.addTitle(infoTitlePresenter);
card.addBody(bodyPresenter);
card.addFooter(footerPresenter);
view.setCard(card.getView());
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ServerTemplatePresenterTest method testRemoveTemplate.
@Test
public void testRemoveTemplate() {
when(view.getRemoveTemplateErrorMessage()).thenReturn("ERROR");
doAnswer(new Answer<Void>() {
@Override
public Void answer(final InvocationOnMock invocation) throws Throwable {
Command command = (Command) invocation.getArguments()[0];
if (command != null) {
command.execute();
}
return null;
}
}).when(view).confirmRemove(any(Command.class));
final ServerTemplate serverTemplate = new ServerTemplate("ServerTemplateKeyId", "ServerTemplateKeyName");
presenter.setup(serverTemplate, null);
presenter.removeTemplate();
verify(specManagementService).deleteServerTemplate(serverTemplate.getId());
verify(serverTemplateListRefreshEvent).fire(any(ServerTemplateListRefresh.class));
doThrow(new RuntimeException()).when(specManagementService).deleteServerTemplate(serverTemplate.getId());
presenter.removeTemplate();
verify(specManagementService, times(2)).deleteServerTemplate(serverTemplate.getId());
verify(serverTemplateListRefreshEvent, times(2)).fire(any(ServerTemplateListRefresh.class));
verify(notification).fire(new NotificationEvent("ERROR", NotificationEvent.NotificationType.ERROR));
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DefaultWorkbenchFeaturesMenusHelperTest method logoutCommandRedirectIncludesLocaleTest.
@Test
@SuppressWarnings("unchecked")
public void logoutCommandRedirectIncludesLocaleTest() throws Throwable {
final DefaultWorkbenchFeaturesMenusHelper.LogoutCommand logoutCommand = spy(menusHelper.new LogoutCommand() {
@Override
void doRedirect(final String url) {
// Do nothing
}
@Override
String getGWTModuleBaseURL() {
return "/gwtModule/";
}
@Override
String getGWTModuleName() {
return "gwtModule";
}
@Override
String getLocale() {
return "en_GB";
}
});
logoutCommand.execute();
final ArgumentCaptor<Command> postSaveStateCommandCaptor = ArgumentCaptor.forClass(Command.class);
final ArgumentCaptor<String> redirectURLCaptor = ArgumentCaptor.forClass(String.class);
verify(perspectiveManager).savePerspectiveState(postSaveStateCommandCaptor.capture());
final Command postSaveStateCommand = postSaveStateCommandCaptor.getValue();
postSaveStateCommand.execute();
verify(logoutCommand).getRedirectURL();
verify(logoutCommand).doRedirect(redirectURLCaptor.capture());
final String redirectURL = redirectURLCaptor.getValue();
assertTrue(redirectURL.contains("/logout.jsp?locale=en_GB"));
}
Aggregations