Fix a couple of types in tests. (#2317)

These show up with recent Error Prone analyses for Truth. Because the
tests use the overload of `Gson.fromJson` that takes a `Type` argument,
rather than the one with a `TypeToken`, the type mismatches were not
detected by the compiler.
This commit is contained in:
Éamonn McManus 2023-02-15 05:53:29 -08:00 committed by GitHub
parent e8b6fa9287
commit 18bdb6db2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -301,7 +301,7 @@ public class MapTest {
public void testMapStandardSubclassDeserialization() {
String json = "{a:'1',b:'2'}";
Type type = new TypeToken<LinkedHashMap<String, String>>() {}.getType();
LinkedHashMap<String, Integer> map = gson.fromJson(json, type);
LinkedHashMap<String, String> map = gson.fromJson(json, type);
assertThat(map).containsEntry("a", "1");
assertThat(map).containsEntry("b", "2");
}

View File

@ -161,7 +161,7 @@ public class ParameterizedTypesTest {
.create();
Reader json = new StringReader(expected.getExpectedJson());
MyParameterizedType<Integer> actual = gson.fromJson(json, expectedType);
MyParameterizedType<BagOfPrimitives> actual = gson.fromJson(json, expectedType);
assertThat(actual).isEqualTo(expected);
}