Skip to content

Commit 12f06de

Browse files
committed
Multimodule structure
1 parent 27ffcd1 commit 12f06de

File tree

7 files changed

+144
-0
lines changed

7 files changed

+144
-0
lines changed

code-samples-base/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>code-samples-base</artifactId>
6+
7+
<parent>
8+
<groupId>org.fugerit.java</groupId>
9+
<artifactId>code-samples</artifactId>
10+
<version>1.0.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<name>Fugerit Code Samples Base</name>
14+
<description>My code samples.</description>
15+
16+
<licenses>
17+
<license>
18+
<name>Apache License, Version 2.0</name>
19+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
20+
<distribution>repo</distribution>
21+
</license>
22+
</licenses>
23+
24+
<scm>
25+
<connection>scm:git:git://github.com/fugerit-org/code-samples.git</connection>
26+
<developerConnection>scm:git:ssh://github.com/fugerit-org/code-samples.git</developerConnection>
27+
<url>https://github.com/fugerit-org/code-samples.git</url>
28+
<tag>HEAD</tag>
29+
</scm>
30+
31+
<organization>
32+
<url>https://www.fugerit.org</url>
33+
<name>Fugerit</name>
34+
</organization>
35+
36+
<url>https://www.fugerit.org/</url>
37+
38+
</project>

code-samples-pdfbox2/pom.xml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>code-samples-pdfbox2</artifactId>
6+
7+
<parent>
8+
<groupId>org.fugerit.java</groupId>
9+
<artifactId>code-samples</artifactId>
10+
<version>1.0.0-SNAPSHOT</version>
11+
</parent>
12+
13+
<name>Fugerit Code Samples</name>
14+
<description>My code samples.</description>
15+
16+
<licenses>
17+
<license>
18+
<name>Apache License, Version 2.0</name>
19+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
20+
<distribution>repo</distribution>
21+
</license>
22+
</licenses>
23+
24+
<properties>
25+
<pdfbox-version>2.0.32</pdfbox-version>
26+
</properties>
27+
28+
<scm>
29+
<connection>scm:git:git://github.com/fugerit-org/code-samples.git</connection>
30+
<developerConnection>scm:git:ssh://github.com/fugerit-org/code-samples.git</developerConnection>
31+
<url>https://github.com/fugerit-org/code-samples.git</url>
32+
<tag>HEAD</tag>
33+
</scm>
34+
35+
<dependencies>
36+
37+
<dependency>
38+
<groupId>org.apache.pdfbox</groupId>
39+
<artifactId>pdfbox</artifactId>
40+
<version>${pdfbox-version}</version>
41+
</dependency>
42+
43+
</dependencies>
44+
45+
<organization>
46+
<url>https://www.fugerit.org</url>
47+
<name>Fugerit</name>
48+
</organization>
49+
50+
<url>https://www.fugerit.org/</url>
51+
52+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.fugerit.java.code.samples.time;
2+
3+
import java.time.LocalDate;
4+
import java.time.temporal.ChronoUnit;
5+
6+
public class AgeCheck {
7+
8+
private AgeCheck() {}
9+
10+
public static Boolean isAgeAtLeast(LocalDate d, int numberOfYears) {
11+
return d != null && d.until(LocalDate.now(), ChronoUnit.YEARS)>=numberOfYears;
12+
}
13+
14+
public static Boolean isAgeAtLeast18(LocalDate d) {
15+
return isAgeAtLeast(d, 18);
16+
}
17+
18+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package test.org.fugerit.java.code.samples.time;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.fugerit.java.code.samples.time.AgeCheck;
5+
import org.junit.jupiter.api.Assertions;
6+
import org.junit.jupiter.api.Test;
7+
8+
import java.time.LocalDate;
9+
10+
@Slf4j
11+
class TestAgeCheck {
12+
13+
private boolean check18Worker( LocalDate d ) {
14+
boolean test = AgeCheck.isAgeAtLeast18( d );
15+
log.info( "check date: {}, isAgeAtLeast18?: {}", d, test );
16+
return test;
17+
}
18+
19+
@Test
20+
void test18() {
21+
LocalDate d = LocalDate.now();
22+
Assertions.assertFalse( this.check18Worker( d ) );
23+
Assertions.assertFalse( this.check18Worker( null ) ); // null is false
24+
Assertions.assertTrue( this.check18Worker( LocalDate.of( d.getYear()-18, d.getMonthValue(), d.getDayOfMonth() ) ) ); // test exactly 18 years, true
25+
Assertions.assertFalse( this.check18Worker( LocalDate.of( d.getYear()-18, d.getMonthValue(), d.getDayOfMonth()+1 ) ) ); // test 18 years -1 day, true
26+
Assertions.assertTrue( this.check18Worker( LocalDate.of( d.getYear()-30, d.getMonthValue(), d.getDayOfMonth() ) ) ); // generic test, true
27+
Assertions.assertFalse( this.check18Worker( LocalDate.of( d.getYear()-5, d.getMonthValue(), d.getDayOfMonth() ) ) ); // generic test, false
28+
}
29+
30+
}

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<name>Fugerit Code Samples</name>
1515
<description>My code samples.</description>
1616
<version>1.0.0-SNAPSHOT</version>
17+
<packaging>pom</packaging>
1718

1819
<licenses>
1920
<license>
@@ -27,6 +28,11 @@
2728
<fj-version>8.6.4</fj-version>
2829
</properties>
2930

31+
<modules>
32+
<module>code-samples-base</module>
33+
<module>code-samples-pdfbox2</module>
34+
</modules>
35+
3036
<scm>
3137
<connection>scm:git:git://github.com/fugerit-org/code-samples.git</connection>
3238
<developerConnection>scm:git:ssh://github.com/fugerit-org/code-samples.git</developerConnection>

0 commit comments

Comments
 (0)