Skip to content
Snippets Groups Projects
Verified Commit aa9f1fd5 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Creation

parents
Branches
No related merge requests found
.project
.classpath
.settings/
target/
*.bench
benchmark-collector/build\.sh
.DS_Store
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>koz01.java02</groupId>
<artifactId>lab01-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.10.1</maven.compiler.version>
<javafx.version>17.0.6</javafx.version>
<junit.version>5.9.2</junit.version>
<log4j.version>2.20.0</log4j.version>
<lombok.version>1.18.26</lombok.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
package koz01.java02;
import java.time.LocalDate;
import java.time.Period;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class AgeCalculator {
private final LocalDate actualDate;
public AgeCalculator() {
this(LocalDate.now());
}
public int compute(LocalDate birthDate) {
return Period.between(actualDate, birthDate).getYears();
}
}
module koz01.java02 {
exports koz01.java02;
requires lombok;
}
\ No newline at end of file
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
<Configuration>
<Appenders>
<Console name="Console">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"></AppenderRef>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
package koz01.java02;
import static java.time.LocalDate.of;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
public class AgeCalculatorTest {
@Test
public void test() {
AgeCalculator ca = new AgeCalculator(of(1900, 2, 1));
assertEquals(1, ca.compute(of(1901, 2, 1)));
assertEquals(0, ca.compute(of(1901, 1, 31)));
assertEquals(1, ca.compute(of(1902, 1, 31)));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment