Upgrade Kotlin, AssertJ, compile-testing, and kotlin-metadata dependencies
This commit is contained in:
parent
f873bd93b7
commit
735f0c39f7
5 changed files with 42 additions and 29 deletions
|
@ -108,7 +108,7 @@
|
|||
<sourceDirs>
|
||||
<sourceDir>src/test/kotlin</sourceDir>
|
||||
<sourceDir>src/test/java</sourceDir>
|
||||
<sourceDir>target/generated-sources/kapt/test</sourceDir>
|
||||
<sourceDir>target/generated-sources/kaptKotlin/test</sourceDir>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
@ -144,7 +144,9 @@
|
|||
<execution>
|
||||
<id>java-test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals> <goal>testCompile</goal> </goals>
|
||||
<goals>
|
||||
<goal>testCompile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
|
|
@ -18,6 +18,7 @@ package com.squareup.moshi;
|
|||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -28,7 +29,6 @@ import org.junit.Test;
|
|||
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public final class JsonValueWriterTest {
|
||||
|
@ -57,8 +57,11 @@ public final class JsonValueWriterTest {
|
|||
writer.name("d").nullValue();
|
||||
writer.endObject();
|
||||
|
||||
assertThat((Map<?, ?>) writer.root()).containsExactly(
|
||||
entry("a", "s"), entry("b", 1.5d), entry("c", true), entry("d", null));
|
||||
assertThat((Map<String, Object>) writer.root()).containsExactly(
|
||||
new SimpleEntry<String, Object>("a", "s"),
|
||||
new SimpleEntry<String, Object>("b", 1.5d),
|
||||
new SimpleEntry<String, Object>("c", true),
|
||||
new SimpleEntry<String, Object>("d", null));
|
||||
}
|
||||
|
||||
@Test public void repeatedNameThrows() throws IOException {
|
||||
|
@ -253,8 +256,11 @@ public final class JsonValueWriterTest {
|
|||
writer.name("d");
|
||||
writer.value(new Buffer().writeUtf8("null"));
|
||||
writer.endObject();
|
||||
assertThat((Map<?, ?>) writer.root()).containsExactly(
|
||||
entry("a", singletonList("value")), entry("b", 2.0d), entry("c", 3L), entry("d", null));
|
||||
assertThat((Map<String, Object>) writer.root()).containsExactly(
|
||||
new SimpleEntry<String, Object>("a", singletonList("value")),
|
||||
new SimpleEntry<String, Object>("b", 2.0d),
|
||||
new SimpleEntry<String, Object>("c", 3L),
|
||||
new SimpleEntry<String, Object>("d", null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,12 +17,12 @@ package com.squareup.moshi;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import okio.Buffer;
|
||||
import org.assertj.core.data.MapEntry;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.squareup.moshi.TestUtil.newReader;
|
||||
|
@ -45,7 +45,9 @@ public final class MapJsonAdapterTest {
|
|||
Map<String, Boolean> fromJson = fromJson(
|
||||
String.class, Boolean.class, "{\"a\":true,\"b\":false,\"c\":null}");
|
||||
assertThat(fromJson).containsExactly(
|
||||
MapEntry.entry("a", true), MapEntry.entry("b", false), MapEntry.entry("c", null));
|
||||
new SimpleEntry<String, Boolean>("a", true),
|
||||
new SimpleEntry<String, Boolean>("b", false),
|
||||
new SimpleEntry<String, Boolean>("c", null));
|
||||
}
|
||||
|
||||
@Test public void mapWithNullKeyFailsToEmit() throws Exception {
|
||||
|
@ -119,13 +121,15 @@ public final class MapJsonAdapterTest {
|
|||
String toJson = toJson(Integer.class, Boolean.class, map);
|
||||
assertThat(toJson).isEqualTo("{\"5\":true,\"6\":false,\"7\":null}");
|
||||
|
||||
Map<String, Boolean> fromJson = fromJson(
|
||||
Map<Integer, Boolean> fromJson = fromJson(
|
||||
Integer.class, Boolean.class, "{\"5\":true,\"6\":false,\"7\":null}");
|
||||
assertThat(fromJson).containsExactly(
|
||||
MapEntry.entry(5, true), MapEntry.entry(6, false), MapEntry.entry(7, null));
|
||||
new SimpleEntry<Integer, Boolean>(5, true),
|
||||
new SimpleEntry<Integer, Boolean>(6, false),
|
||||
new SimpleEntry<Integer, Boolean>(7, null));
|
||||
}
|
||||
|
||||
@Test public void mapWithNonStringKeysToJsonObject() throws Exception {
|
||||
@Test public void mapWithNonStringKeysToJsonObject() {
|
||||
Map<Integer, Boolean> map = new LinkedHashMap<>();
|
||||
map.put(5, true);
|
||||
map.put(6, false);
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.math.BigDecimal;
|
|||
import java.util.AbstractCollection;
|
||||
import java.util.AbstractList;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.AbstractSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
@ -40,10 +41,9 @@ import org.junit.Test;
|
|||
import static java.util.Collections.singletonList;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.entry;
|
||||
|
||||
public final class ObjectAdapterTest {
|
||||
@Test public void toJsonUsesRuntimeType() throws Exception {
|
||||
@Test public void toJsonUsesRuntimeType() {
|
||||
Delivery delivery = new Delivery();
|
||||
delivery.address = "1455 Market St.";
|
||||
Pizza pizza = new Pizza();
|
||||
|
@ -62,7 +62,7 @@ public final class ObjectAdapterTest {
|
|||
+ "}");
|
||||
}
|
||||
|
||||
@Test public void toJsonJavaLangObject() throws Exception {
|
||||
@Test public void toJsonJavaLangObject() {
|
||||
Moshi moshi = new Moshi.Builder().build();
|
||||
JsonAdapter<Object> adapter = moshi.adapter(Object.class);
|
||||
assertThat(adapter.toJson(new Object())).isEqualTo("{}");
|
||||
|
@ -104,7 +104,7 @@ public final class ObjectAdapterTest {
|
|||
.isEqualTo(emptyDelivery);
|
||||
}
|
||||
|
||||
@Test public void toJsonCoercesRuntimeTypeForCollections() throws Exception {
|
||||
@Test public void toJsonCoercesRuntimeTypeForCollections() {
|
||||
Collection<String> collection = new AbstractCollection<String>() {
|
||||
@Override public Iterator<String> iterator() {
|
||||
return Collections.singleton("A").iterator();
|
||||
|
@ -119,7 +119,7 @@ public final class ObjectAdapterTest {
|
|||
assertThat(adapter.toJson(collection)).isEqualTo("[\"A\"]");
|
||||
}
|
||||
|
||||
@Test public void toJsonCoercesRuntimeTypeForLists() throws Exception {
|
||||
@Test public void toJsonCoercesRuntimeTypeForLists() {
|
||||
List<String> list = new AbstractList<String>() {
|
||||
@Override public String get(int i) {
|
||||
return "A";
|
||||
|
@ -135,7 +135,7 @@ public final class ObjectAdapterTest {
|
|||
assertThat(adapter.toJson(list)).isEqualTo("[\"A\"]");
|
||||
}
|
||||
|
||||
@Test public void toJsonCoercesRuntimeTypeForSets() throws Exception {
|
||||
@Test public void toJsonCoercesRuntimeTypeForSets() {
|
||||
Set<String> set = new AbstractSet<String>() {
|
||||
@Override public Iterator<String> iterator() {
|
||||
return Collections.singleton("A").iterator();
|
||||
|
@ -151,7 +151,7 @@ public final class ObjectAdapterTest {
|
|||
}
|
||||
|
||||
@Ignore // We don't support raw maps, like Map<Object, Object>. (Even if the keys are strings!)
|
||||
@Test public void toJsonCoercesRuntimeTypeForMaps() throws Exception {
|
||||
@Test public void toJsonCoercesRuntimeTypeForMaps() {
|
||||
Map<String, Boolean> map = new AbstractMap<String, Boolean>() {
|
||||
@Override public Set<Entry<String, Boolean>> entrySet() {
|
||||
return Collections.singletonMap("A", true).entrySet();
|
||||
|
@ -163,7 +163,7 @@ public final class ObjectAdapterTest {
|
|||
assertThat(adapter.toJson(map)).isEqualTo("{\"A\":true}");
|
||||
}
|
||||
|
||||
@Test public void toJsonUsesTypeAdapters() throws Exception {
|
||||
@Test public void toJsonUsesTypeAdapters() {
|
||||
Object dateAdapter = new Object() {
|
||||
@ToJson Long dateToJson(Date d) {
|
||||
return d.getTime();
|
||||
|
@ -185,7 +185,7 @@ public final class ObjectAdapterTest {
|
|||
*/
|
||||
@Test public void objectAdapterDelegatesStringNamesAndValues() throws Exception {
|
||||
JsonAdapter<String> stringAdapter = new JsonAdapter<String>() {
|
||||
@Nullable @Override public String fromJson(JsonReader reader) throws IOException {
|
||||
@Override public String fromJson(JsonReader reader) throws IOException {
|
||||
return reader.nextString().toUpperCase(Locale.US);
|
||||
}
|
||||
|
||||
|
@ -198,8 +198,9 @@ public final class ObjectAdapterTest {
|
|||
.add(String.class, stringAdapter)
|
||||
.build();
|
||||
JsonAdapter<Object> objectAdapter = moshi.adapter(Object.class);
|
||||
Map<?, ?> value = (Map<?, ?>) objectAdapter.fromJson("{\"a\":\"b\", \"c\":\"d\"}");
|
||||
assertThat(value).containsExactly(entry("A", "B"), entry("C", "D"));
|
||||
Map<String, String> value
|
||||
= (Map<String, String>) objectAdapter.fromJson("{\"a\":\"b\", \"c\":\"d\"}");
|
||||
assertThat(value).containsExactly(new SimpleEntry<>("A", "B"), new SimpleEntry<>("C", "D"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,7 +242,7 @@ public final class ObjectAdapterTest {
|
|||
/** Confirm that the built-in adapter for Object delegates to user-supplied adapters for lists. */
|
||||
@Test public void objectAdapterDelegatesLists() throws Exception {
|
||||
JsonAdapter<List<?>> listAdapter = new JsonAdapter<List<?>>() {
|
||||
@Override public @Nullable List<?> fromJson(JsonReader reader) throws IOException {
|
||||
@Override public List<?> fromJson(JsonReader reader) throws IOException {
|
||||
reader.skipValue();
|
||||
return singletonList("z");
|
||||
}
|
||||
|
@ -262,7 +263,7 @@ public final class ObjectAdapterTest {
|
|||
/** Confirm that the built-in adapter for Object delegates to user-supplied adapters for maps. */
|
||||
@Test public void objectAdapterDelegatesMaps() throws Exception {
|
||||
JsonAdapter<Map<?, ?>> mapAdapter = new JsonAdapter<Map<?, ?>>() {
|
||||
@Override public @Nullable Map<?, ?> fromJson(JsonReader reader) throws IOException {
|
||||
@Override public Map<?, ?> fromJson(JsonReader reader) throws IOException {
|
||||
reader.skipValue();
|
||||
return singletonMap("x", "y");
|
||||
}
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -29,8 +29,8 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.7</java.version>
|
||||
<kotlin.version>1.2.21</kotlin.version>
|
||||
<kotlin-metadata.version>1.3.0</kotlin-metadata.version>
|
||||
<kotlin.version>1.2.71</kotlin.version>
|
||||
<kotlin-metadata.version>1.4.0</kotlin-metadata.version>
|
||||
<dokka.version>0.9.17</dokka.version>
|
||||
<maven-assembly.version>3.1.0</maven-assembly.version>
|
||||
|
||||
|
@ -38,9 +38,9 @@
|
|||
<okio.version>1.15.0</okio.version>
|
||||
|
||||
<!-- Test Dependencies -->
|
||||
<compile-testing.version>0.8</compile-testing.version>
|
||||
<compile-testing.version>0.15</compile-testing.version>
|
||||
<junit.version>4.12</junit.version>
|
||||
<assertj.version>1.7.0</assertj.version>
|
||||
<assertj.version>3.11.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
|
Loading…
Reference in a new issue