Package org.amplafi.json

Examples of org.amplafi.json.JSONWriter.object()


    @Test
    public void testSimpleFlowState() {
        FlowStateImpl flowState = newFlowState();
        flowState.clearLookupKey();
        JSONWriter jsonWriter = getJsonWriter();
        jsonWriter.object().key("flowState").value(flowState).endObject();
        assertEquals(jsonWriter.toString(), "{\"flowState\":{\""+FlowStateJsonRenderer.FS_COMPLETE+"\":true,\"" +
                FlowStateJsonRenderer.FS_PARAMETERS+"\":{}" +
            "}}");

    }
View Full Code Here


        FlowStateImpl flowState = newFlowState();
        flowState.setRawProperty("property1", "value1");
        flowState.setRawProperty("property2", "value2");
        flowState.clearLookupKey();
        JSONWriter jsonWriter = getJsonWriter();
        jsonWriter.object().key("flowState").value(flowState).endObject();
        assertEquals(jsonWriter.toString(), "{\"flowState\":{\""+FlowStateJsonRenderer.FS_COMPLETE+"\":true,\""+
                FlowStateJsonRenderer.FS_PARAMETERS+"\":{\"property1\":\"value1\",\"property2\":\"value2\"}}}");
    }

    private FlowStateImpl newFlowState() {
View Full Code Here

    @Test
    public void testNoValidationErrors() throws Exception {
        ReportAllValidationResult reportAll = new ReportAllValidationResult();
        JSONWriter jsonWriter = getJsonWriter();
        jsonWriter.object().key("validation").value(reportAll).endObject();
        assertEquals(jsonWriter.toString(),"{\"validation\":{}}");

        ReportAllValidationResult single = new ReportAllValidationResult().addTracking(true, "activityKey", "foo");
        jsonWriter = getJsonWriter();
        jsonWriter.object().key("validation").value(single).endObject();
View Full Code Here

        jsonWriter.object().key("validation").value(reportAll).endObject();
        assertEquals(jsonWriter.toString(),"{\"validation\":{}}");

        ReportAllValidationResult single = new ReportAllValidationResult().addTracking(true, "activityKey", "foo");
        jsonWriter = getJsonWriter();
        jsonWriter.object().key("validation").value(single).endObject();
        assertEquals(jsonWriter.toString(),"{\"validation\":{}}");
    }

    @Test
    public void testValidationErrors() throws Exception {
View Full Code Here

        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();
View Full Code Here

        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\"]}]}}");
    }

    private JSONWriter getJsonWriter() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.