org.springframework.shell.table.Table Java Examples

The following examples show how to use org.springframework.shell.table.Table. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
public void testViewInstance() {
	logger.info("Retrieve Job Instance Detail by Id");

	Table table = getTable(job().instanceDisplay(jobInstances.get(0).getInstanceId()));
	verifyColumnNumber(table, 5);
	checkCell(table, 0, 0, "Name ");
	checkCell(table, 0, 1, "Execution ID ");
	checkCell(table, 0, 2, "Step Execution Count ");
	checkCell(table, 0, 3, "Status ");
	checkCell(table, 0, 4, "Job Parameters ");
	boolean isValidCell = false;
	if (table.getModel().getValue(1, 4).equals("foo=FOO,-bar=BAR")
			|| table.getModel().getValue(1, 4).equals("-bar=BAR,foo=FOO")) {
		isValidCell = true;
	}
	assertTrue("Job Parameters does match expected.", isValidCell);
}
 
Example #2
Source File: StreamCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
/**
 * Verify the stream is listed in stream list.
 *
 * @param streamName the name of the stream
 * @param definition definition of the stream
 */
public void verifyExists(String streamName, String definition, boolean deployed) {
	CommandResult cr = shell.executeCommand("stream list");
	assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());

	Table table = (org.springframework.shell.table.Table) cr.getResult();
	TableModel model = table.getModel();
	Collection<String> statuses = deployed
			? Arrays.asList(DeploymentStateResource.DEPLOYED.getDescription(),
			DeploymentStateResource.DEPLOYING.getDescription())
			: Arrays.asList(DeploymentStateResource.UNDEPLOYED.getDescription());
	for (int row = 0; row < model.getRowCount(); row++) {
		if (streamName.equals(model.getValue(row, 0))
				&& definition.replace("\\\\", "\\").equals(model.getValue(row, 2))) {
			// TODO (Tzolov) CLASSIC-MODE-REMOVAL To compute an aggregated state the Info returned by the mocked
			// TODO SkipperClient.info() (in SkipperStreamDeployer#getStreamDeploymentState) must have a
			// TODO valid PlatformStatus
			// && statuses.contains(model.getValue(row, 2))) {
			return;
		}
	}
	fail("Stream named " + streamName + " does not exist");

}
 
Example #3
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskExecutionList() {
	logger.info("Retrieve Task Execution List Test");
	CommandResult cr = task().taskExecutionList();
	assertTrue("task execution list command must be successful", cr.isSuccess());
	Table table = (Table) cr.getResult();
	assertEquals("Number of columns returned was not expected", 5, table.getModel().getColumnCount());
	verifyTableValue(table, 0, 0, "Task Name");
	verifyTableValue(table, 0, 1, "ID");
	verifyTableValue(table, 0, 2, "Start Time");
	verifyTableValue(table, 0, 3, "End Time");
	verifyTableValue(table, 0, 4, "Exit Code");

	verifyTableValue(table, 1, 0, TASK_NAME);
	verifyTableValue(table, 1, 1, TASK_EXECUTION_ID);
	verifyTableValue(table, 1, 2, startTime);
	verifyTableValue(table, 1, 3, endTime);
	verifyTableValue(table, 1, 4, EXIT_CODE);
}
 
