From 4a9fbb153630cee0d6a4854cef21438f0c407c28 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Sun, 26 Nov 2023 19:59:09 +0200 Subject: [PATCH] Fix imports and spacing. Removed .andDo(print()) --- .../repository/JdbcAggregateJobQueryDao.java | 17 +++++++++++------ .../controller/JobInstanceControllerTests.java | 5 ----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java index a923fc4c54..d157cd994b 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/repository/JdbcAggregateJobQueryDao.java @@ -16,12 +16,19 @@ package org.springframework.cloud.dataflow.server.repository; -import javax.sql.DataSource; import java.sql.ResultSet; import java.sql.SQLException; import java.time.Instant; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; import java.util.stream.Collectors; +import javax.sql.DataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -239,12 +246,10 @@ public JdbcAggregateJobQueryDao(DataSource dataSource, SchemaService schemaServi @Override public Page listJobInstances(String jobName, Pageable pageable) throws NoSuchJobException { int total = countJobExecutions(jobName); - if(total == 0) { + if (total == 0) { throw new NoSuchJobException("No Job with that name either current or historic: [" + jobName + "]"); } - List taskJobInstancesForJobName = total > 0 - ? getTaskJobInstancesForJobName(jobName, pageable) - : Collections.emptyList(); + List taskJobInstancesForJobName = getTaskJobInstancesForJobName(jobName, pageable); return new PageImpl<>(taskJobInstancesForJobName, pageable, total); } diff --git a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/JobInstanceControllerTests.java b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/JobInstanceControllerTests.java index e00cb2a238..50af0a6128 100644 --- a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/JobInstanceControllerTests.java +++ b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/JobInstanceControllerTests.java @@ -119,14 +119,12 @@ public void testJobInstanceControllerConstructorMissingRepository() { @Test public void testGetInstanceNotFound() throws Exception { mockMvc.perform(get("/jobs/instances/1345345345345").accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(status().isNotFound()); } @Test public void testGetInstance() throws Exception { mockMvc.perform(get("/jobs/instances/1").accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$.jobInstanceId", equalTo(1))) .andExpect(jsonPath("$.jobExecutions[0].stepExecutionCount", equalTo(1))) @@ -136,7 +134,6 @@ public void testGetInstance() throws Exception { @Test public void testGetInstancesByName() throws Exception { mockMvc.perform(get("/jobs/instances/").param("name", JOB_NAME_ORIG).accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$._embedded.jobInstanceResourceList[0].jobName", is(JOB_NAME_ORIG))) .andExpect(jsonPath("$._embedded.jobInstanceResourceList", hasSize(1))); @@ -145,7 +142,6 @@ public void testGetInstancesByName() throws Exception { @Test public void testGetExecutionsByNameMultipleResult() throws Exception { mockMvc.perform(get("/jobs/instances/").param("name", JOB_NAME_FOOBAR).accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(status().isOk()) .andExpect(jsonPath("$._embedded.jobInstanceResourceList[0].jobName", is(JOB_NAME_FOOBAR))) .andExpect(jsonPath("$._embedded.jobInstanceResourceList[0].jobExecutions[0].executionId", is(4))) @@ -156,7 +152,6 @@ public void testGetExecutionsByNameMultipleResult() throws Exception { @Test public void testGetInstanceByNameNotFound() throws Exception { mockMvc.perform(get("/jobs/instances/").param("name", "BAZ").accept(MediaType.APPLICATION_JSON)) - .andDo(print()) .andExpect(status().is4xxClientError()) .andExpect(content().string(containsString("NoSuchJobException"))); }