Skip to content
This repository was archived by the owner on Oct 17, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.iml
.idea
.DS_Store
target
target
.classpath
.project
.settings/
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
status:
project:
default:
# basic
target: 100%
176 changes: 86 additions & 90 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,100 +1,96 @@
<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>
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>se.cygni</groupId>
<artifactId>ci-tdd-java-template</artifactId>
<version>1..00-SNAPSHOT</version>
<groupId>se.cygni</groupId>
<artifactId>ci-tdd-java-template</artifactId>
<version>1..00-SNAPSHOT</version>

<name>ci-tdd-java-template</name>
<name>ci-tdd-java-template</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.1.0</junit.jupiter.version>
<junit.platform.version>1.1.0</junit.platform.version>
</properties>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<junit.jupiter.version>5.1.0</junit.jupiter.version>
<junit.platform.version>1.1.0</junit.platform.version>
</properties>


<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.9.0</version>
<scope>test</scope>
</dependency>

</dependencies>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!--suppress MavenModelInspection -->
<argLine>${surefireArgLine}</argLine>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<!--
Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Surefire plugin is executed.
-->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!--
Ensures that the code coverage report for unit tests is created after
unit tests have been run.
-->
<execution>
<id>post-unit-test</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!--suppress MavenModelInspection -->
<argLine>${surefireArgLine}</argLine>
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*Tests.java</include>
<include>**/*TestCase.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<!-- https://mvnrepository.com/artifact/org.jacoco/jacoco-maven-plugin -->
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent which
is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!-- Ensures that the code coverage report for unit tests is created
after unit tests have been run. -->
<execution>
<id>post-unit-test</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
35 changes: 21 additions & 14 deletions src/main/java/se/cygni/palmithor/tdd/StringUtils.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package se.cygni.palmithor.tdd;

public class StringUtils {

import java.util.stream.IntStream;

public boolean isPalindrome(final String str) {
throw new RuntimeException("Not yet implemented");
}
public class StringUtils {

public boolean isPalindrome(final String str) {
if(str != null) {
String temp = str.replaceAll("\\s+", "").toLowerCase();
return IntStream.range(0, temp.length() / 2)
.noneMatch(i -> temp.charAt(i) != temp.charAt(temp.length() - i - 1));
}
return false;
}

/**
* Checks if a String is empty (""), null or whitespace only.
* @param str the string to check
*
* @return true if str is null, empty or whitespace only, otherwise false
*/
public boolean isBlank(final String str) {
throw new RuntimeException("Not yet implemented");
}
/**
* Checks if a String is empty (""), null or whitespace only.
*
* @param str
* the string to check
*
* @return true if str is null, empty or whitespace only, otherwise false
*/
public boolean isBlank(final String str) {
return str == null || str.trim().length() == 0;
}
}
7 changes: 6 additions & 1 deletion src/test/java/se/cygni/palmithor/tdd/CalculatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public class CalculatorTest {

@Test
public void test() {
//assertThat(calculator.sumAll().get()).isEqualTo(1); // fail un purpose
assertThat(calculator.sumAll(1).get()).isEqualTo(1); // TODO failing on purpose please fix
assertThat(calculator.sumAll(1,3).get()).isEqualTo(4);
assertThat(calculator.sumAll().get()).isEqualTo(0);
assertThat(calculator.sumAll(null).isPresent()).isFalse();


}


Expand Down
7 changes: 4 additions & 3 deletions src/test/java/se/cygni/palmithor/tdd/StringUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@ public class StringUtilsTest {

@Test
public void isPalindrome() {
/*
assertThat(stringUtils.isPalindrome("aabb")).isFalse();
assertThat(stringUtils.isPalindrome(null)).isFalse();
assertThat(stringUtils.isPalindrome("NotEvenClose")).isFalse();
assertThat(stringUtils.isPalindrome("")).isTrue();
assertThat(stringUtils.isPalindrome("abba")).isTrue();
assertThat(stringUtils.isPalindrome("tattarrattat")).isTrue();
*/
}

/**
* For the following function, you choose if you want to use TDD or not
*/
@Test
public void isBlank() {
// stringUtils.isBlank()
assertThat(stringUtils.isBlank("")).isTrue();
assertThat(stringUtils.isBlank("NotEmpty")).isFalse();
assertThat(stringUtils.isBlank(null)).isTrue();
assertThat(stringUtils.isBlank(" ")).isTrue();
}
}