Example #4
Source File: ConfigCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@Test
public void testInfo() throws IOException {
	if (!isWindows()) {
		DataFlowOperations dataFlowOperations = mock(DataFlowOperations.class);
		AboutOperations aboutOperations = mock(AboutOperations.class);
		when(dataFlowOperations.aboutOperation()).thenReturn(aboutOperations);
		AboutResource aboutResource = new AboutResource();
		when(aboutOperations.get()).thenReturn(aboutResource);
		dataFlowShell.setDataFlowOperations(dataFlowOperations);

		aboutResource.getFeatureInfo().setTasksEnabled(false);
		aboutResource.getVersionInfo().getCore().setName("Foo Core");
		aboutResource.getVersionInfo().getCore().setVersion("1.2.3.BUILD-SNAPSHOT");
		aboutResource.getSecurityInfo().setAuthenticationEnabled(true);
		aboutResource.getRuntimeEnvironment().getAppDeployer().setJavaVersion("1.8");
		aboutResource.getRuntimeEnvironment().getAppDeployer().getPlatformSpecificInfo().put("Some", "Stuff");
		List<RuntimeEnvironmentDetails> taskLaunchers = new ArrayList<>();
		taskLaunchers.add(new RuntimeEnvironmentDetails());
		aboutResource.getRuntimeEnvironment().setTaskLaunchers(taskLaunchers);
		aboutResource.getRuntimeEnvironment().getTaskLaunchers().get(0).setDeployerSpiVersion("6.4");
		final Table infoResult = (Table) configCommands.info().get(0);
		String expectedOutput = FileCopyUtils.copyToString(new InputStreamReader(
				getClass().getResourceAsStream(ConfigCommandTests.class.getSimpleName() + "-testInfo.txt"), "UTF-8"));
		assertThat(infoResult.render(80), is(expectedOutput));
	}
}
 
Example #5
Source File: TaskSchedulerCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = SCHEDULER_LIST, help = "List task schedules by task definition name")
public Table listByDefinition(
		@CliOption(key = { "platform" }, help = "the name platform from which to retrieve a list of schedules") String platform,
		@CliOption(key = { "definitionName" }, help = "the task definition name") String definitionName) {
	PagedModel<ScheduleInfoResource> schedules;
	if (Strings.isEmpty(definitionName)) {
		schedules = scheduleOperations().listByPlatform(platform);
	}
	else {
		schedules = scheduleOperations().list(definitionName, platform);
	}

	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("scheduleName", "Schedule Name");
	headers.put("taskDefinitionName", "Task Definition Name");
	headers.put("scheduleProperties", "Properties");
	final TableBuilder builder = new TableBuilder(new BeanListTableModel<>(schedules, headers));
	return DataFlowTables.applyStyle(builder).build();
}
 
Example #6
Source File: JobCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = STEP_EXECUTION_PROGRESS, help = "Display the details of a specific step progress")
public Table stepProgressDisplay(
		@CliOption(key = { "id" }, help = "the step execution id", mandatory = true) long id, @CliOption(key = {
				"jobExecutionId" }, help = "the job execution id", mandatory = true) long jobExecutionId) {

	StepExecutionProgressInfoResource progressInfoResource = jobOperations().stepExecutionProgress(jobExecutionId,
			id);

	TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();
	modelBuilder.addRow().addValue("ID ").addValue("Step Name ").addValue("Complete ").addValue("Duration ");

	modelBuilder.addRow().addValue(progressInfoResource.getStepExecution().getId())
			.addValue(progressInfoResource.getStepExecution().getStepName())
			.addValue(progressInfoResource.getPercentageComplete() * 100 + "%")
			.addValue(progressInfoResource.getDuration() + " ms");

	TableBuilder builder = new TableBuilder(modelBuilder.build());
	DataFlowTables.applyStyle(builder);

	return builder.build();
}
 
Example #7
Source File: JobCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = STEP_EXECUTION_LIST, help = "List step executions filtered by jobExecutionId")
public Table stepExecutionList(@CliOption(key = {
		"id" }, help = "the job execution id to be used as a filter", mandatory = true) long id) {

	final PagedModel<StepExecutionResource> steps = jobOperations().stepExecutionList(id);

	TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();

	modelBuilder.addRow().addValue("ID ").addValue("Step Name ").addValue("Job Exec Id ").addValue("Start Time ")
			.addValue("End Time ").addValue("Status ");
	for (StepExecutionResource step : steps) {
		modelBuilder.addRow().addValue(step.getStepExecution().getId())
				.addValue(step.getStepExecution().getStepName()).addValue(id)
				.addValue(step.getStepExecution().getStartTime()).addValue(step.getStepExecution().getEndTime())
				.addValue(step.getStepExecution().getStatus().name());
	}
	TableBuilder builder = new TableBuilder(modelBuilder.build());

	DataFlowTables.applyStyle(builder);

	return builder.build();
}
 
