Package org.amplafi.flow.validation

Examples of org.amplafi.flow.validation.ReportAllValidationResult


        }
        return pageName;
    }

    public FlowValidationResult getFullFlowValidationResult(FlowActivityPhase flowActivityPhase, FlowStepDirection flowStepDirection) {
        FlowValidationResult flowValidationResult = new ReportAllValidationResult();
        // TODO : need to account for properties that earlier activities will create the property required by a later property.
        // we should look for PropertyUsage.create (and equivalents )
        for(FlowActivity flowActivity: this.getActivities()) {
            FlowValidationResult flowActivityValidationResult  = flowActivity.getFlowValidationResult(flowActivityPhase, flowStepDirection);
            flowValidationResult.merge(flowActivityValidationResult);
        }
        return flowValidationResult;
    }
View Full Code Here


    private FlowValidationResultJsonRenderer flowValidationResultJsonRenderer = new FlowValidationResultJsonRenderer();
    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

        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\"]}]}}");
    }
View Full Code Here

* Tests for {@link ReportAllValidationResult}.
*/
@Test
public class TestReportAllValidationResult extends Assert {
    public void testNothingAdded() {
        ReportAllValidationResult result = new ReportAllValidationResult().addTracking(true, "activityKey", "key");
        assertTrue(result.isValid());

        ReportAllValidationResult result2 = new ReportAllValidationResult().addTracking(true, "activityKey", "key", "val");
        assertTrue(result2.isValid());
    }
View Full Code Here

        assertTrue(result2.isValid());
    }

    public void testOneError() {
        FlowValidationResult result =
                new ReportAllValidationResult().addTracking(false, "activityKey", "key", "val").addTracking(false, "activityKey", "key2");
        assertFalse(result.isValid());
    }
View Full Code Here

                new ReportAllValidationResult().addTracking(false, "activityKey", "key", "val").addTracking(false, "activityKey", "key2");
        assertFalse(result.isValid());
    }

    public void testAddDifferentTrackings() {
        ReportAllValidationResult result = new ReportAllValidationResult(
                new MissingRequiredTracking("firstname"),
                new InconsistencyTracking("field not a number", "username"),
                new MismatchTracking("field1", "field2"),
                new ExceptionTracking("field", new RuntimeException())
        );

        assertFalse(result.isValid());
        assertEquals(result.getTrackings().size(), 4);
    }
View Full Code Here

        assertFalse(result.isValid());
        assertEquals(result.getTrackings().size(), 4);
    }

    public void testMerge() {
        FlowValidationResult result = new ReportAllValidationResult(
            new MissingRequiredTracking("firstname"));

        FlowValidationResult result1 = new ReportAllValidationResult();
        result1.merge(result);
        assertFalse(result1.isValid());

    }
View Full Code Here

            FlowValidationResult validationResult = flowStepDirection == FlowStepDirection.backward?
                getFlowValidationResult(FlowActivityPhase.advance, flowStepDirection):
                    getFlowValidationResult();
            return validationResult;
        }
        return new ReportAllValidationResult();
    }
View Full Code Here

TOP

Related Classes of org.amplafi.flow.validation.ReportAllValidationResult

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.