Skip to content

Commit d0fc313

Browse files
author
Corneil du Plessis
committed
Update Task Thin Executions list function for parity with 2.11.x
Updated task thin executions link handing and added extra test for parity with 2.11.x See spring-attic#6062
1 parent 54aca00 commit d0fc313

File tree

3 files changed

+11
-23
lines changed
  • spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation
  • spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client
  • spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller

3 files changed

+11
-23
lines changed

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/ApiDocumentation.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void index() throws Exception {
222222
fieldWithPath("_links.tasks/thinexecutions.href").description("Link to the tasks/thinexecutions"),
223223

224224
fieldWithPath("_links.tasks/thinexecutions/name.href").description("Link to the tasks/thinexecutions/name"),
225-
fieldWithPath("_links.tasks/thinexecutions/name.templated").description("Link to the tasks/thinexecutions/name is templated"),
225+
fieldWithPath("_links.tasks/thinexecutions/name.templated").type(JsonFieldType.BOOLEAN).optional().description("Link to the tasks/thinexecutions/name is templated"),
226226

227227
fieldWithPath("_links.tasks/info/executions.href").description("Link to the tasks/info/executions"),
228228
fieldWithPath("_links.tasks/info/executions.templated").type(JsonFieldType.BOOLEAN).optional().description("Link tasks/info is templated"),

spring-cloud-dataflow-rest-client/src/main/java/org/springframework/cloud/dataflow/rest/client/TaskTemplate.java

+4-22
Original file line numberDiff line numberDiff line change
@@ -146,35 +146,17 @@ public class TaskTemplate implements TaskOperations {
146146
if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, VALIDATION_RELATION_VERSION)) {
147147
Assert.notNull(resources.getLink(VALIDATION_REL), ()-> VALIDATION_REL + " relation is required");
148148
}
149-
if (VersionUtils.isDataFlowServerVersionGreaterThanOrEqualToRequiredVersion(version, EXECUTIONS_CURRENT_RELATION_VERSION)) {
150-
Assert.isTrue(resources.getLink(EXECUTIONS_CURRENT_RELATION).isPresent(), ()-> EXECUTIONS_CURRENT_RELATION + " relation is required");
151-
this.executionsCurrentLink = resources.getLink(EXECUTIONS_CURRENT_RELATION).get();
152-
} else {
153-
this.executionsCurrentLink = null;
154-
}
155149

156150
this.aboutLink = resources.getLink("about").get();
157151

158152
this.definitionsLink = resources.getLink(DEFINITIONS_RELATION).get();
159153
this.definitionLink = resources.getLink(DEFINITION_RELATION).get();
160154
this.executionsLink = resources.getLink(EXECUTIONS_RELATION).get();
161155
this.executionLink = resources.getLink(EXECUTION_RELATION).get();
162-
if(resources.getLink(THIN_EXECUTIONS_RELATION).isPresent()) {
163-
this.thinExecutionsLink = resources.getLink(THIN_EXECUTIONS_RELATION).get();
164-
} else {
165-
this.thinExecutionsLink = null;
166-
}
167-
if(resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).isPresent()) {
168-
this.thinExecutionsByNameLink = resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).get();
169-
} else {
170-
this.thinExecutionsByNameLink = null;
171-
}
172-
173-
if(resources.getLink(EXECUTION_LAUNCH_RELATION).isPresent()) {
174-
this.executionLaunchLink = resources.getLink(EXECUTION_LAUNCH_RELATION).get();
175-
} else {
176-
this.executionLaunchLink = null;
177-
}
156+
this.executionsCurrentLink = resources.getLink(EXECUTIONS_CURRENT_RELATION).orElse(null);
157+
this.thinExecutionsLink = resources.getLink(THIN_EXECUTIONS_RELATION).orElse(null);
158+
this.thinExecutionsByNameLink = resources.getLink(THIN_EXECUTIONS_BY_NAME_RELATION).orElse(null);
159+
this.executionLaunchLink = resources.getLink(EXECUTION_LAUNCH_RELATION).orElse(null);
178160
this.executionByNameLink = resources.getLink(EXECUTION_RELATION_BY_NAME).get();
179161
if (resources.getLink(EXECUTIONS_INFO_RELATION).isPresent()) {
180162
this.executionsInfoLink = resources.getLink(EXECUTIONS_INFO_RELATION).get();

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/TaskExecutionControllerTests.java

+6
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,12 @@ void getAllThinExecutions() throws Exception {
343343
}
344344
@Test
345345
void getThinExecutionsByName() throws Exception {
346+
mockMvc.perform(get("/tasks/thinexecutions").queryParam("name", TASK_NAME_ORIG).accept(MediaType.APPLICATION_JSON))
347+
.andExpect(status().isOk())
348+
.andExpect(jsonPath("$._embedded.taskExecutionThinResourceList[*].executionId", containsInAnyOrder(2, 1)))
349+
.andExpect(jsonPath("$._embedded.taskExecutionThinResourceList[*].parentExecutionId", containsInAnyOrder(null, 1)))
350+
.andExpect(jsonPath("$._embedded.taskExecutionThinResourceList[*].taskExecutionStatus", containsInAnyOrder("RUNNING", "RUNNING")))
351+
.andExpect(jsonPath("$._embedded.taskExecutionThinResourceList", hasSize(2)));
346352
mockMvc.perform(get("/tasks/thinexecutions").queryParam("name", "nope").accept(MediaType.APPLICATION_JSON))
347353
.andExpect(jsonPath("$.page.totalElements", is(0)));
348354
mockMvc.perform(get("/tasks/thinexecutions").queryParam("name", "none").accept(MediaType.APPLICATION_JSON))

0 commit comments

Comments
 (0)