Example #8
Source File: JobCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = INSTANCE_DISPLAY, help = "Display the job executions for a specific job instance.")
public Table instanceDisplay(@CliOption(key = { "id" }, help = "the job instance id", mandatory = true) long id) {

	JobInstanceResource jobInstanceResource = jobOperations().jobInstance(id);

	TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();
	modelBuilder.addRow().addValue("Name ").addValue("Execution ID ").addValue("Step Execution Count ")
			.addValue("Status ").addValue("Job Parameters ");
	for (JobExecutionResource job : jobInstanceResource.getJobExecutions()) {
		modelBuilder.addRow().addValue(jobInstanceResource.getJobName()).addValue(job.getExecutionId())
				.addValue(job.getStepExecutionCount()).addValue(job.getJobExecution().getStatus().name())
				.addValue(job.getJobParametersString());
	}
	TableBuilder builder = new TableBuilder(modelBuilder.build());
	DataFlowTables.applyStyle(builder);

	return builder.build();
}
 
Example #9
Source File: StreamCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = STREAM_HISTORY, help = "Get history for the stream deployed using Skipper")
public Table history(
		@CliOption(key = { "",
				"name" }, help = "the name of the stream", mandatory = true, optionContext = "existing-stream "
				+ "disable-string-converter") String name) {
	Collection<Release> releases = streamOperations().history(name);
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("version", "Version");
	headers.put("info.lastDeployed", "Last updated");
	headers.put("info.status.statusCode", "Status");
	headers.put("pkg.metadata.name", "Package Name");
	headers.put("pkg.metadata.version", "Package Version");
	headers.put("info.description", "Description");
	TableModel model = new BeanListTableModel<>(releases, headers);
	TableBuilder tableBuilder = new TableBuilder(model);
	DataFlowTables.applyStyle(tableBuilder);
	return tableBuilder.build();
}
 
Example #10
Source File: TaskCommands.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
@CliCommand(value = EXECUTION_LIST, help = "List created task executions filtered by taskName")
public Table executionListByName(
		@CliOption(key = "name", help = "the task name to be used as a filter", optionContext = "existing-task disable-string-converter") String name) {

	final PagedModel<TaskExecutionResource> tasks;
	if (name == null) {
		tasks = taskOperations().executionList();
	}
	else {
		tasks = taskOperations().executionListByTaskName(name);
	}
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("taskName", "Task Name");
	headers.put("executionId", "ID");
	headers.put("startTime", "Start Time");
	headers.put("endTime", "End Time");
	headers.put("exitCode", "Exit Code");
	final TableBuilder builder = new TableBuilder(new BeanListTableModel<>(tasks, headers));
	return DataFlowTables.applyStyle(builder).build();
}
 
Example #11
Source File: ReleaseCommands.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@ShellMethod(key = "release list", value = "List the latest version of releases with status of deployed or failed.")
public Table list(
		@ShellOption(help = "wildcard expression to search by release name", defaultValue = ShellOption.NULL) String releaseName) {
	List<Release> releases = this.skipperClient.list(releaseName);
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("name", "Name");
	headers.put("version", "Version");
	headers.put("info.lastDeployed", "Last updated");
	headers.put("info.status.statusCode", "Status");
	headers.put("pkg.metadata.name", "Package Name");
	headers.put("pkg.metadata.version", "Package Version");
	headers.put("platformName", "Platform Name");
	headers.put("info.status.platformStatusPrettyPrint", "Platform Status");
	TableModel model = new BeanListTableModel<>(releases, headers);
	TableBuilder tableBuilder = new TableBuilder(model);
	TableUtils.applyStyle(tableBuilder);
	return tableBuilder.build();
}
 
