Use new AssertJ duration assertions

See gh-19985
This commit is contained in:
dreis2211
2020-01-30 08:02:22 +01:00
committed by Stephane Nicoll
parent 7de3712e56
commit fac6f08ca3
12 changed files with 108 additions and 116 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
package org.springframework.boot.docs.context.properties.bind;
import java.time.Duration;
import java.util.function.Consumer;
import org.junit.jupiter.api.Test;
@@ -43,8 +42,8 @@ class AppSystemPropertiesTests {
void bindWithDefaultUnit() {
this.contextRunner.withPropertyValues("app.system.session-timeout=40", "app.system.read-timeout=5000")
.run(assertBinding((properties) -> {
assertThat(properties.getSessionTimeout()).isEqualTo(Duration.ofSeconds(40));
assertThat(properties.getReadTimeout()).isEqualTo(Duration.ofMillis(5000));
assertThat(properties.getSessionTimeout()).hasSeconds(40);
assertThat(properties.getReadTimeout()).hasMillis(5000);
}));
}
@@ -52,8 +51,8 @@ class AppSystemPropertiesTests {
void bindWithExplicitUnit() {
this.contextRunner.withPropertyValues("app.system.session-timeout=1h", "app.system.read-timeout=5s")
.run(assertBinding((properties) -> {
assertThat(properties.getSessionTimeout()).isEqualTo(Duration.ofMinutes(60));
assertThat(properties.getReadTimeout()).isEqualTo(Duration.ofMillis(5000));
assertThat(properties.getSessionTimeout()).hasMinutes(60);
assertThat(properties.getReadTimeout()).hasMillis(5000);
}));
}
@@ -61,8 +60,8 @@ class AppSystemPropertiesTests {
void bindWithIso8601Format() {
this.contextRunner.withPropertyValues("app.system.session-timeout=PT15S", "app.system.read-timeout=PT0.5S")
.run(assertBinding((properties) -> {
assertThat(properties.getSessionTimeout()).isEqualTo(Duration.ofSeconds(15));
assertThat(properties.getReadTimeout()).isEqualTo(Duration.ofMillis(500));
assertThat(properties.getSessionTimeout()).hasSeconds(15);
assertThat(properties.getReadTimeout()).hasMillis(500);
}));
}