Skip to content

Commit 6d1bb23

Browse files
committed
Period check test
1 parent 21fb0aa commit 6d1bb23

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
- Period check test
1213
- POC PDFBox line wrapping
1314
- POC PDFBox special characters : U+2002 ('enspace')
1415
- Module pdfbox
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.fugerit.java.code.samples.base;
2+
3+
import java.time.LocalDate;
4+
import java.time.temporal.ChronoUnit;
5+
6+
public class PeriodCheck {
7+
8+
private PeriodCheck() {}
9+
10+
public static Boolean everyNumberOfDaysDateFrom(LocalDate fromDate, LocalDate testDate, int numberOfDays) {
11+
return ChronoUnit.DAYS.between(fromDate, testDate) % numberOfDays == 0;
12+
}
13+
14+
15+
public static Boolean everyWeeekFrom(LocalDate fromDate, LocalDate testDate) {
16+
return everyNumberOfDaysDateFrom(fromDate, testDate, 7);
17+
}
18+
19+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package test.org.fugerit.java.code.samples.base;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.fugerit.java.code.samples.base.AgeCheck;
5+
import org.fugerit.java.code.samples.base.PeriodCheck;
6+
import org.junit.jupiter.api.Assertions;
7+
import org.junit.jupiter.api.Test;
8+
9+
import java.time.LocalDate;
10+
import java.time.temporal.ChronoUnit;
11+
12+
@Slf4j
13+
class TestPeriodCheck {
14+
15+
@Test
16+
void testWeekCheck() {
17+
Assertions.assertTrue(PeriodCheck.everyWeeekFrom( LocalDate.of( 2024, 7, 25 ), LocalDate.of( 2024, 8, 8 ) ) );
18+
Assertions.assertTrue(PeriodCheck.everyWeeekFrom( LocalDate.of( 2024, 8, 1 ), LocalDate.of( 2024, 8, 8 ) ) );
19+
Assertions.assertFalse(PeriodCheck.everyWeeekFrom( LocalDate.of( 2024, 7, 26 ), LocalDate.of( 2024, 8, 8 ) ) );
20+
}
21+
22+
}

0 commit comments

Comments
 (0)