Example #12
Source File: ReleaseCommands.java    From spring-cloud-skipper with Apache License 2.0 6 votes vote down vote up
@ShellMethod(key = "release history", value = "List the history of versions for a given release.")
public Table history(
		@ShellOption(help = "wildcard expression to search by release name") @NotNull String releaseName) {
	Collection<Release> releases;
	releases = this.skipperClient.history(releaseName);
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("version", "Version");
	headers.put("info.lastDeployed", "Last updated");
	headers.put("info.status.statusCode", "Status");
	headers.put("pkg.metadata.name", "Package Name");
	headers.put("pkg.metadata.version", "Package Version");
	headers.put("info.description", "Description");
	TableModel model = new BeanListTableModel<>(releases, headers);
	TableBuilder tableBuilder = new TableBuilder(model);
	TableUtils.applyStyle(tableBuilder);
	return tableBuilder.build();
}
 
Example #13
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testStepExecutionView() {
	logger.info("Retrieve Job Execution Detail by Id");

	long jobExecutionId = getFirstJobExecutionIdFromTable();
	long stepExecutionId = getFirstStepExecutionIdFromJobExecution(jobExecutionId);

	Table table = getTable(job().jobStepExecutionDisplay(stepExecutionId, jobExecutionId));

	verifyColumnNumber(table, 2);
	checkCell(table, 0, 0, "Key ");
	checkCell(table, 1, 0, "Step Execution Id ");
	checkCell(table, 2, 0, "Job Execution Id ");
	checkCell(table, 3, 0, "Step Name ");
	checkCell(table, 4, 0, "Start Time ");
	checkCell(table, 5, 0, "End Time ");
	checkCell(table, 6, 0, "Duration ");
	checkCell(table, 7, 0, "Status ");
	checkCell(table, 8, 0, "Last Updated ");
	checkCell(table, 9, 0, "Read Count ");
	checkCell(table, 10, 0, "Write Count ");
	checkCell(table, 11, 0, "Filter Count ");
	checkCell(table, 12, 0, "Read Skip Count ");
	checkCell(table, 13, 0, "Write Skip Count ");
	checkCell(table, 14, 0, "Process Skip Count ");
	checkCell(table, 15, 0, "Read Skip Count ");
	checkCell(table, 16, 0, "Commit Count ");
	checkCell(table, 17, 0, "Rollback Count ");
	checkCell(table, 18, 0, "Exit Status ");
	checkCell(table, 19, 0, "Exit Description ");

}
 
Example #14
Source File: TaskCommands.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@CliCommand(value = TASK_EXECUTION_STATUS, help = "Display the details of a specific task execution")
public Table display(@CliOption(key = { "", "id" }, help = "the task execution id", mandatory = true) long id) {

	TaskExecutionResource taskExecutionResource = taskOperations().taskExecutionStatus(id);

	TableModelBuilder<Object> modelBuilder = new TableModelBuilder<>();

	modelBuilder.addRow().addValue("Key ").addValue("Value ");
	modelBuilder.addRow().addValue("Id ").addValue(taskExecutionResource.getExecutionId());
	modelBuilder.addRow().addValue("Resource URL ").addValue(taskExecutionResource.getResourceUrl());
	modelBuilder.addRow().addValue("Name ").addValue(taskExecutionResource.getTaskName());
	modelBuilder.addRow().addValue("CLI Arguments ").addValue(taskExecutionResource.getArguments());
	modelBuilder.addRow().addValue("App Arguments ").addValue(taskExecutionResource.getAppProperties());
	modelBuilder.addRow().addValue("Deployment Properties ")
			.addValue(taskExecutionResource.getDeploymentProperties());
	modelBuilder.addRow().addValue("Job Execution Ids ").addValue(taskExecutionResource.getJobExecutionIds());
	modelBuilder.addRow().addValue("Start Time ").addValue(taskExecutionResource.getStartTime());
	modelBuilder.addRow().addValue("End Time ").addValue(taskExecutionResource.getEndTime());
	modelBuilder.addRow().addValue("Exit Code ").addValue(taskExecutionResource.getExitCode());
	modelBuilder.addRow().addValue("Exit Message ").addValue(taskExecutionResource.getExitMessage());
	modelBuilder.addRow().addValue("Error Message ").addValue(taskExecutionResource.getErrorMessage());
	modelBuilder.addRow().addValue("External Execution Id ")
			.addValue(taskExecutionResource.getExternalExecutionId());

	TableBuilder builder = new TableBuilder(modelBuilder.build());

	DataFlowTables.applyStyle(builder);

	return builder.build();
}
 
