assertEquals(jsonWriter.toString(),"{\"validation\":{}}");
}
@Test
public void testValidationErrors() throws Exception {
ReportAllValidationResult reportAll = new ReportAllValidationResult();
FlowValidationTracking[] flowValidationTrackings = new FlowValidationTracking[] {
EasyMock.createMock(FlowValidationTracking.class),
EasyMock.createMock(FlowValidationTracking.class)
};
for(int i =0 ; i < flowValidationTrackings.length; i++) {
flowValidationTrackings[i] = EasyMock.createMock(FlowValidationTracking.class);
EasyMock.expect(flowValidationTrackings[i].getMessageKey()).andReturn(Integer.toString(i)).anyTimes();
EasyMock.expect(flowValidationTrackings[i].getMessageParameters()).andReturn(new String[] {
i+" error-1",
i+" error-2"
}).anyTimes();
}
EasyMock.replay(flowValidationTrackings);
reportAll.addTracking(flowValidationTrackings[0]);
reportAll.addTracking(flowValidationTrackings[1]);
JSONWriter jsonWriter = getJsonWriter();
jsonWriter.object().key("validation").value(reportAll).endObject();
assertEquals(jsonWriter.toString(),
"{\"validation\":{\"flowValidationTracking\":[{\"key\":\"0\",\"parameters\":[\"0 error-1\",\"0 error-2\"]},{\"key\":\"1\",\"parameters\":[\"1 error-1\",\"1 error-2\"]}]}}");
ReportAllValidationResult single = new ReportAllValidationResult().addTracking(false, "activityKey", "foo", "foo");
jsonWriter = getJsonWriter();
jsonWriter.object().key("validation").value(single).endObject();
assertEquals(jsonWriter.toString(),
"{\"validation\":{\"flowValidationTracking\":[{\"key\":\"foo\",\"parameters\":[\"foo\"]}]}}");
}