Package org.amplafi.flow.flowproperty

Examples of org.amplafi.flow.flowproperty.DataClassDefinitionImpl


    }
    @Test
    public void testResolvingClassWithCollections() {
        FlowPropertyProvider flowPropertyProvider = null;

        DataClassDefinitionImpl dataClassDefinition = new DataClassDefinitionImpl(Long.class, Set.class);
        getFlowTranslatorResolver().resolve("", dataClassDefinition, true);
        assertEquals(dataClassDefinition.getDataClass(), Set.class);
        assertNotNull(dataClassDefinition.getFlowTranslator());
        assertTrue(dataClassDefinition.getFlowTranslator() instanceof SetFlowTranslator, dataClassDefinition.getFlowTranslator().toString());
        DataClassDefinition elementDataClassDefinition = dataClassDefinition.getElementDataClassDefinition();
        assertNotNull(elementDataClassDefinition);
        assertEquals(elementDataClassDefinition.getDataClass(), Long.class);
        assertNotNull(elementDataClassDefinition.getFlowTranslator());
        assertTrue(elementDataClassDefinition.getFlowTranslator() instanceof LongFlowTranslator, elementDataClassDefinition.getFlowTranslator().toString());

        // verify that the resolved result can do something useful
        Set<Long> result = dataClassDefinition.deserialize(flowPropertyProvider, null, "[34,45,67]");
        assertTrue(result.containsAll(Arrays.asList(34L, 45L, 67L)));
        assertEquals(result.size(), 3);

        String serializedResult = (String) dataClassDefinition.serialize(null, result);
        assertEquals(serializedResult, "[34,45,67]");
    }
View Full Code Here


    }
    @Test
    public void testResolvingClassWithMaps() {
        FlowPropertyProvider flowPropertyProvider = null;

        DataClassDefinitionImpl dataClassDefinition = DataClassDefinitionImpl.map(Long.class, String.class, List.class);
        getFlowTranslatorResolver().resolve("", dataClassDefinition, true);

        assertEquals(dataClassDefinition.getDataClass(), Map.class);
        assertNotNull(dataClassDefinition.getFlowTranslator());
        assertTrue(dataClassDefinition.getFlowTranslator() instanceof MapFlowTranslator, dataClassDefinition.getFlowTranslator().toString());

        // look at the map's values
        DataClassDefinition elementDataClassDefinition = dataClassDefinition.getElementDataClassDefinition();
        assertNotNull(elementDataClassDefinition);
        assertEquals(elementDataClassDefinition.getDataClass(), List.class);
        assertNotNull(elementDataClassDefinition.getFlowTranslator());
        assertTrue(elementDataClassDefinition.getFlowTranslator() instanceof ListFlowTranslator,
                   elementDataClassDefinition.getFlowTranslator().toString());
        assertNotNull(elementDataClassDefinition.getElementDataClassDefinition().getFlowTranslator());
        assertTrue(elementDataClassDefinition.getElementDataClassDefinition().getFlowTranslator() instanceof CharSequenceFlowTranslator,
                   elementDataClassDefinition.getElementDataClassDefinition().getFlowTranslator().toString());

        // look at the maps's keys
        assertNotNull(dataClassDefinition.getKeyDataClassDefinition());
        assertNotNull(dataClassDefinition.getKeyDataClassDefinition().getFlowTranslator());
        assertTrue(dataClassDefinition.getKeyDataClassDefinition().getFlowTranslator() instanceof LongFlowTranslator);

        // verify that the result can be used.
        Map<Long, List<String>> map = new LinkedHashMap<Long, List<String>>();
        List<String> expected34 = Arrays.asList("foo34", "bar34");
        map.put(new Long(34), expected34);
        List<String> expected3 = Arrays.asList("foo3", "bar3");
        map.put(new Long(3), expected3);

        String serializedResult = (String) dataClassDefinition.serialize(null, map);
        assertEquals(serializedResult, "{\"34\":[\"foo34\",\"bar34\"],\"3\":[\"foo3\",\"bar3\"]}");
        Map<Long, List<String>> reMap = dataClassDefinition.deserialize(flowPropertyProvider, null, serializedResult);
        assertEquals(reMap.size(), 2);
        List<String> set34 = reMap.get(new Long(34));
        List<String> set3 = reMap.get(new Long(3));
        assertTrue(set34.containsAll(expected34));
        assertTrue(set3.containsAll(expected3));
View Full Code Here

* Test {@link DataClassDefinitionImpl}.
*/
public class TestDataClassDefinition {
    @Test
    public void testMap() {
        DataClassDefinitionImpl def = DataClassDefinitionImpl.map(Integer.class, String.class);
        assertEquals(def.getCollection(), Map.class);
        assertEquals(def.getDataClass(), Map.class);
        assertEquals(def.getKeyDataClassDefinition().getDataClass(), Integer.class);
        assertEquals(def.getElementDataClassDefinition().getDataClass(), String.class);
    }
View Full Code Here

    }

    @Override
    protected DataClassDefinitionImpl createDataClassDefinition() {
        FlowTranslator flowTranslator = createFlowTranslator();
        DataClassDefinitionImpl dataClassDefinition = new DataClassDefinitionImpl(Subject.class);
        dataClassDefinition.setFlowTranslator(flowTranslator);
        return dataClassDefinition;
    }
View Full Code Here

    @DataProvider(name="flowTranslatorExpectations")
    protected abstract Object[][] getFlowTranslatorExpectations();

    protected DataClassDefinitionImpl createDataClassDefinition() {
        FlowTranslator<T> flowTranslator = createFlowTranslator();
        DataClassDefinitionImpl dataClassDefinition = new DataClassDefinitionImpl(flowTranslator.getTranslatedClass());
        dataClassDefinition.setFlowTranslator(flowTranslator);
        return dataClassDefinition;
    }
View Full Code Here

        assertTrue(definition6.isMergeable(definition5));
    }

    @Test(enabled=TEST_ENABLED)
    public void testDataClassDefinition() {
        DataClassDefinitionImpl dataClassDefinition =
            new DataClassDefinitionImpl(Boolean.class, Set.class);
        assertEquals(dataClassDefinition.getElementDataClassDefinition().getDataClass(), Boolean.class);
        assertEquals(dataClassDefinition.getDataClass(), Set.class);
    }
View Full Code Here

        assertEquals(dataClassDefinition.getDataClass(), Set.class);
    }

    @Test(enabled=TEST_ENABLED)
    public void testDataClassDefinitionCollection() {
        DataClassDefinitionImpl dataClassDefinition =
            new DataClassDefinitionImpl(Boolean.class, Set.class);
        assertTrue(dataClassDefinition.isCollection());
        dataClassDefinition =
            new DataClassDefinitionImpl(Set.class);
        assertTrue(dataClassDefinition.isCollection());
        assertFalse(dataClassDefinition.isMap());

        dataClassDefinition =
            new DataClassDefinitionImpl(Map.class);
        assertTrue(dataClassDefinition.isCollection());
        assertTrue(dataClassDefinition.isMap());
        assertEquals(dataClassDefinition.getDataClass(), Map.class );
        dataClassDefinition =
            new DataClassDefinitionImpl(List.class);
        assertTrue(dataClassDefinition.isCollection());
        assertFalse(dataClassDefinition.isMap());
    }
View Full Code Here

TOP

Related Classes of org.amplafi.flow.flowproperty.DataClassDefinitionImpl

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.