Example #15
Source File: PlatformCommands.java    From spring-cloud-skipper with Apache License 2.0 5 votes vote down vote up
@ShellMethod(key = "platform list", value = "List platforms")
public Table list() {
	Collection<Deployer> repositoryResources = this.skipperClient.listDeployers();
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("name", "Name");
	headers.put("type", "Type");
	headers.put("description", "Description");
	TableModel model = new BeanListTableModel<>(repositoryResources, headers);
	TableBuilder tableBuilder = new TableBuilder(model);
	return TableUtils.applyStyle(tableBuilder).build();
}
 
Example #16
Source File: TableMatcher.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public static DiagnosingMatcher<Table> hasRowThat(Matcher<?>... cells) {
	return new DiagnosingMatcher<Table>() {
		@Override
		protected boolean matches(Object item, Description mismatchDescription) {
			TableModel model = ((Table) item).getModel();
			outer: for (int row = 0; row < model.getRowCount(); row++) {
				mismatchDescription.appendText("\nRow " + row + ": ");
				for (int col = 0; col < cells.length; col++) {
					mismatchDescription.appendText("\n  Column " + col + ": ");
					cells[col].describeMismatch(model.getValue(row, col), mismatchDescription);
					if (!cells[col].matches(model.getValue(row, col))) {
						continue outer;
					}
				}
				return true;
			}
			return false;
		}

		@Override
		public void describeTo(Description description) {
			description.appendText("a table having at least one row that\n");
			for (int col = 0; col < cells.length; col++) {
				description.appendText("column " + col + ": ");
				cells[col].describeTo(description);
				description.appendText("\n");
			}
		}
	};
}
 
Example #17
Source File: TaskCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Launch a task and validate the result from shell.
 *
 * @param taskName the name of the task
 */
public long launch(String taskName) {
	// add the task name to the tasks list before assertion
	tasks.add(taskName);
	CommandResult cr = shell.executeCommand("task launch " + taskName);
	CommandResult idResult = shell.executeCommand("task execution list --name " + taskName);
	Table result = (Table) idResult.getResult();

	long value = (long) result.getModel().getValue(1, 1);
	assertTrue(cr.toString().contains("with execution id " + value));
	return value;
}
 
Example #18
Source File: TaskCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Launch a task and validate the result from shell.
 *
 * @param taskName the name of the task
 * @param ctrAppName the app to use when launching a ComposedTask if default is not wanted.
 */
public long launchWithAlternateCTR(String taskName, String ctrAppName) {
	// add the task name to the tasks list before assertion
	tasks.add(taskName);
	CommandResult cr = shell.executeCommand(String.format("task launch %s --composedTaskRunnerName %s", taskName, ctrAppName));
	CommandResult idResult = shell.executeCommand("task execution list --name " + taskName);
	Table result = (Table) idResult.getResult();

	long value = (long) result.getModel().getValue(1, 1);
	assertTrue(cr.toString().contains("with execution id " + value));
	return value;
}
 
Example #19
Source File: TaskCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private long launchTaskExecutionForLog(String taskName) throws Exception{
	// add the task name to the tasks list before assertion
	tasks.add(taskName);
	CommandResult cr = shell.executeCommand(String.format("task launch %s", taskName));
	CommandResult idResult = shell.executeCommand("task execution list --name " + taskName);
	Table taskExecutionResult = (Table) idResult.getResult();

	long id = (long) taskExecutionResult.getModel().getValue(1, 1);
	assertTrue(cr.toString().contains("with execution id " + id));
	waitForDBToBePopulated(id);
	return id;
}
 
Example #20
Source File: TaskCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
/**
 * Verify the task is listed in task list.
 *
 * @param taskName the name of the task
 * @param definition definition of the task
 */
public void verifyExists(String taskName, String definition) {
	CommandResult cr = shell.executeCommand("task list");
	assertTrue("Failure.  CommandResult = " + cr.toString(), cr.isSuccess());
	Table table = (Table) cr.getResult();
	TableModel model = table.getModel();
	for (int row = 0; row < model.getRowCount(); row++) {
		if (taskName.equals(model.getValue(row, 0))
				&& definition.replace("\\\\", "\\").equals(model.getValue(row, 1))) {
			return;
		}
	}
	fail("Task named " + taskName + " was not created");
}
 
