Skip to content

Commit

Permalink
Initial import of the Kata.
Browse files Browse the repository at this point in the history
  • Loading branch information
yanaga committed Dec 2, 2014
1 parent d6e7bb1 commit 770dc05
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea
/*.iml
/target
34 changes: 34 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
<groupId>com.github.javacodekata</groupId>
<artifactId>stream-lambda</artifactId>
<name>stream-lambda</name>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<scm>
<connection>scm:git:git@github.com:JavaCodeKata/stream-lambda.git</connection>
<url>scm:git:git@github.com:JavaCodeKata/stream-lambda.git</url>
<developerConnection>scm:git:git@github.com:JavaCodeKata/stream-lambda.git</developerConnection>
</scm>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.github.javacodekata.lambda.stream;

import com.google.common.collect.ImmutableList;

import java.util.LinkedList;
import java.util.List;

import static com.google.common.base.Preconditions.checkNotNull;

public class ListTransformer {

private final List<String> values;

private ListTransformer(List<String> values) {
this.values = values;
}

public static ListTransformer of(List<String> values) {
checkNotNull(values);
return new ListTransformer(ImmutableList.copyOf(values));
}

public List<String> getSortedStrings() {
return values;
}

public List<Integer> getSortedIntegers() {
return new LinkedList<>();
}

public List<Integer> getSortedDescendingIntegers() {
return new LinkedList<>();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.github.javacodekata.lambda.stream;

import org.junit.Before;
import org.junit.Test;

import java.util.Arrays;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class ListTransformerTest {

private static final String[] strings =
{ "a", "7", "4", "z", "T", "c", "10", "h", "2" };

private ListTransformer listTransformer;

@Before
public void setup() {
this.listTransformer = ListTransformer.of(Arrays.asList(strings));
}

@Test
public void testGetSortedStrings() throws Exception {
assertThat(listTransformer.getSortedStrings(), is(equalTo(Arrays.asList("10", "2", "4", "7", "T", "a", "c", "h", "z"))));
}

@Test
public void testGetSortedIntegers() throws Exception {
assertThat(listTransformer.getSortedIntegers(), is(equalTo(Arrays.asList(2, 4, 7, 10))));
}

@Test
public void testGetSortedDescendingIntegers() throws Exception {
assertThat(listTransformer.getSortedDescendingIntegers(), is(equalTo(Arrays.asList(10, 7, 4, 2))));
}

}

0 comments on commit 770dc05

Please sign in to comment.