Skip to content

Commit 770dc05

Browse files
committed
Initial import of the Kata.
1 parent d6e7bb1 commit 770dc05

4 files changed

Lines changed: 111 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/*.iml
3+
/target

pom.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>com.github.javacodekata</groupId>
6+
<artifactId>stream-lambda</artifactId>
7+
<name>stream-lambda</name>
8+
<packaging>jar</packaging>
9+
<version>1.0-SNAPSHOT</version>
10+
<scm>
11+
<connection>scm:git:[email protected]:JavaCodeKata/stream-lambda.git</connection>
12+
<url>scm:git:[email protected]:JavaCodeKata/stream-lambda.git</url>
13+
<developerConnection>scm:git:[email protected]:JavaCodeKata/stream-lambda.git</developerConnection>
14+
</scm>
15+
<properties>
16+
<maven.compiler.source>1.8</maven.compiler.source>
17+
<maven.compiler.target>1.8</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
20+
</properties>
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.google.guava</groupId>
24+
<artifactId>guava</artifactId>
25+
<version>18.0</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>junit</groupId>
29+
<artifactId>junit</artifactId>
30+
<version>4.11</version>
31+
<scope>test</scope>
32+
</dependency>
33+
</dependencies>
34+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.github.javacodekata.lambda.stream;
2+
3+
import com.google.common.collect.ImmutableList;
4+
5+
import java.util.LinkedList;
6+
import java.util.List;
7+
8+
import static com.google.common.base.Preconditions.checkNotNull;
9+
10+
public class ListTransformer {
11+
12+
private final List<String> values;
13+
14+
private ListTransformer(List<String> values) {
15+
this.values = values;
16+
}
17+
18+
public static ListTransformer of(List<String> values) {
19+
checkNotNull(values);
20+
return new ListTransformer(ImmutableList.copyOf(values));
21+
}
22+
23+
public List<String> getSortedStrings() {
24+
return values;
25+
}
26+
27+
public List<Integer> getSortedIntegers() {
28+
return new LinkedList<>();
29+
}
30+
31+
public List<Integer> getSortedDescendingIntegers() {
32+
return new LinkedList<>();
33+
}
34+
35+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.github.javacodekata.lambda.stream;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
6+
import java.util.Arrays;
7+
8+
import static org.hamcrest.CoreMatchers.equalTo;
9+
import static org.hamcrest.CoreMatchers.is;
10+
import static org.junit.Assert.assertThat;
11+
12+
public class ListTransformerTest {
13+
14+
private static final String[] strings =
15+
{ "a", "7", "4", "z", "T", "c", "10", "h", "2" };
16+
17+
private ListTransformer listTransformer;
18+
19+
@Before
20+
public void setup() {
21+
this.listTransformer = ListTransformer.of(Arrays.asList(strings));
22+
}
23+
24+
@Test
25+
public void testGetSortedStrings() throws Exception {
26+
assertThat(listTransformer.getSortedStrings(), is(equalTo(Arrays.asList("10", "2", "4", "7", "T", "a", "c", "h", "z"))));
27+
}
28+
29+
@Test
30+
public void testGetSortedIntegers() throws Exception {
31+
assertThat(listTransformer.getSortedIntegers(), is(equalTo(Arrays.asList(2, 4, 7, 10))));
32+
}
33+
34+
@Test
35+
public void testGetSortedDescendingIntegers() throws Exception {
36+
assertThat(listTransformer.getSortedDescendingIntegers(), is(equalTo(Arrays.asList(10, 7, 4, 2))));
37+
}
38+
39+
}

0 commit comments

Comments
 (0)