use of org.eclipse.che.api.machine.shared.dto.CommandDto in project che by eclipse.
the class DefaultWorkspaceValidatorTest method createConfig.
private static WorkspaceConfigDto createConfig() {
final WorkspaceConfigDto workspaceConfigDto = newDto(WorkspaceConfigDto.class).withName("ws-name").withDefaultEnv("dev-env");
ExtendedMachineDto extendedMachine = newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent")).withServers(singletonMap("ref1", newDto(ServerConf2Dto.class).withPort("8080/tcp").withProtocol("https").withProperties(singletonMap("some", "prop")))).withAttributes(singletonMap("memoryLimitBytes", "1000000"));
EnvironmentDto env = newDto(EnvironmentDto.class).withMachines(singletonMap("devmachine1", extendedMachine)).withRecipe(newDto(EnvironmentRecipeDto.class).withType("type").withContent("content").withContentType("content type"));
workspaceConfigDto.setEnvironments(singletonMap("dev-env", env));
List<CommandDto> commandDtos = new ArrayList<>();
commandDtos.add(newDto(CommandDto.class).withName("command_name").withType("maven").withCommandLine("mvn clean install").withAttributes(new HashMap<>(singletonMap("cmd-attribute-name", "cmd-attribute-value"))));
workspaceConfigDto.setCommands(commandDtos);
return workspaceConfigDto;
}
use of org.eclipse.che.api.machine.shared.dto.CommandDto in project che by eclipse.
the class WorkspaceServiceTest method shouldAddCommand.
@Test
public void shouldAddCommand() throws Exception {
final WorkspaceImpl workspace = createWorkspace(createConfigDto());
when(wsManager.getWorkspace(workspace.getId())).thenReturn(workspace);
when(wsManager.updateWorkspace(any(), any())).thenReturn(workspace);
final CommandDto commandDto = createCommandDto();
final int commandsSizeBefore = workspace.getConfig().getCommands().size();
final Response response = given().auth().basic(ADMIN_USER_NAME, ADMIN_USER_PASSWORD).contentType("application/json").body(commandDto).when().post(SECURE_PATH + "/workspace/" + workspace.getId() + "/command");
assertEquals(response.getStatusCode(), 200);
assertEquals(new WorkspaceImpl(unwrapDto(response, WorkspaceDto.class), TEST_ACCOUNT).getConfig().getCommands().size(), commandsSizeBefore + 1);
verify(validator).validateConfig(workspace.getConfig());
verify(wsManager).updateWorkspace(any(), any());
}
Aggregations