Example #21
Source File: TaskScheduleCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public void list() {
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName("schedName");
	scheduleInfo.setTaskDefinitionName("testDefinition");
	scheduleInfo.setScheduleProperties(Collections.EMPTY_MAP);

	when(schedule.listForPlatform(null)).thenReturn(Arrays.asList(scheduleInfo));

	String wholeCommand = "task schedule list";
	CommandResult cr = dataFlowShell.executeCommand(wholeCommand);

	Table table = (Table) cr.getResult();
	assertEquals("schedName", table.getModel().getValue(1, 0));
}
 
Example #22
Source File: TaskScheduleCommandTemplate.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
public void listByTaskDefinition(String definitionName) {
	ScheduleInfo scheduleInfo = new ScheduleInfo();
	scheduleInfo.setScheduleName("schedName");
	scheduleInfo.setTaskDefinitionName("testDefinition");
	scheduleInfo.setScheduleProperties(Collections.EMPTY_MAP);

	when(schedule.list(definitionName, null)).thenReturn(Arrays.asList(scheduleInfo));

	String wholeCommand = String.format("task schedule list --definitionName %s", definitionName);
	CommandResult cr = dataFlowShell.executeCommand(wholeCommand);

	Table table = (Table) cr.getResult();
	assertEquals("schedName", table.getModel().getValue(1, 0));
}
 
Example #23
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskExecutionListByName() {
	logger.info("Retrieve Task Execution List By Name Test");
	task().create("mytask", "timestamp");
	CommandResult cr = task().taskExecutionListByName("mytask");
	assertTrue("task execution list by name command must be successful", cr.isSuccess());
	Table table = (Table) cr.getResult();
	assertEquals("Number of columns returned was not expected", 5, table.getModel().getColumnCount());

	verifyTableValue(table,0, 0, "Task Name");
	verifyTableValue(table,0, 1, "ID");
	verifyTableValue(table,0, 2, "Start Time");
	verifyTableValue(table,0, 3, "End Time");
	verifyTableValue(table,0, 4, "Exit Code");
}
 
Example #24
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testViewExecution() {
	logger.info("Retrieve Task Execution Status by Id");

	CommandResult idResult = task().taskExecutionList();
	Table result = (Table) idResult.getResult();
	long value = (long) result.getModel().getValue(findRowForExecutionId(result, TASK_EXECUTION_ID), 1);
	logger.info("Looking up id " + value);
	CommandResult cr = task().taskExecutionStatus(value);
	assertTrue("task execution status command must be successful", cr.isSuccess());
	Table table = (Table) cr.getResult();
	assertEquals("Number of columns returned was not expected", 2, table.getModel().getColumnCount());
	verifyTableValue(table, 0, 0, "Key ");
	verifyTableValue(table, 1, 0, "Id ");
	verifyTableValue(table, 2, 0, "Resource URL ");
	verifyTableValue(table, 3, 0, "Name ");
	verifyTableValue(table, 4, 0, "CLI Arguments ");
	verifyTableValue(table, 5, 0, "App Arguments ");
	verifyTableValue(table, 6, 0, "Deployment Properties ");
	verifyTableValue(table, 7, 0, "Job Execution Ids ");
	verifyTableValue(table, 8, 0, "Start Time ");
	verifyTableValue(table, 9, 0, "End Time ");
	verifyTableValue(table, 10, 0, "Exit Code ");
	verifyTableValue(table, 11, 0, "Exit Message ");
	verifyTableValue(table, 12, 0, "Error Message ");
	verifyTableValue(table, 13, 0, "External Execution Id ");

	verifyTableValue(table, 1, 1, TASK_EXECUTION_ID);
	verifyTableValue(table, 3, 1, TASK_NAME);
	verifyTableValue(table, 8, 1, startTime);
	verifyTableValue(table, 9, 1, endTime);
	verifyTableValue(table, 10, 1, EXIT_CODE);
	verifyTableValue(table, 11, 1, EXIT_MESSAGE);
	verifyTableValue(table, 12, 1, ERROR_MESSAGE);
	verifyTableValue(table, 13, 1, EXTERNAL_EXECUTION_ID);
}
 
