use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class ActiveOptionsInitTest method testNoParameters.
@Test
public void testNoParameters() throws Exception {
Command completeCommand = mock(Command.class);
options.init(mock(PlaceRequest.class), completeCommand);
assertFalse(options.getOptions().isEmpty());
assertTrue(options.isBusinessViewActive());
assertTrue(options.isBreadCrumbNavigationVisible());
assertFalse(options.areHiddenFilesVisible());
verify(completeCommand).execute();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class BuildExecutorTest method testBuildNotManagedRepositoryClashingGAV.
@Test
@SuppressWarnings("unchecked")
public void testBuildNotManagedRepositoryClashingGAV() throws Exception {
final Map<String, Object> env = new HashMap<String, Object>() {
{
put("managed", false);
}
};
when(repository.getEnvironment()).thenReturn(env);
doThrow(GAVAlreadyExistsException.class).when(buildServiceMock).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED));
final GAV gav = module.getPom().getGav();
final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
buildExecutor.triggerBuildAndDeploy();
verify(buildServiceMock, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED));
verify(conflictingRepositoriesPopup, times(1)).setContent(eq(gav), any(Set.class), commandArgumentCaptor.capture());
verify(conflictingRepositoriesPopup, times(1)).show();
assertNotNull(commandArgumentCaptor.getValue());
// Emulate User electing to force save
commandArgumentCaptor.getValue().execute();
verify(conflictingRepositoriesPopup, times(1)).hide();
verify(buildServiceMock, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.FORCED));
verify(view, times(2)).showBusyIndicator(eq(ProjectEditorResources.CONSTANTS.Building()));
verify(view, times(2)).hideBusyIndicator();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewWorkspaceProjectHandlerTest method testGetCommandWithActiveRepository.
@Test
public void testGetCommandWithActiveRepository() {
final LibraryOrganizationalUnitPreferences libraryOrganizationalUnitPreferences = mock(LibraryOrganizationalUnitPreferences.class);
when(libraryOrganizationalUnitPreferences.getName()).thenReturn("myOU");
when(libraryPreferences.getOrganizationalUnitPreferences()).thenReturn(libraryOrganizationalUnitPreferences);
when(context.getActiveWorkspaceProject()).thenReturn(Optional.of(new WorkspaceProject(mock(OrganizationalUnit.class), repository, mock(Branch.class), mock(Module.class))));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
when(organizationalUnit.getDefaultGroupId()).thenReturn("defaultGroupId");
when(organizationalUnitService.getOrganizationalUnit("myOU")).thenReturn(organizationalUnit);
doAnswer(new Answer() {
@Override
public Void answer(InvocationOnMock invocationOnMock) throws Throwable {
when(context.getActiveOrganizationalUnit()).thenReturn(Optional.of(organizationalUnit));
return null;
}
}).when(projectContextChangeEvent).fire(any(WorkspaceProjectContextChangeEvent.class));
final Command command = handler.getCommand(newResourcePresenter);
assertNotNull(command);
command.execute();
ArgumentCaptor<POM> pomArgumentCaptor = ArgumentCaptor.forClass(POM.class);
verify(wizard, times(1)).initialise(pomArgumentCaptor.capture());
verify(wizard, times(1)).start(any(org.uberfire.client.callbacks.Callback.class), anyBoolean());
assertEquals("defaultGroupId", pomArgumentCaptor.getValue().getGav().getGroupId());
assertEquals("kjar", pomArgumentCaptor.getValue().getPackaging());
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class NewWorkspaceProjectWizardTest method testCompleteClashingGAV.
@Test
@SuppressWarnings("unchecked")
public void testCompleteClashingGAV() throws Exception {
final Path repositoryRoot = mock(Path.class);
final POM pom = mock(POM.class);
final GAV gav = mock(GAV.class);
when(projectService.newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.VALIDATED))).thenThrow(GAVAlreadyExistsException.class);
when(moduleContext.getActiveOrganizationalUnit()).thenReturn(Optional.of(mock(OrganizationalUnit.class)));
when(moduleContext.getActiveRepositoryRoot()).thenReturn(Optional.of(repositoryRoot));
when(pomWizardPage.getPom()).thenReturn(pom);
when(pom.getGav()).thenReturn(gav);
final ArgumentCaptor<Command> commandArgumentCaptor = ArgumentCaptor.forClass(Command.class);
wizard.complete();
verify(projectService, timeout(1)).newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.VALIDATED));
verify(busyIndicatorView, times(1)).showBusyIndicator(any(String.class));
verify(busyIndicatorView, times(1)).hideBusyIndicator();
verify(conflictingRepositoriesPopup, times(1)).setContent(eq(gav), any(Set.class), commandArgumentCaptor.capture());
verify(conflictingRepositoriesPopup, times(1)).show();
assertNotNull(commandArgumentCaptor.getValue());
// Emulate User electing to force save
commandArgumentCaptor.getValue().execute();
verify(conflictingRepositoriesPopup, times(1)).hide();
verify(projectService, times(1)).newProject(any(OrganizationalUnit.class), eq(pom), eq(DeploymentMode.FORCED));
verify(busyIndicatorView, times(2)).showBusyIndicator(any(String.class));
verify(busyIndicatorView, times(2)).hideBusyIndicator();
}
use of org.uberfire.mvp.Command in project kie-wb-common by kiegroup.
the class DataSourceDefEditorHelperTest method setup.
@Before
public void setup() {
clientValidationService = new ClientValidationServiceMock();
editorServiceCaller = new CallerMock<>(editorService);
queryServiceCaller = new CallerMock<>(queryService);
when(driverDefInfo.getUuid()).thenReturn(DRIVER_UUID);
when(driverDefInfo.getName()).thenReturn("DriverName");
List<DriverDefInfo> drivers = new ArrayList<>();
drivers.add(driverDefInfo);
when(queryService.findGlobalDrivers()).thenReturn(drivers);
when(queryService.findModuleDrivers(any(Path.class))).thenReturn(drivers);
editorHelper = new DataSourceDefEditorHelper(translationService, editorServiceCaller, queryServiceCaller, clientValidationService, popupsUtil);
editorHelper.setHandler(handler);
editorHelper.init(mainPanel);
editorHelper.loadDrivers(new Command() {
@Override
public void execute() {
// do nothing
}
}, new ParameterizedCommand<Throwable>() {
@Override
public void execute(Throwable parameter) {
// do nothing
}
});
dataSourceDef = new DataSourceDef();
editorHelper.setDataSourceDef(dataSourceDef);
verify(mainPanel, times(1)).clear();
verify(mainPanel, times(1)).setName(dataSourceDef.getName());
verify(mainPanel, times(1)).setConnectionURL(dataSourceDef.getConnectionURL());
verify(mainPanel, times(1)).setUser(dataSourceDef.getUser());
verify(mainPanel, times(1)).setPassword(dataSourceDef.getPassword());
verify(mainPanel, times(1)).setDriver(dataSourceDef.getDriverUuid());
}
Aggregations