"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spring-boot-project/spring-boot/src/test/java/org/springframework/boot/convert/PeriodStyleTests.java" between
spring-boot-2.7.3.tar.gz and spring-boot-2.7.4.tar.gz

About: Spring Boot helps to create Spring-powered, production-grade applications and services.

PeriodStyleTests.java  (spring-boot-2.7.3):PeriodStyleTests.java  (spring-boot-2.7.4)
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* https://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
skipping to change at line 32 skipping to change at line 32
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException ; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException ;
/** /**
* Tests for {@link PeriodStyle}. * Tests for {@link PeriodStyle}.
* *
* @author Eddú Meléndez * @author Eddú Meléndez
* @author Edson Chávez * @author Edson Chávez
* @author Valentine Wu
*/ */
class PeriodStyleTests { class PeriodStyleTests {
@Test @Test
void detectAndParseWhenValueIsNullShouldThrowException() { void detectAndParseWhenValueIsNullShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> PeriodStyle .detectAndParse(null)) assertThatIllegalArgumentException().isThrownBy(() -> PeriodStyle .detectAndParse(null))
.withMessageContaining("Value must not be null"); .withMessageContaining("Value must not be null");
} }
@Test @Test
void detectAndParseWhenIso8601ShouldReturnPeriod() { void detectAndParseWhenIso8601ShouldReturnPeriod() {
assertThat(PeriodStyle.detectAndParse("p15m")).isEqualTo(Period.p arse("p15m"));
assertThat(PeriodStyle.detectAndParse("P15M")).isEqualTo(Period.p arse("P15M")); assertThat(PeriodStyle.detectAndParse("P15M")).isEqualTo(Period.p arse("P15M"));
assertThat(PeriodStyle.detectAndParse("-P15M")).isEqualTo(Period. parse("P-15M")); assertThat(PeriodStyle.detectAndParse("-P15M")).isEqualTo(Period. parse("P-15M"));
assertThat(PeriodStyle.detectAndParse("+P15M")).isEqualTo(Period. parse("P15M")); assertThat(PeriodStyle.detectAndParse("+P15M")).isEqualTo(Period. parse("P15M"));
assertThat(PeriodStyle.detectAndParse("P2D")).isEqualTo(Period.pa rse("P2D")); assertThat(PeriodStyle.detectAndParse("P2D")).isEqualTo(Period.pa rse("P2D"));
assertThat(PeriodStyle.detectAndParse("-P20Y")).isEqualTo(Period. parse("P-20Y")); assertThat(PeriodStyle.detectAndParse("-P20Y")).isEqualTo(Period. parse("P-20Y"));
} }
@Test @Test
void detectAndParseWhenSimpleDaysShouldReturnPeriod() { void detectAndParseWhenSimpleDaysShouldReturnPeriod() {
skipping to change at line 126 skipping to change at line 128
assertThat(PeriodStyle.detect("+10")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("+10")).isEqualTo(PeriodStyle.SIMPL E);
assertThat(PeriodStyle.detect("-10")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("-10")).isEqualTo(PeriodStyle.SIMPL E);
assertThat(PeriodStyle.detect("10m")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("10m")).isEqualTo(PeriodStyle.SIMPL E);
assertThat(PeriodStyle.detect("10y")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("10y")).isEqualTo(PeriodStyle.SIMPL E);
assertThat(PeriodStyle.detect("10d")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("10d")).isEqualTo(PeriodStyle.SIMPL E);
assertThat(PeriodStyle.detect("10D")).isEqualTo(PeriodStyle.SIMPL E); assertThat(PeriodStyle.detect("10D")).isEqualTo(PeriodStyle.SIMPL E);
} }
@Test @Test
void detectWhenIso8601ShouldReturnIso8601() { void detectWhenIso8601ShouldReturnIso8601() {
assertThat(PeriodStyle.detect("p20")).isEqualTo(PeriodStyle.ISO86 01);
assertThat(PeriodStyle.detect("P20")).isEqualTo(PeriodStyle.ISO86 01); assertThat(PeriodStyle.detect("P20")).isEqualTo(PeriodStyle.ISO86 01);
assertThat(PeriodStyle.detect("-P15M")).isEqualTo(PeriodStyle.ISO 8601); assertThat(PeriodStyle.detect("-P15M")).isEqualTo(PeriodStyle.ISO 8601);
assertThat(PeriodStyle.detect("+P15M")).isEqualTo(PeriodStyle.ISO 8601); assertThat(PeriodStyle.detect("+P15M")).isEqualTo(PeriodStyle.ISO 8601);
assertThat(PeriodStyle.detect("P10Y")).isEqualTo(PeriodStyle.ISO8 601); assertThat(PeriodStyle.detect("P10Y")).isEqualTo(PeriodStyle.ISO8 601);
assertThat(PeriodStyle.detect("P2D")).isEqualTo(PeriodStyle.ISO86 01); assertThat(PeriodStyle.detect("P2D")).isEqualTo(PeriodStyle.ISO86 01);
assertThat(PeriodStyle.detect("-P6")).isEqualTo(PeriodStyle.ISO86 01); assertThat(PeriodStyle.detect("-P6")).isEqualTo(PeriodStyle.ISO86 01);
assertThat(PeriodStyle.detect("-P-6M")).isEqualTo(PeriodStyle.ISO 8601); assertThat(PeriodStyle.detect("-P-6M")).isEqualTo(PeriodStyle.ISO 8601);
} }
@Test @Test
void detectWhenUnknownShouldThrowException() { void detectWhenUnknownShouldThrowException() {
assertThatIllegalArgumentException().isThrownBy(() -> PeriodStyle .detect("bad")) assertThatIllegalArgumentException().isThrownBy(() -> PeriodStyle .detect("bad"))
.withMessageContaining("'bad' is not a valid peri od"); .withMessageContaining("'bad' is not a valid peri od");
} }
@Test @Test
void parseIso8601ShouldParse() { void parseIso8601ShouldParse() {
assertThat(PeriodStyle.ISO8601.parse("p20d")).isEqualTo(Period.pa rse("p20d"));
assertThat(PeriodStyle.ISO8601.parse("P20D")).isEqualTo(Period.pa rse("P20D")); assertThat(PeriodStyle.ISO8601.parse("P20D")).isEqualTo(Period.pa rse("P20D"));
assertThat(PeriodStyle.ISO8601.parse("P15M")).isEqualTo(Period.pa rse("P15M")); assertThat(PeriodStyle.ISO8601.parse("P15M")).isEqualTo(Period.pa rse("P15M"));
assertThat(PeriodStyle.ISO8601.parse("+P15M")).isEqualTo(Period.p arse("P15M")); assertThat(PeriodStyle.ISO8601.parse("+P15M")).isEqualTo(Period.p arse("P15M"));
assertThat(PeriodStyle.ISO8601.parse("P10Y")).isEqualTo(Period.pa rse("P10Y")); assertThat(PeriodStyle.ISO8601.parse("P10Y")).isEqualTo(Period.pa rse("P10Y"));
assertThat(PeriodStyle.ISO8601.parse("P2D")).isEqualTo(Period.par se("P2D")); assertThat(PeriodStyle.ISO8601.parse("P2D")).isEqualTo(Period.par se("P2D"));
assertThat(PeriodStyle.ISO8601.parse("-P6D")).isEqualTo(Period.pa rse("-P6D")); assertThat(PeriodStyle.ISO8601.parse("-P6D")).isEqualTo(Period.pa rse("-P6D"));
assertThat(PeriodStyle.ISO8601.parse("-P-6Y+3M")).isEqualTo(Perio d.parse("-P-6Y+3M")); assertThat(PeriodStyle.ISO8601.parse("-P-6Y+3M")).isEqualTo(Perio d.parse("-P-6Y+3M"));
} }
@Test @Test
void parseIso8601WithUnitShouldIgnoreUnit() { void parseIso8601WithUnitShouldIgnoreUnit() {
assertThat(PeriodStyle.ISO8601.parse("p20d", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("p20d"));
assertThat(PeriodStyle.ISO8601.parse("P20D", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P20D")); assertThat(PeriodStyle.ISO8601.parse("P20D", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P20D"));
assertThat(PeriodStyle.ISO8601.parse("P15M", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P15M")); assertThat(PeriodStyle.ISO8601.parse("P15M", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P15M"));
assertThat(PeriodStyle.ISO8601.parse("+P15M", ChronoUnit.SECONDS) ).isEqualTo(Period.parse("P15M")); assertThat(PeriodStyle.ISO8601.parse("+P15M", ChronoUnit.SECONDS) ).isEqualTo(Period.parse("P15M"));
assertThat(PeriodStyle.ISO8601.parse("P10Y", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P10Y")); assertThat(PeriodStyle.ISO8601.parse("P10Y", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("P10Y"));
assertThat(PeriodStyle.ISO8601.parse("P2D", ChronoUnit.SECONDS)). isEqualTo(Period.parse("P2D")); assertThat(PeriodStyle.ISO8601.parse("P2D", ChronoUnit.SECONDS)). isEqualTo(Period.parse("P2D"));
assertThat(PeriodStyle.ISO8601.parse("-P6D", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("-P6D")); assertThat(PeriodStyle.ISO8601.parse("-P6D", ChronoUnit.SECONDS)) .isEqualTo(Period.parse("-P6D"));
assertThat(PeriodStyle.ISO8601.parse("-P-6Y+3M", ChronoUnit.SECON DS)).isEqualTo(Period.parse("-P-6Y+3M")); assertThat(PeriodStyle.ISO8601.parse("-P-6Y+3M", ChronoUnit.SECON DS)).isEqualTo(Period.parse("-P-6Y+3M"));
} }
@Test @Test
 End of changes. 6 change blocks. 
1 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)