Example #25
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testCurrentExecutions() {
	CommandResult cr = task().taskExecutionCurrent();
	Table table = (Table) cr.getResult();
	assertEquals("Number of columns returned was not expected", 4, table.getModel().getColumnCount());
	verifyTableValue(table, 0, 0, "Platform Name");
	verifyTableValue(table, 0, 1, "Platform Type");
	verifyTableValue(table, 0, 2, "Execution Count");
	verifyTableValue(table, 0, 3, "Maximum Executions");

	verifyTableValue(table, 1, 0, "default");
	verifyTableValue(table, 1, 1, "Local");
	verifyTableValue(table, 1, 3, 20);
}
 
Example #26
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testPlatformList() {
	CommandResult cr = task().taskPlatformList();
	Table table = (Table) cr.getResult();
	assertEquals("Number of columns returned was not expected", 3, table.getModel().getColumnCount());
	assertEquals("First Row First Value should be: Platform Name", "Platform Name", table.getModel().getValue(0, 0));
	assertEquals("First Row Second Value should be: Platform Type", "Platform Type", table.getModel().getValue(0, 1));
	assertEquals("First Row Second Value should be: Description", "Description", table.getModel().getValue(0, 2));
	assertEquals("Second Row First Value should be: default", "default", table.getModel().getValue(1, 0));
	assertEquals("Second Row Second Value should be: Local", "Local", table.getModel().getValue(1, 1));
}
 
Example #27
Source File: TaskCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
private int findRowForExecutionId(Table table, long id) {
	int result = -1;
	for(int rowNum = 0; rowNum < table.getModel().getRowCount(); rowNum++) {
		if(table.getModel().getValue(rowNum, 1).equals(id)) {
			result = rowNum;
			break;
		}
	}
	assertTrue("Task Execution Id specified was not found in execution list", id > -1);
	return result;
}
 
Example #28
Source File: JobCommandTests.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobStepExecutionList() {
	logger.info("Retrieve Job Step Execution List Test");

	Table table = getTable(job().jobStepExecutionList(getFirstJobExecutionIdFromTable()));
	verifyColumnNumber(table, 6);
	checkCell(table, 0, 0, "ID ");
	checkCell(table, 0, 1, "Step Name ");
	checkCell(table, 0, 2, "Job Exec Id ");
	checkCell(table, 0, 3, "Start Time ");
	checkCell(table, 0, 4, "End Time ");
	checkCell(table, 0, 5, "Status ");
}
 
Example #29
Source File: TaskCommands.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@CliCommand(value = PLATFORM_LIST, help = "List platform accounts for tasks")
public Table listPlatforms() {
	final PagedModel<LauncherResource> platforms = taskOperations().listPlatforms();
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("name", "Platform Name");
	headers.put("type", "Platform Type");
	headers.put("description", "Description");
	final TableBuilder builder = new TableBuilder(new BeanListTableModel<>(platforms, headers));
	return DataFlowTables.applyStyle(builder).build();
}
 
Example #30
Source File: TaskCommands.java    From spring-cloud-dataflow with Apache License 2.0 5 votes vote down vote up
@CliCommand(value = TASK_EXECUTION_CURRENT, help = "Display count of currently executin tasks and related information")
public Table currentExecutions() {
	Collection<CurrentTaskExecutionsResource> taskExecutionsResources = taskOperations().currentTaskExecutions();
	LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
	headers.put("name", "Platform Name");
	headers.put("type", "Platform Type");
	headers.put("runningExecutionCount", "Execution Count");
	headers.put("maximumTaskExecutions", "Maximum Executions");

	TableBuilder builder = new TableBuilder(new BeanListTableModel<>(taskExecutionsResources, headers));
	DataFlowTables.applyStyle(builder);
	return builder.build();
}