public void shouldCallJsonSerialization() { String expectedResult = "{\"message\":{\"category\":\"success\",\"message\":\"Just another {0} in {1}\"}}"; serialization.from("success", "message.cat").as(json()); writer.flush();
public void serialize(Report report, ExportFormat format) { SerializedReport content = content(report, format); result.use(Results.json()).withoutRoot().from(content).serialize(); }
protected <T extends Serializable> void success(T data, String message) { this.result.use(Results.json()) .withoutRoot() .from(new Response<T>(true, message, null, data)) .recursive().serialize(); this.result.nothing(); }
protected <T extends Serializable> void success(List<T> list, Long total, String message) { this.result.use(Results.json()) .withoutRoot() .from(new ListResponse<T>(true, message, null, list, total)) .recursive().serialize(); this.result.nothing(); }
@Test public void shouldReturnStringWithObjectSerialized() throws Exception { Car car = new Car("XXU-5569", "Caelum", "VW", "Polo"); String expectedResult = "{\"car\":{\"licensePlate\":\"XXU-5569\",\"owner\":\"Caelum\",\"make\":\"VW\",\"model\":\"Polo\"}}"; result.use(json()).from(car).serialize(); Assert.assertThat(result.serializedResult(), is(equalTo(expectedResult))); } }
@Test public void shouldNotThrowNullPointersOnJsonResult() throws Exception { result.use(json()).withoutRoot().from("abc").exclude("aaa").include("aaa").serialize(); } @Test