use of siena.Json in project siena by mandubian.
the class JsonTest method testSumDoubles.
public void testSumDoubles() {
Json map1 = Json.map().put("a", 1.5);
Json map2 = Json.map().put("a", 2.5).put("b", 5);
map1.sumReals(map2);
assertEquals(4, map1.get("a").asInt());
assertEquals(5, map1.get("b").asInt());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testIndexOf.
public void testIndexOf() {
Json json = Json.list(1, 2, 3, "hello", true, false, null);
assertEquals(0, json.indexOf(1));
assertEquals(1, json.indexOf(2));
assertEquals(2, json.indexOf(3));
assertEquals(3, json.indexOf("hello"));
assertEquals(4, json.indexOf(true));
assertEquals(5, json.indexOf(false));
assertEquals(6, json.indexOf(null));
}
use of siena.Json in project siena by mandubian.
the class User method testSimple.
public void testSimple() throws Exception {
Date date = createDate();
Json data = JsonSerializer.serialize(new Contact("Alberto", "Gimeno", Gender.MALE, date, date));
Contact contact = (Contact) JsonSerializer.deserialize(Contact.class, data);
assertEquals("Alberto", contact.firstName);
assertNull(contact.foo);
assertEquals("Gimeno", contact.lastName);
assertEquals(Gender.MALE, contact.gender);
assertEquals(date, contact.birthday);
assertEquals(date, contact.rebirthday);
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testRemoveAll.
public void testRemoveAll() {
Json list = Json.list(1, 2, 3);
list.removeAll(Json.list(1, 2));
assertEquals(1, list.size());
assertEquals(3, list.at(0).asInt());
Json map = Json.map().put("foo", 1).put("bar", 2);
map.removeAll(Json.map().put("foo", 1));
assertEquals(1, map.size());
assertEquals(2, map.get("bar").asInt());
}
use of siena.Json in project siena by mandubian.
the class JsonTest method testBuildEmptyMap.
public void testBuildEmptyMap() {
Json json = Json.map();
assertTrue(json.isMap());
assertTrue(json.isEmpty());
assertFalse(json.isBoolean());
assertFalse(json.isList());
assertFalse(json.isNumber());
assertFalse(json.isString());
assertEquals(0, json.size());
assertEquals("{}", json.toString());
}
Aggregations