Skip to content
Snippets Groups Projects
Commit f20d42c5 authored by Arnaud LABOUREL's avatar Arnaud LABOUREL
Browse files

Added ci config

parent 75b5259f
No related branches found
No related tags found
No related merge requests found
Pipeline #44806 passed
image: gradle:jdk23-alpine
stages:
- build
- test
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
before_script:
- export GRADLE_USER_HOME=`pwd`/.gradle
build:
stage: build
script:
gradle --build-cache build
artifacts:
paths:
- build/libs/*.jar
expire_in: 1 week
test:
stage: test
script:
- gradle test
artifacts:
when: always
reports:
junit: build/test-results/test/**/TEST-*.xml
\ No newline at end of file
plugins {
id("java")
id("application")
id("org.javamodularity.moduleplugin") version "1.8.15"
id("org.openjfx.javafxplugin") version "0.1.0"
id("org.beryx.jlink") version "2.25.0"
}
group = "fr.univ_amu.m1info"
......@@ -24,8 +22,10 @@ javafx {
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.11.3"))
testRuntimeOnly("org.junit.jupiter:junit-jupiter")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.11.4")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("org.assertj:assertj-core:3.27.0")
implementation("org.apache.logging.log4j:log4j-api:2.24.3")
implementation("org.apache.logging.log4j:log4j-core:2.24.3")
implementation("com.fasterxml.jackson.core:jackson-databind:2.18.1")
......
package fr.univ_amu.m1info.util;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.*;
import java.time.Duration;
import java.time.LocalTime;
import java.util.Iterator;
class TimeIntervalGeneratorTest {
private static final LocalTime SIX = LocalTime.of(6, 0, 0);
private static final LocalTime SEVEN = LocalTime.of(7, 0, 0);
private static final LocalTime EIGHT = LocalTime.of(8, 0, 0);
private static final LocalTime NINE = LocalTime.of(9, 0, 0);
private static final LocalTime TEN = LocalTime.of(10, 0, 0);
private static final LocalTime NOON = LocalTime.of(12, 0, 0);
private static final Duration ONE_HOUR = Duration.ofHours(1);
private static final Duration ONE_QUARTER = Duration.ofMinutes(15);
private TimeIntervalGenerator sixToTenByHours;
private TimeIntervalGenerator nineToNoonByQuarters;
@BeforeEach
void testSetUp() {
sixToTenByHours = new TimeIntervalGenerator(SIX, TEN, ONE_HOUR);
nineToNoonByQuarters = new TimeIntervalGenerator(NINE, NOON, ONE_QUARTER);
}
@Test
void testGetIntervalDuration() {
assertThat(sixToTenByHours.getIntervalDuration()).isEqualTo(ONE_HOUR);
assertThat(nineToNoonByQuarters.getIntervalDuration()).isEqualTo(ONE_QUARTER);
}
@Test
void testGetStartTime() {
assertThat(sixToTenByHours.getStartTime()).isEqualTo(SIX);
assertThat(nineToNoonByQuarters.getStartTime()).isEqualTo(NINE);
}
@Test
void testGetEndTime() {
assertThat(sixToTenByHours.getEndTime()).isEqualTo(TEN);
assertThat(nineToNoonByQuarters.getEndTime()).isEqualTo(NOON);
}
@Test
void testGetTimeIntervals() {
assertThat(nineToNoonByQuarters.getTimeIntervals())
.hasSize(12)
.contains(new TimeInterval(NINE, NINE.plus(ONE_QUARTER)),
new TimeInterval(TEN, TEN.plus(ONE_QUARTER)));
assertThat(sixToTenByHours.getTimeIntervals())
.hasSize(4)
.containsExactly(new TimeInterval(SIX, SEVEN), new TimeInterval(SEVEN, EIGHT),
new TimeInterval(EIGHT, NINE), new TimeInterval(NINE, TEN));
}
@Test
void testGetNumberOfIntervals() {
assertThat(sixToTenByHours.getNumberOfIntervals()).isEqualTo(4);
assertThat(nineToNoonByQuarters.getNumberOfIntervals()).isEqualTo(12);
}
@Test
void testGetTimeIndex() {
assertThat(sixToTenByHours.getTimeIndex(EIGHT)).isEqualTo(2);
assertThat(nineToNoonByQuarters.getTimeIndex(NINE)).isEqualTo(0);
}
@Test
void testGetStartTimesOfIntervals() {
assertThat(sixToTenByHours.getStartTimesOfIntervals())
.hasSize(4)
.containsExactly(SIX, SEVEN, EIGHT, NINE);
assertThat(nineToNoonByQuarters.getStartTimesOfIntervals())
.hasSize(12)
.contains(NINE, TEN, TEN.plus(ONE_QUARTER), TEN.plus(ONE_QUARTER.multipliedBy(3)));
}
@Test
void testIterator() {
Iterator<TimeInterval> iterator = nineToNoonByQuarters.iterator();
for (int i = 0; i < 12; i++) {
assertThat(iterator.hasNext()).isTrue();
TimeInterval timeInterval = iterator.next();
LocalTime expectedStart = NINE.plus(ONE_QUARTER.multipliedBy(i));
LocalTime expectedEnd = expectedStart.plus(ONE_QUARTER);
assertThat(timeInterval.start()).isEqualTo(expectedStart);
assertThat(timeInterval.end()).isEqualTo(expectedEnd);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment