From e448546f63181f65de5be7a2392db5f9596781f6 Mon Sep 17 00:00:00 2001 From: arnaudlabourel <arnaud.labourel@univ-amu.fr> Date: Thu, 8 Sep 2022 14:10:37 +0200 Subject: [PATCH] Version bio-info 2022 --- .gitignore | 10 ++++--- .gitlab-ci.yml | 30 ++++++++++++++++--- README.md | 2 +- build.gradle | 15 ++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 20 +++++++++---- .../java/{TestCohort.java => CohortTest.java} | 16 ++++++---- .../java/{TestGrade.java => GradeTest.java} | 8 ++++- .../{TestStudent.java => StudentTest.java} | 30 ++++++++++++------- ...esult.java => TeachingUnitResultTest.java} | 13 ++++---- 10 files changed, 100 insertions(+), 46 deletions(-) rename src/test/java/{TestCohort.java => CohortTest.java} (82%) rename src/test/java/{TestGrade.java => GradeTest.java} (83%) rename src/test/java/{TestStudent.java => StudentTest.java} (64%) rename src/test/java/{TestTeachingUnitResult.java => TeachingUnitResultTest.java} (50%) diff --git a/.gitignore b/.gitignore index c6012b2..369d1d7 100644 --- a/.gitignore +++ b/.gitignore @@ -22,12 +22,14 @@ .idea/**/dynamic.xml .idea/**/uiDesigner.xml .idea/**/dbnavigator.xml - +.gradle/ +.idea/ # Gradle -.idea/gradle.xml -.idea/workspaces.xml +.idea/**/gradle.xml .idea/**/libraries +.idea/misc.xml +.idea/vcs.xml # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, @@ -37,7 +39,7 @@ .idea/compiler.xml .idea/jarRepositories.xml .idea/modules.xml -.idea/*.iml +idea/*.iml .idea/modules *.iml *.ipr diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 031f7d9..09a6c28 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,7 @@ -image: gradle:jdk17 +image: openjdk:17-alpine + +variables: + GRADLE_OPTS: "-Dorg.gradle.daemon=false" before_script: - export GRADLE_USER_HOME=`pwd`/.gradle @@ -8,11 +11,30 @@ cache: - .gradle/wrapper - .gradle/caches +stages: + - build + - test + +build: + stage: build + script: ./gradlew --build-cache assemble + cache: + key: "$CI_COMMIT_REF_NAME" + policy: push + paths: + - build + - .gradle + java: stage: test - script: - - gradle test + script: ./gradlew test artifacts: when: always reports: - junit: build/test-results/test/**/TEST-*.xml \ No newline at end of file + junit: build/test-results/test/**/TEST-*.xml + cache: + key: "$CI_COMMIT_REF_NAME" + policy: pull + paths: + - build + - .gradle \ No newline at end of file diff --git a/README.md b/README.md index 8203e45..aaec9b3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ Le but de ce TP est de créer des classes permettant de représenter des étudiants (classe `Student`), des notes (classe `Grade`), des résultats à une unité d'enseignement (classe `TeachingUnitResult`) et des promotions d'étudiants (classe `Cohort`). -## Membres du projet +## Membre du projet - NOM, prénom, numéro de groupe diff --git a/build.gradle b/build.gradle index 2b2c1b4..5808b41 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,9 @@ plugins { id "application" + id "java" } -apply plugin : "java" -group 'l2info' +group 'M2_DLAD' version '1.0-SNAPSHOT' repositories { @@ -11,18 +11,15 @@ repositories { } dependencies { - testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2', "org.assertj:assertj-core:3.22.0" - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2' + testImplementation('org.junit.jupiter:junit-jupiter-api:5.9.0', + 'org.assertj:assertj-core:3.23.1') + testRuntimeOnly('org.junit.jupiter:junit-jupiter-engine:5.9.0') } test { useJUnitPlatform() } -ext { - javaMainClass = "Main" -} - application { - mainClassName = javaMainClass + mainClassName = "Main" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 41dfb87..ae04661 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c787..5580fce 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,13 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -143,12 +143,16 @@ fi if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -205,6 +209,12 @@ set -- \ org.gradle.wrapper.GradleWrapperMain \ "$@" +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + # Use "xargs" to parse quoted args. # # With -n1 it outputs one arg per line, with the quotes and backslashes removed. diff --git a/src/test/java/TestCohort.java b/src/test/java/CohortTest.java similarity index 82% rename from src/test/java/TestCohort.java rename to src/test/java/CohortTest.java index 0bddc48..a3d1b7d 100644 --- a/src/test/java/TestCohort.java +++ b/src/test/java/CohortTest.java @@ -1,11 +1,12 @@ import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -class TestCohort { +class CohortTest { private static final Cohort cohort = new Cohort("L2 informatique"); private static final Student davidGoodenough = new Student("David", "Goodenough"); private static final Student jeanMichelBruitage = new Student("Jean-Michel", "Bruitage"); @@ -13,23 +14,27 @@ class TestCohort { @BeforeAll static void addStudentsToCohort(){ - jeanMichelBruitage.addResult("Programmation 2", TestGrade.zero); - jeanMichelBruitage.addResult("Structures discrètes", TestGrade.twenty); - davidGoodenough.addResult("Programmation 2", TestGrade.ten); - davidGoodenough.addResult("Structures discrètes", TestGrade.ten); + jeanMichelBruitage.addResult("Programmation 2", GradeTest.zero); + jeanMichelBruitage.addResult("Structures discrètes", GradeTest.twenty); + davidGoodenough.addResult("Programmation 2", GradeTest.ten); + davidGoodenough.addResult("Structures discrètes", GradeTest.ten); cohort.addStudent(davidGoodenough); cohort.addStudent(jeanMichelBruitage); } + + @Disabled("Disabled until Cohort is coded") @Test void testGetStudentsIsEmpty_whenEmptyCohort(){ assertThat(l1Descartes.getStudents()).isEmpty(); } + @Disabled("Disabled until Cohort is coded") @Test void testGetStudents_whenCohortContainsStudents(){ assertThat(cohort.getStudents()).isEqualTo(List.of(davidGoodenough, jeanMichelBruitage)); } + @Disabled("Disabled until Cohort is coded") @Test void testPrintStudentsResults_whenCohortIsEmpty() { StandardOutputSandbox standardOutputSandbox = new StandardOutputSandbox(l1Descartes::printStudentsResults); @@ -38,6 +43,7 @@ class TestCohort { assertThat(standardOutputSandbox.getProducedOutput()).isEqualTo(expectedOutput); } + @Disabled("Disabled until Cohort is coded") @Test void testPrintStudentsResults_whenCohortContainsStudents() { StandardOutputSandbox standardOutputSandbox = new StandardOutputSandbox(cohort::printStudentsResults); diff --git a/src/test/java/TestGrade.java b/src/test/java/GradeTest.java similarity index 83% rename from src/test/java/TestGrade.java rename to src/test/java/GradeTest.java index d224272..be08c2c 100644 --- a/src/test/java/TestGrade.java +++ b/src/test/java/GradeTest.java @@ -1,3 +1,4 @@ +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.List; @@ -5,7 +6,7 @@ import java.util.List; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.within; -class TestGrade { +class GradeTest { static Grade twenty = new Grade(20); static Grade zero = new Grade(0); static Grade ten = new Grade(10); @@ -13,6 +14,7 @@ class TestGrade { private static final List<Grade> grades = List.of(zero, twenty, ten); private static final List<Grade> gradesZero = List.of(zero, zero); + @Disabled("Disabled until Grade is coded") @Test void testHashCode(){ assertThat(twenty.hashCode()).isEqualTo(new Grade(20).hashCode()) @@ -20,6 +22,7 @@ class TestGrade { .isNotEqualTo(zero.hashCode()); } + @Disabled("Disabled until Grade is coded") @Test void testEquals(){ assertThat(twenty).isEqualTo(new Grade(20)) @@ -30,12 +33,14 @@ class TestGrade { .isNotEqualTo(20.0); } + @Disabled("Disabled until Grade is coded") @Test void testGetValue() { assertThat(twenty.getValue()).isCloseTo(20, within(EPSILON)); assertThat(zero.getValue()).isCloseTo(0, within(EPSILON)); } + @Disabled("Disabled until Grade is coded") @Test void testToString() { assertThat(twenty.toString()).isEqualTo("20.0/20"); @@ -43,6 +48,7 @@ class TestGrade { } + @Disabled("Disabled until Grade is coded") @Test void testAverageGrade(){ assertThat(Grade.averageGrade(grades)).isEqualTo(ten); diff --git a/src/test/java/TestStudent.java b/src/test/java/StudentTest.java similarity index 64% rename from src/test/java/TestStudent.java rename to src/test/java/StudentTest.java index 11e9e98..6adbde7 100644 --- a/src/test/java/TestStudent.java +++ b/src/test/java/StudentTest.java @@ -1,31 +1,35 @@ import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import java.util.List; import static org.assertj.core.api.Assertions.assertThat; -class TestStudent { +class StudentTest { private static final Student arnaudLabourel = new Student("Arnaud", "Labourel"); private static final Student jeanMichelBruitage = new Student("Jean-Michel", "Bruitage"); private static final Student davidGoodenough = new Student("David", "Goodenough"); + @Disabled("Disabled until Student is coded") @BeforeAll static void addResultsToStudents(){ - arnaudLabourel.addResult("Programmation 2", TestGrade.twenty); - arnaudLabourel.addResult("Structures discrètes", TestGrade.twenty); - davidGoodenough.addResult("Programmation 2", TestGrade.ten); - davidGoodenough.addResult("Structures discrètes", TestGrade.zero); - jeanMichelBruitage.addResult("Programmation 2", TestGrade.ten); - jeanMichelBruitage.addResult("Structures discrètes", TestGrade.twenty); + arnaudLabourel.addResult("Programmation 2", GradeTest.twenty); + arnaudLabourel.addResult("Structures discrètes", GradeTest.twenty); + davidGoodenough.addResult("Programmation 2", GradeTest.ten); + davidGoodenough.addResult("Structures discrètes", GradeTest.zero); + jeanMichelBruitage.addResult("Programmation 2", GradeTest.ten); + jeanMichelBruitage.addResult("Structures discrètes", GradeTest.twenty); } + @Disabled("Disabled until Student is coded") @Test void testHashCode(){ assertThat(jeanMichelBruitage.hashCode()).isEqualTo(new Student("Jean-Michel", "Bruitage").hashCode()) .isNotEqualTo(davidGoodenough.hashCode()); } + @Disabled("Disabled until Student is coded") @Test void testEquals(){ assertThat(jeanMichelBruitage).isEqualTo(new Student("Jean-Michel", "Bruitage")) @@ -34,26 +38,30 @@ class TestStudent { .isNotEqualTo("Jean-Michel Bruitage"); } + @Disabled("Disabled until Student is coded") @Test void testToString() { assertThat(jeanMichelBruitage.toString()).isEqualTo("Jean-Michel Bruitage"); assertThat(davidGoodenough.toString()).isEqualTo("David Goodenough"); } + @Disabled("Disabled until Student is coded") @Test void testGetGrades() { - assertThat(arnaudLabourel.getGrades()).isEqualTo(List.of(TestGrade.twenty, TestGrade.twenty)); - assertThat(davidGoodenough.getGrades()).isEqualTo(List.of(TestGrade.ten, TestGrade.zero)); - assertThat(jeanMichelBruitage.getGrades()).isEqualTo(List.of(TestGrade.ten, TestGrade.twenty)); + assertThat(arnaudLabourel.getGrades()).isEqualTo(List.of(GradeTest.twenty, GradeTest.twenty)); + assertThat(davidGoodenough.getGrades()).isEqualTo(List.of(GradeTest.ten, GradeTest.zero)); + assertThat(jeanMichelBruitage.getGrades()).isEqualTo(List.of(GradeTest.ten, GradeTest.twenty)); } + @Disabled("Disabled until Student is coded") @Test void testGetAverageGrade() { - assertThat(arnaudLabourel.averageGrade()).isEqualTo(TestGrade.twenty); + assertThat(arnaudLabourel.averageGrade()).isEqualTo(GradeTest.twenty); assertThat(davidGoodenough.averageGrade()).isEqualTo(new Grade(5)); assertThat(jeanMichelBruitage.averageGrade()).isEqualTo(new Grade(15)); } + @Disabled("Disabled until Student is coded") @Test void testPrintResults() { StandardOutputSandbox standardOutputSandbox = new StandardOutputSandbox(arnaudLabourel::printResults); diff --git a/src/test/java/TestTeachingUnitResult.java b/src/test/java/TeachingUnitResultTest.java similarity index 50% rename from src/test/java/TestTeachingUnitResult.java rename to src/test/java/TeachingUnitResultTest.java index 81428cf..9dd8db9 100644 --- a/src/test/java/TestTeachingUnitResult.java +++ b/src/test/java/TeachingUnitResultTest.java @@ -1,19 +1,22 @@ +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -class TestTeachingUnitResult { +class TeachingUnitResultTest { private static final TeachingUnitResult twentyAtProg = - new TeachingUnitResult("Programmation 2", TestGrade.twenty); + new TeachingUnitResult("Programmation 2", GradeTest.twenty); private static final TeachingUnitResult zeroAtStructDiscrete = - new TeachingUnitResult("Structures discrètes", TestGrade.zero); + new TeachingUnitResult("Structures discrètes", GradeTest.zero); + @Disabled("Disabled until TeachingUnitResult is coded") @Test void testGetGrade() { - assertThat(twentyAtProg.getGrade()).isEqualTo(TestGrade.twenty); - assertThat(zeroAtStructDiscrete.getGrade()).isEqualTo(TestGrade.zero); + assertThat(twentyAtProg.getGrade()).isEqualTo(GradeTest.twenty); + assertThat(zeroAtStructDiscrete.getGrade()).isEqualTo(GradeTest.zero); } + @Disabled("Disabled until TeachingUnitResult is coded") @Test void testToString() { assertThat(twentyAtProg.toString()).isEqualTo("Programmation 2 : 20.0/20"); -- GitLab