Commit 3fe26d94 authored by Colin DAMON's avatar Colin DAMON
Browse files

Merge branch '15-mutualise-java-build' into 'master'

Resolve "Mutualise java build"

Closes #15 and #13

See merge request !12
parents 5cfd5d36 e2bddb8e
......@@ -2,11 +2,37 @@ variables:
MAVEN_OPTS: "-Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$CI_PROJECT_DIR/.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"
stages:
- build
cache:
paths:
- .m2/repository
.java:
image: maven:3.6.3-jdk-14
tags: docker
coverage: '/Total.*?([0-9]{1,3})%/'
stage: build
tags:
- docker
before_script:
- cd $PROJECT_FOLDER
script:
- mvn $MAVEN_CLI_OPTS clean package
- cat target/site/jacoco/index.html
- awk -F"," '{ branches += $6 + $7; covered += $7 } END { print covered, "/", branches, "branches covered"; print 100*covered/branches, "%covered" }' target/site/jacoco/jacoco.csv
artifacts:
reports:
junit: $PROJECT_FOLDER/target/surefire-reports/TEST-*.xml
paths:
- $PROJECT_FOLDER/target/site/jacoco
name: "$PROJECT_FOLDER-report"
expire_in: 1 day
only:
refs:
- master
- merge_requests
changes:
- ".gitlab-ci.yml"
- ".gitlab-common-ci.yml"
- "$PROJECT_FOLDER/**/*"
coverage: "/([^%]+) %covered/"
......@@ -10,20 +10,11 @@
Ce dépôt Git a pour but de partager les différents ateliers pouvant être réalisés durant les sessions live coding d'Ippon Technologies sur sa chaîne Twitch.
* Chaîne Twitch: https://www.twitch.tv/ippontech
* Chaîne Youtube (rediff): https://www.youtube.com/c/ippontechtv
- Chaîne Twitch: https://www.twitch.tv/ippontech
- Chaîne Youtube (rediff): https://www.youtube.com/c/ippontechtv
## Kata Live Coding
* **[WordWrap](https://codingdojo.org/kata/WordWrap/)** : Par Colin DAMON le 09/07/2020
* Niveau: Moyen
* Lien: [Lancement de la chaîne](https://www.youtube.com/watch?v=bokPlp6o02g)
* Go To: [WordWrap](/wordWrap)
* **[Roman Numerals](https://codingdojo.org/kata/RomanNumerals/)**: Par Colin DAMON et Julie CONTE le 15/07/2020
* Niveau: Débutant
* Lien: [Roman Numerals avec Julie et Colin](https://www.youtube.com/watch?v=CWJqq_k7hDY)
* Go To: [RomanNumerals](/romanNumerals)
* **[Presque String Calculator](https://codingdojo.org/kata/StringCalculator/)**: Par Marina FILLATRE et Colin DAMON le 23/07/2020
* Niveau: Moyen
* Lien: [Agility && TDD, Marina et Colin](https://www.youtube.com/watch?v=_G5FzqGLy8c)
* Go To: [stringCalculator](/stringCalculator)
1. [WordWrap](/wordWrap)
2. [RomanNumerals](/romanNumerals)
3. [StringCalculator](/stringCalculator)
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>1.0.0</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>java-parent</artifactId>
<packaging>pom</packaging>
<properties>
<java.version>14</java.version>
<junit.version>5.7.0-M1</junit.version>
<assertj.version>3.16.1</assertj.version>
<mockito.version>3.1.0</mockito.version>
<surefire-plugin.version>3.0.0-M4</surefire-plugin.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<jacoco.version>0.8.5</jacoco.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
stages:
- build
package-roman-numerals:
variables:
PROJECT_FOLDER: "romanNumerals"
extends: .java
stage: build
tags:
- docker
script:
- cd romanNumerals
- mvn $MAVEN_CLI_OPTS clean package
- cat target/site/jacoco/index.html
artifacts:
reports:
junit: romanNumerals/target/surefire-reports/TEST-*.xml
expire_in: 1 day
only:
refs:
- master
- merge_requests
changes:
- ".gitlab-ci.yml"
- ".gitlab-common-ci.yml"
- "romanNumerals/**/*"
<p align="center">
<a href="https://fr.ippon.tech/" target="_blank">
<img alt="Ippon Technologies Logo" width="100" src="https://fr.ippon.tech/assets/images/common/Logo.svg">
</a>
</p>
# Roman Numerals
# Ippon Kata : Roman Numerals
Résolution en TDD et avec explications du kata [Roman Numerals](https://codingdojo.org/kata/RomanNumerals/).
- **Auteurs** : Julie CONTE et Colin DAMON
- **Date** : 15/07/2020
- **Langage** : Java
- **Niveau** : Débutant
- **Replay** : [Roman Numerals avec Julie et Colin](https://www.youtube.com/watch?v=CWJqq_k7hDY)
......@@ -4,95 +4,26 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<version>1.0.0</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>java-parent</artifactId>
<relativePath>../java-parent</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>roman-numerals</artifactId>
<name>RomanNumerals</name>
<properties>
<java.version>14</java.version>
<junit.version>5.7.0-M1</junit.version>
<assertj.version>3.16.1</assertj.version>
<mockito.version>3.1.0</mockito.version>
<surefire-plugin.version>3.0.0-M4</surefire-plugin.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<jacoco.version>0.8.5</jacoco.version>
</properties>
<developers>
<developer>
<email>cdamon@ippon.fr</email>
<name>Colin DAMON</name>
</developer>
<developer>
<email>jconte@ippon.fr</email>
<name>Julie CONTE</name>
</developer>
<developer>
<email>cdamon@ippon.fr</email>
<name>Colin DAMON</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
stages:
- build
package-string-calculator:
variables:
PROJECT_FOLDER: "stringCalculator"
extends: .java
stage: build
tags:
- docker
script:
- cd stringCalculator
- mvn $MAVEN_CLI_OPTS clean package
- cat target/site/jacoco/index.html
artifacts:
reports:
junit: stringCalculator/target/surefire-reports/TEST-*.xml
expire_in: 1 day
only:
refs:
- master
- merge_requests
changes:
- ".gitlab-ci.yml"
- ".gitlab-common-ci.yml"
- "stringCalculator/**/*"
<p align="center">
<a href="https://fr.ippon.tech/" target="_blank">
<img alt="Ippon Technologies Logo" width="100" src="https://fr.ippon.tech/assets/images/common/Logo.svg">
</a>
</p>
# String calculator
# Ippon Kata : String Calculator
Découverte en live d'une version modifiée de [StringCalculator](/stringCalculator). Marina à le role du Product Owner et Colin celui du développeur découvrant les features et les changements pendant le live.
- **Auteurs** : Marina FILLATRE et Colin DAMON
- **Date** : 23/07/2020
- **Langage** : Java
- **Niveau** : Moyen
- **Replay** : [Agility && TDD, Marina et Colin](https://www.youtube.com/watch?v=_G5FzqGLy8c)
......@@ -4,95 +4,26 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<version>1.0.0</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>java-parent</artifactId>
<relativePath>../java-parent</relativePath>
</parent>
<version>1.0.0-SNAPSHOT</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>string-calculator</artifactId>
<name>StringCalculator</name>
<properties>
<java.version>14</java.version>
<junit.version>5.7.0-M1</junit.version>
<assertj.version>3.16.1</assertj.version>
<mockito.version>3.1.0</mockito.version>
<surefire-plugin.version>3.0.0-M4</surefire-plugin.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<jacoco.version>0.8.5</jacoco.version>
</properties>
<developers>
<developer>
<email>cdamon@ippon.fr</email>
<name>Colin DAMON</name>
</developer>
<developer>
<email>mfillatre@ippon.fr</email>
<name>Marina FILLATRE</name>
</developer>
<developer>
<email>cdamon@ippon.fr</email>
<name>Colin DAMON</name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
......@@ -3,25 +3,23 @@ package fr.ippon.stringcalculator;
import java.math.BigDecimal;
import java.util.function.BinaryOperator;
public class Calculator {
public final class Calculator {
private Calculator() {}
public static String sum(String first, String second) {
return operate(first, second, BigDecimal::add);
}
public static String substract(String first,
String second) {
public static String substract(String first, String second) {
return operate(first, second, BigDecimal::subtract);
}
private static String operate(String first,
String second, BinaryOperator<BigDecimal> operation) {
private static String operate(String first, String second, BinaryOperator<BigDecimal> operation) {
notNull(first);
notNull(second);
return operation
.apply(toBigDecimal(first), toBigDecimal(second))
.toPlainString();
return operation.apply(toBigDecimal(first), toBigDecimal(second)).toPlainString();
}
private static BigDecimal toBigDecimal(String value) {
......@@ -37,5 +35,4 @@ public class Calculator {
throw new IllegalArgumentException();
}
}
}
......@@ -8,16 +8,12 @@ public class CalculatorTest {
@Test
void shouldNotSumWithNullFirstInput() {
assertThatThrownBy(() -> Calculator.sum(null, "3"))
.isExactlyInstanceOf(
IllegalArgumentException.class);
assertThatThrownBy(() -> Calculator.sum(null, "3")).isExactlyInstanceOf(IllegalArgumentException.class);
}
@Test
void shouldNotSumWithNullSecondInput() {
assertThatThrownBy(() -> Calculator.sum("3", null))
.isExactlyInstanceOf(
IllegalArgumentException.class);
assertThatThrownBy(() -> Calculator.sum("3", null)).isExactlyInstanceOf(IllegalArgumentException.class);
}
@Test
......@@ -42,48 +38,36 @@ public class CalculatorTest {
@Test
void shouldSumFloats() {
assertThat(Calculator.sum("1.01", "2.02"))
.isEqualTo("3.03");
assertThat(Calculator.sum("1.01", "2.02")).isEqualTo("3.03");
}
@Test
void shouldSumCommaSeparatedFloats() {
assertThat(Calculator.sum("1,01", "2,02"))
.isEqualTo("3.03");
assertThat(Calculator.sum("1,01", "2,02")).isEqualTo("3.03");
}
@Test
void shouldSumNegativeCommaSeparatedFloats() {
assertThat(Calculator.sum("-1,01", "-2,02"))
.isEqualTo("-3.03");
assertThat(Calculator.sum("-1,01", "-2,02")).isEqualTo("-3.03");
}
@Test
void shouldNotSubstractNullInputs() {
assertThatThrownBy(
() -> Calculator.substract(null, "3"))
.isExactlyInstanceOf(
IllegalArgumentException.class);
assertThatThrownBy(() -> Calculator.substract(null, "3")).isExactlyInstanceOf(IllegalArgumentException.class);
}
@Test
void shouldNotSubstractWithNullSecondInputs() {
assertThatThrownBy(
() -> Calculator.substract("3", null))
.isExactlyInstanceOf(
IllegalArgumentException.class);
assertThatThrownBy(() -> Calculator.substract("3", null)).isExactlyInstanceOf(IllegalArgumentException.class);
}
@Test
void shouldSubstractCommaSeparatedFloats() {
assertThat(Calculator.substract("1,01", "2,02"))
.isEqualTo("-1.01");
assertThat(Calculator.substract("1,01", "2,02")).isEqualTo("-1.01");
}
@Test
void shouldSumTooBigIntegers() {
assertThat(Calculator
.sum(String.valueOf(Integer.MAX_VALUE), "2,02"))
.isEqualTo("2147483649.02");
assertThat(Calculator.sum(String.valueOf(Integer.MAX_VALUE), "2,02")).isEqualTo("2147483649.02");
}
}
stages:
- build
package-word-wrap:
variables:
PROJECT_FOLDER: "wordWrap"
extends: .java
stage: build
tags:
- docker
script:
- cd wordWrap
- mvn $MAVEN_CLI_OPTS clean package
- cat target/site/jacoco/index.html
artifacts:
reports:
junit: wordWrap/target/surefire-reports/TEST-*.xml
expire_in: 1 day
only:
refs:
- master
- merge_requests
changes:
- ".gitlab-ci.yml"
- ".gitlab-common-ci.yml"
- "wordWrap/**/*"
<p align="center">
<a href="https://fr.ippon.tech/" target="_blank">
<img alt="Ippon Technologies Logo" width="100" src="https://fr.ippon.tech/assets/images/common/Logo.svg">
</a>
</p>
# Word Wrap
# Ippon Kata : Wrapper
Résolution préparée du kata [WordWrap](https://codingdojo.org/kata/WordWrap/) lors du lancement de la chaine Twitch Ippon.
- **Auteur** : Colin DAMON
- **Date** : 09/07/2020
- **Langage** : Java
- **Niveau** : Moyen
- **Replay** : [Lancement de la chaîne](https://www.youtube.com/watch?v=bokPlp6o02g)
......@@ -4,90 +4,22 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<version>1.0.0</version>
<groupId>fr.ippon.kata</groupId>
<artifactId>java-parent</artifactId>
<relativePath>../java-parent</relativePath>
</parent>