Package org.amplafi.json

Examples of org.amplafi.json.JSONWriter


    @BeforeMethod()
    protected void setUpObjects() {
        renderer = new JavascriptDateOutputRenderer();
        result = new StringWriter();
        jsonWriter = new JSONWriter(result);
    }
View Full Code Here


    @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

    public void testCompleteFlowState() {
        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\"}}}");
    }
View Full Code Here

        flowState.finishFlow();
        return flowState;
    }
    private JSONWriter getJsonWriter() {
        MapJsonRenderer mapJsonRenderer = new MapJsonRenderer();
        JSONWriter jsonWriter = new JSONStringer();
        jsonWriter.addRenderer(FlowValidationResultJsonRenderer.INSTANCE);
        jsonWriter.addRenderer(FlowValidationTrackingJsonRenderer.INSTANCE);
        jsonWriter.addRenderer(new FlowStateJsonRenderer(true));
        jsonWriter.addRenderer(mapJsonRenderer);
        return jsonWriter;
    }
View Full Code Here

    private FlowValidationTrackingJsonRenderer flowValidationTrackingJsonRenderer = new FlowValidationTrackingJsonRenderer();

    @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();
        assertEquals(jsonWriter.toString(),"{\"validation\":{}}");
    }
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();
        jsonWriter.object().key("validation").value(single).endObject();
        assertEquals(jsonWriter.toString(),
        "{\"validation\":{\"flowValidationTracking\":[{\"key\":\"foo\",\"parameters\":[\"foo\"]}]}}");
    }
View Full Code Here

        assertEquals(jsonWriter.toString(),
        "{\"validation\":{\"flowValidationTracking\":[{\"key\":\"foo\",\"parameters\":[\"foo\"]}]}}");
    }

    private JSONWriter getJsonWriter() {
        JSONWriter jsonWriter = new JSONStringer();
        jsonWriter.addRenderer(flowValidationResultJsonRenderer);
        jsonWriter.addRenderer(flowValidationTrackingJsonRenderer);
        return jsonWriter;
    }
View Full Code Here

TOP

Related Classes of org.amplafi.json.JSONWriter

Copyright © 2018 www.massapicom. 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.