Minor clean-up of warnings (in 1.5) and added new test for non-Empty maps.
This commit is contained in:
parent
451a9dbe66
commit
69661216a3
@ -58,4 +58,17 @@ public class DefaultMapJsonSerializerTest extends TestCase {
|
||||
JsonObject emptyMapJsonObject = (JsonObject) element;
|
||||
assertTrue(emptyMapJsonObject.entrySet().isEmpty());
|
||||
}
|
||||
|
||||
public void testNonEmptyMapSerialization() {
|
||||
Type mapType = new TypeToken<Map<String, String>>() { }.getType();
|
||||
Map<String, String> myMap = new HashMap<String, String>();
|
||||
String key = "key1";
|
||||
myMap.put(key, "value1");
|
||||
Gson gson = new Gson();
|
||||
JsonElement element = gson.toJsonTree(myMap, mapType);
|
||||
|
||||
assertTrue(element.isJsonObject());
|
||||
JsonObject mapJsonObject = element.getAsJsonObject();
|
||||
assertTrue(mapJsonObject.has(key));
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ public class CollectionTest extends TestCase {
|
||||
assertEquals("[1,2,3,4,5,6,7,8,9]", gson.toJson(target));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRawCollectionSerialization() {
|
||||
BagOfPrimitives bag1 = new BagOfPrimitives();
|
||||
Collection target = Arrays.asList(bag1, bag1);
|
||||
@ -276,7 +276,7 @@ public class CollectionTest extends TestCase {
|
||||
assertTrue(deserializedCollection.contains(objB));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@SuppressWarnings("unchecked")
|
||||
private static int[] toIntArray(Collection collection) {
|
||||
int[] ints = new int[collection.size()];
|
||||
int i = 0;
|
||||
|
@ -107,7 +107,6 @@ public class ExclusionStrategyFunctionalTest extends TestCase {
|
||||
// Field tag only annotation
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static class SampleObjectForTest {
|
||||
@Foo
|
||||
private final int annotatedField;
|
||||
|
Loading…
Reference in New Issue
Block a user