Skip to content

Commit

Permalink
Clean up tests (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
uschi2000 authored Jul 17, 2016
1 parent f878048 commit 6ef86d7
Showing 1 changed file with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import java.io.IOException;
Expand Down Expand Up @@ -280,31 +279,12 @@ public void testGetFileName_normalizesFirst() {
}

@Test
public void testToString() {
assertThat(new Path("/a/b").toString(), is("/a/b"));
assertThat(new Path("a/b").toString(), is("a/b"));
assertThat(new Path("").toString(), is(""));
assertThat(new Path("/").toString(), is("/"));
assertThat(new Path("a/").toString(), is("a/"));
}

@Test
public void testJsonSerialization() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
assertThat(mapper.writeValueAsString(new Path("/a/b")), is("\"/a/b\""));
assertThat(mapper.writeValueAsString(new Path("a/b")), is("\"a/b\""));
assertThat(mapper.writeValueAsString(new Path("")), is("\"\""));
assertThat(mapper.writeValueAsString(new Path("/")), is("\"/\""));
assertThat(mapper.writeValueAsString(new Path("a/")), is("\"a/\""));
}

@Test
public void testJsonDeserialization() throws IOException {
public void testToStringAndSerialization() throws IOException {
ObjectMapper mapper = new ObjectMapper();
assertThat(mapper.readValue("\"/a/b\"", Path.class), is(new Path("/a/b")));
assertThat(mapper.readValue("\"a/b\"", Path.class), is(new Path("a/b")));
assertThat(mapper.readValue("\"\"", Path.class), is(new Path("")));
assertThat(mapper.readValue("\"/\"", Path.class), is(new Path("/")));
assertThat(mapper.readValue("\"a/\"", Path.class), is(new Path("a/")));
for (String path : new String[] {"/a/b", "a/b", "", "/", "a/"}) {
assertThat(new Path(path).toString(), is(path));
assertThat(mapper.writeValueAsString(new Path(path)), is("\"" + path + "\""));
assertThat(mapper.readValue("\"" + path + "\"", Path.class), is(new Path(path)));
}
}
}

0 comments on commit 6ef86d7

Please sign in to comment.