Minor clean-up of warnings (in 1.5) and added new test for non-Empty maps.

This commit is contained in:
Joel Leitch 2011-02-11 18:22:58 +00:00
parent 451a9dbe66
commit 69661216a3
3 changed files with 15 additions and 3 deletions

View File

@ -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));
}
}

View File

@ -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;

View File

@ -107,7 +107,6 @@ public class ExclusionStrategyFunctionalTest extends TestCase {
// Field tag only annotation
}
@SuppressWarnings("unused")
private static class SampleObjectForTest {
@Foo
private final int annotatedField;