Commit 4901bf13 authored by Colin DAMON's avatar Colin DAMON

Switch to autonomous kata

parent 36585115
######################
# Project Specific
######################
/src/main/webapp/content/css/main.css
/target/classes/static/**
/src/test/javascript/coverage/
######################
# Node
######################
/node/
node_tmp/
node_modules/
npm-debug.log.*
/.awcache/*
/.cache-loader/*
######################
# SASS
######################
.sass-cache/
######################
# Eclipse
######################
*.pydevproject
.project
# Created by https://www.toptal.com/developers/gitignore/api/eclipse,intellij,visualstudiocode,java,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=eclipse,intellij,visualstudiocode,java,maven
### Eclipse ###
.metadata
bin/
tmp/
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.factorypath
/src/main/resources/rebel.xml
.recommenders
# External tool builders
.externalToolBuilders/**
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
# PyDev specific (Python IDE for Eclipse)
*.pydevproject
# CDT-specific (C/C++ Development Tooling)
.cproject
# PDT-specific
# CDT- autotools
.autotools
# Java annotation processor (APT)
.factorypath
# PDT-specific (PHP Development Tools)
.buildpath
######################
# Intellij
######################
.idea/
*.iml
# sbteclipse plugin
.target
# Tern plugin
.tern-project
# TeXlipse plugin
.texlipse
# STS (Spring Tool Suite)
.springBeans
# Code Recommenders
.recommenders/
# Annotation Processing
.apt_generated/
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
### Eclipse Patch ###
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
# Annotation Processing
.apt_generated
.sts4-cache/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
*.ipr
*.ids
*.orig
classes/
# IntelliJ
out/
######################
# Visual Studio Code
######################
.vscode/
# mpeltonen/sbt-idea plugin
.idea_modules/
######################
# Maven
######################
/log/
/target/
# JIRA plugin
atlassian-ide-plugin.xml
######################
# Gradle
######################
.gradle/
/build/
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
######################
# Package Files
######################
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
.idea/sonarlint
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# Mac OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Directories
######################
/bin/
/deploy/
######################
# Logs
######################
*.log*
######################
# Others
######################
*.class
*.*~
*~
.merge_file*
######################
# Gradle Wrapper
######################
!gradle/wrapper/gradle-wrapper.jar
######################
# Maven Wrapper
######################
!.mvn/wrapper/maven-wrapper.jar
######################
# ESLint
######################
.eslintcache
nohup.out
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
# End of https://www.toptal.com/developers/gitignore/api/eclipse,intellij,visualstudiocode,java,maven
image: maven:latest
stages:
- build
variables:
MAVEN_CLI_OPTS: '-s .m2/settings.xml --batch-mode'
cache:
paths:
- .maven/
before_script:
- export MAVEN_USER_HOME=`pwd`/.maven
maven-compile:
stage: build
script:
- ./mvnw $MAVEN_CLI_OPTS compile -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
paths:
- target/classes/
- target/generated-sources/
expire_in: 1 day
maven-test:
stage: test
script: ./mvnw $MAVEN_CLI_OPTS verify -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
reports:
junit: target/test-results/**/TEST-*.xml
dependency_scanning: target/dependency-check-report.xml
paths:
- target/test-results
- target/jacoco
- target/dependency-check-report.xml
- target/dependency-check-report.html
expire_in: 1 day
include:
- local: "/.gitlab-common-ci.yml"
- local: "/wordWrap/.gitlab-ci.yml"
- local: "/romanNumerals/.gitlab-ci.yml"
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"
cache:
paths:
- .m2/repository
.java:
image: maven:3.6.3-jdk-14
tags: docker
coverage: '/Total.*?([0-9]{1,3})%/'
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<pluginGroups/>
<proxies/>
<servers/>
<mirrors/>
<profiles/>
</settings>
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
This diff was suppressed by a .gitattributes entry.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
......@@ -17,7 +17,7 @@ Ce dépôt Git a pour but de partager les différents ateliers pouvant être ré
## Kata Live Coding
* **Wrapper** : Proposé par Colin DAMON le 09/07/2020
* lien: [Lancement de la chaîne](https://www.youtube.com/watch?v=bokPlp6o02g)
* Go To: [Wrapper](/kata/wrapper)
* Go To: [Wrapper](/wordWrap)
* **Roman Numerals**: Proposé par Colin DAMON et Julie le 15/07/2020
* lien: [Roman Numerals avec Julie et Colin](https://www.twitch.tv/videos/680494502) (lien twitch en attendant upload YT)
* Go To: [Roman Numerals](/kata/romanNumerals)
* Go To: [Roman Numerals](/romanNumerals)
<?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>
<parent>
<groupId>fr.ippon.live-coding</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>
<groupId>fr.ippon.kata</groupId>
<artifactId>romanNumerals</artifactId>
<name>Roman Numerals Kata</name>
<developers>
<developer>
<email>cdamon@ippon.tech</email>
<name>Colin DAMON</name>
</developer>
<developer>
<email></email>
<name>Julie </name>
</developer>
</developers>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package fr.ippon.kata.roman;
import java.util.NavigableMap;
import java.util.TreeMap;
public class Numerals {
private static final NavigableMap<Integer, Roman> CONVERSIONS = buildConversions();
public static String toRoman(int arabic) {
// TODO : Use Stream.iterable to avoid stackoverflow on recursion
if (arabic <= 0) {
return "";
}
Integer highestKnownConversion = CONVERSIONS.floorKey(arabic);
String highestKnownRepresentation = CONVERSIONS
.get(highestKnownConversion)
.getRepresentation();
return highestKnownRepresentation + toRoman(arabic - highestKnownConversion);
}
private static NavigableMap<Integer, Roman> buildConversions() {
NavigableMap<Integer, Roman> conversions = new TreeMap<>();
conversions.put(1, Roman.ONE);
conversions.put(4, Roman.FOUR);
conversions.put(5, Roman.FIVE);
conversions.put(9, Roman.NINE);
conversions.put(10, Roman.TEN);
return conversions;
}
}
package fr.ippon.kata.roman;
import org.junit.jupiter.api.Test;
import static fr.ippon.kata.roman.Numerals.toRoman;
import static org.assertj.core.api.Assertions.*;
class NumeralsTest {
@Test
void shouldConvertZeroToEmptyString() {
assertThat(toRoman(0)).isEmpty();
}
@Test
void shouldConvertOneToI() {
assertThat(toRoman(1)).isEqualTo("I");
}
@Test
void shouldConvertThreeToIII() {
assertThat(toRoman(3)).isEqualTo("III");
}
@Test
void shouldConvertFourToIV() {
assertThat(toRoman(4)).isEqualTo("IV");
}
@Test
void shouldConvertFiveToV() {
assertThat(toRoman(5)).isEqualTo("V");
}
@Test
void shouldConvertSixToVI() {
assertThat(toRoman(6)).isEqualTo("VI");
}
@Test
void shouldConvertNineToIX() {
assertThat(toRoman(9)).isEqualTo("IX");
}
@Test
void shouldConvertTenToTen() {
assertThat(toRoman(10)).isEqualTo("X");
}
@Test
void shouldConvertFourteenToXIV() {
assertThat(toRoman(14)).isEqualTo("XIV");
}