Package com.asakusafw.testdriver.core

Examples of com.asakusafw.testdriver.core.DataModelReflection


        DataModelSourceProvider provider = new SpiDataModelSourceProvider(getClass().getClassLoader());
        URI uri = new URI("windgate:" + MockImporter.class.getName());
        ValueDefinition<String> definition = ValueDefinition.of(String.class);
        DataModelSource source = provider.open(definition, uri, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(definition.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(definition.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(definition.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here


        DataModelSourceProvider provider = new SpiDataModelSourceProvider(getClass().getClassLoader());
        URI uri = new URI("windgate:" + MockExporter.class.getName());
        ValueDefinition<String> definition = ValueDefinition.of(String.class);
        DataModelSource source = provider.open(definition, uri, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(definition.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(definition.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(definition.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

                driver);
        WindGateExporterRetriever retriever = new WindGateExporterRetriever();
        ValueDefinition<String> stringDef = ValueDefinition.of(String.class);
        DataModelSource source = retriever.createSource(stringDef, description, EMPTY);
        try {
            DataModelReflection r1 = source.next();
            assertThat(r1, is(notNullValue()));
            assertThat(stringDef.toObject(r1), is("Hello1, world!"));

            DataModelReflection r2 = source.next();
            assertThat(r2, is(notNullValue()));
            assertThat(stringDef.toObject(r2), is("Hello2, world!"));

            DataModelReflection r3 = source.next();
            assertThat(r3, is(notNullValue()));
            assertThat(stringDef.toObject(r3), is("Hello3, world!"));

            DataModelReflection r4 = source.next();
            assertThat(r4, is(nullValue()));
        } finally {
            source.close();
        }
    }
View Full Code Here

        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("number", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

        assertThat(object.number, is(100));
        assertThat(object.text, is("Hello, world!"));
    }
View Full Code Here

        DataModelDefinition<Simple> def = new SimpleDataModelDefinition<Simple>(Simple.class);
        JsonObject json = new JsonObject();
        json.addProperty("invalid", 100);
        json.addProperty("text", "Hello, world!");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

        assertThat(object.number, is(nullValue()));
        assertThat(object.text, is("Hello, world!"));
    }
View Full Code Here

        json.addProperty("double_value", 1.5d);
        json.addProperty("big_decimal_value", new BigDecimal("12.3456"));
        json.addProperty("date_value", "2012-01-02");
        json.addProperty("datetime_value", "2011-12-31 10:20:30");

        DataModelReflection ref = JsonObjectDriver.convert(def, json);
        Simple object = def.toObject(ref);

        assertThat(object.booleanValue, is(true));
        assertThat(object.byteValue, is((byte) 100));
        assertThat(object.shortValue, is((short) 200));
View Full Code Here

    private List<String> get(DataModelSource input) throws IOException {
        try {
            MockTextDefinition def = new MockTextDefinition();
            List<String> results = new ArrayList<String>();
            while (true) {
                DataModelReflection next = input.next();
                if (next == null) {
                    break;
                }
                results.add(def.toObject(next).toString());
            }
View Full Code Here

        try {
            Set<Object> set = new HashSet<Object>(expected);
            DataModelSource source = target.createSource(def, CONTEXT);
            try {
                while (true) {
                    DataModelReflection next = source.next();
                    if (next == null) {
                        break;
                    }
                    T object = def.toObject(next);
                    assertThat(object.toString(), set.contains(object), is(true));
View Full Code Here

        URI uri = uri("data/workbook.xls", "no such sheet");
        provider.open(SIMPLE, uri, new TestContext.Empty());
    }

    private Simple next(DataModelSource source) throws IOException {
        DataModelReflection next = source.next();
        assertThat(next, is(not(nullValue())));
        return SIMPLE.toObject(next);
    }
View Full Code Here

        assertThat(next, is(not(nullValue())));
        return SIMPLE.toObject(next);
    }

    private void end(DataModelSource source) throws IOException {
        DataModelReflection next = source.next();
        assertThat(String.valueOf(next), next, nullValue());
        source.close();
    }
View Full Code Here

TOP

Related Classes of com.asakusafw.testdriver.core.DataModelReflection

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.