Updated to files to fit the Standard.

This commit is contained in:
Glenn Renfro
2022-07-25 11:41:43 -04:00
parent 39908bb499
commit 76a5d12136
200 changed files with 2839 additions and 4125 deletions

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.task.timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -37,7 +36,7 @@ import org.springframework.context.annotation.Bean;
*/
@EnableTask
@SpringBootApplication
@EnableConfigurationProperties({TimestampTaskProperties.class})
@EnableConfigurationProperties({ TimestampTaskProperties.class })
public class TaskApplication {
private static final Log logger = LogFactory.getLog(TaskApplication.class);
@@ -64,5 +63,7 @@ public class TaskApplication {
DateFormat dateFormat = new SimpleDateFormat(this.config.getFormat());
logger.info(dateFormat.format(new Date()));
}
}
}

View File

@@ -38,4 +38,5 @@ public class TimestampTaskProperties {
public void setFormat(String format) {
this.format = format;
}
}

View File

@@ -36,26 +36,23 @@ import static org.assertj.core.api.Assertions.assertThat;
@ExtendWith(OutputCaptureExtension.class)
public class TaskApplicationTests {
@Test
public void testTimeStampApp(CapturedOutput capturedOutput) throws Exception {
final String TEST_DATE_DOTS = ".......";
final String CREATE_TASK_MESSAGE = "Creating: TaskExecution{executionId=";
final String UPDATE_TASK_MESSAGE = "Updating: TaskExecution with executionId=";
final String EXIT_CODE_MESSAGE = "with the following {exitCode=0";
String[] args = {"--format=yyyy" + TEST_DATE_DOTS};
String[] args = { "--format=yyyy" + TEST_DATE_DOTS };
SpringApplication.run(TaskApplication.class, args);
String output = capturedOutput.toString();
assertThat(output.contains(TEST_DATE_DOTS))
.as("Unable to find the timestamp: " + output).isTrue();
assertThat(output.contains(CREATE_TASK_MESSAGE))
.as("Test results do not show create task message: " + output).isTrue();
assertThat(output.contains(UPDATE_TASK_MESSAGE))
.as("Test results do not show success message: " + output).isTrue();
assertThat(output.contains(EXIT_CODE_MESSAGE))
.as("Test results have incorrect exit code: " + output).isTrue();
assertThat(output.contains(TEST_DATE_DOTS)).as("Unable to find the timestamp: " + output).isTrue();
assertThat(output.contains(CREATE_TASK_MESSAGE)).as("Test results do not show create task message: " + output)
.isTrue();
assertThat(output.contains(UPDATE_TASK_MESSAGE)).as("Test results do not show success message: " + output)
.isTrue();
assertThat(output.contains(EXIT_CODE_MESSAGE)).as("Test results have incorrect exit code: " + output).isTrue();
String taskTitle = "Demo Timestamp Task";
Pattern pattern = Pattern.compile(taskTitle);
@@ -64,7 +61,7 @@ public class TaskApplicationTests {
while (matcher.find()) {
count++;
}
assertThat(count).as("The number of task titles did not match expected: ")
.isEqualTo(1);
assertThat(count).as("The number of task titles did not match expected: ").isEqualTo(1);
}
}

View File

@@ -16,7 +16,6 @@
package org.springframework.cloud.task.timestamp;
import org.junit.jupiter.api.Test;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -39,8 +38,7 @@ public class TimestampTaskPropertiesTests {
testPropertyValues.applyTo(context);
context.register(Conf.class);
context.refresh();
TimestampTaskProperties properties = context
.getBean(TimestampTaskProperties.class);
TimestampTaskProperties properties = context.getBean(TimestampTaskProperties.class);
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(() -> {
properties.getFormat();
});
@@ -51,10 +49,9 @@ public class TimestampTaskPropertiesTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(Conf.class);
context.refresh();
TimestampTaskProperties properties = context
.getBean(TimestampTaskProperties.class);
TimestampTaskProperties properties = context.getBean(TimestampTaskProperties.class);
assertThat(properties.getFormat()).as("result does not match default format.")
.isEqualTo("yyyy-MM-dd HH:mm:ss.SSS");
.isEqualTo("yyyy-MM-dd HH:mm:ss.SSS");
}
@Test
@@ -63,15 +60,15 @@ public class TimestampTaskPropertiesTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(Conf.class);
context.refresh();
TimestampTaskProperties properties = context
.getBean(TimestampTaskProperties.class);
TimestampTaskProperties properties = context.getBean(TimestampTaskProperties.class);
properties.setFormat(FORMAT);
assertThat(properties.getFormat()).as("result does not match established format.")
.isEqualTo(FORMAT);
assertThat(properties.getFormat()).as("result does not match established format.").isEqualTo(FORMAT);
}
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(TimestampTaskProperties.class)
static class Conf {
}
}