Package org.amplafi.flow.flowproperty

Examples of org.amplafi.flow.flowproperty.FlowPropertyDefinitionImpl


     */
    @Test(enabled=TEST_ENABLED)
    public void testDefaultHandlingWithAutoCreate() throws Exception {
        FlowPropertyProvider flowPropertyProvider = null;

        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("foo");
        new FlowTestingUtils().resolveAndInit(definition);
        assertFalse(definition.isAutoCreate());
        definition.initDefaultObject(Boolean.TRUE);
        assertEquals(definition.getDataClass(), Boolean.class);

        new FlowTestingUtils().resolveAndInit(definition);
        Boolean t = (Boolean) definition.parse(flowPropertyProvider, null);
        assertNull(t);
        t = (Boolean) definition.getDefaultObject(new Dummy());
        assertEquals(t, Boolean.TRUE);
        assertTrue(definition.isAutoCreate());

        // check behavior if everything is not defined in the Ctor call
        // (i.e. like the definition is being defined in the hivemind.xml)
        definition = new FlowPropertyDefinitionImpl("foo");
        definition.setDefaultObject("true");
        definition.setDataClass(Boolean.class);
        new FlowTestingUtils().resolveAndInit(definition);
        t = (Boolean) definition.parse(flowPropertyProvider, null);
        assertNull(t);
        t = (Boolean) definition.getDefaultObject(new Dummy());
        assertEquals(t, Boolean.TRUE);
        assertTrue(definition.isAutoCreate());

        final FlowPropertyDefinitionImpl definition1 = new FlowPropertyDefinitionImpl("foo");
        definition1.setFlowPropertyValueProvider(new FlowPropertyValueProvider<FlowPropertyProvider>() {
            @Override
            @SuppressWarnings({ "unchecked" })
            public <T> T get(FlowPropertyProvider flowActivity, FlowPropertyDefinition flowPropertyDefinition) {
                assertSame(flowPropertyDefinition, definition1);
                return (T) Boolean.TRUE;
View Full Code Here


        assertEquals(t, Boolean.TRUE);
        assertTrue(definition.isAutoCreate());
    }

    private void assertDefaultObject(Class<?> clazz, Object value) {
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("u", clazz, FlowActivityPhase.advance);
        new FlowTestingUtils().resolveAndInit(definition);
        assertEquals(definition.getDefaultObject(new Dummy()), value);
    }
View Full Code Here

    /**
     * Check merging with no collection types
     */
    @Test(enabled=TEST_ENABLED)
    public void testFlowPropertyDefinitionSimpleMerging() {
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("foo", Boolean.class);
        FlowPropertyDefinitionImpl definition1 = new FlowPropertyDefinitionImpl("foo", Boolean.class).initDefaultObject(true);
        assertTrue( definition.isMergeable(definition1));
        assertTrue( definition1.isMergeable(definition));
        definition.merge(definition1);
        new FlowTestingUtils().resolveAndInit(definition);
        assertTrue((Boolean)definition.getDefaultObject(new Dummy()));
        assertEquals(definition.getDataClass(), definition1.getDataClass());
    }
View Full Code Here

        assertEquals(definition.getDataClass(), definition1.getDataClass());
    }

    @Test(enabled=TEST_ENABLED)
    public void testFlowPropertyDefinitionComplexMergingBecauseOfDataClass() {
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl("foo", Boolean.class, Set.class);
        FlowPropertyDefinitionImpl definition1 = new FlowPropertyDefinitionImpl("foo", Boolean.class).initDefaultObject(true);
        assertFalse( definition.isMergeable(definition1));
        assertFalse( definition1.isMergeable(definition));

        // definition with unknown element in a set should be able to merge with a set that has a defined element type.
        FlowPropertyDefinitionImpl definition2 = new FlowPropertyDefinitionImpl("foo", null, Set.class);
        assertTrue( definition.isMergeable(definition2));

        // merge check will be false because List and Boolean are not assignable between each other.
        FlowPropertyDefinitionImpl definition3 = new FlowPropertyDefinitionImpl("foo", Long.class, Set.class, List.class);
        assertFalse( definition.isMergeable(definition3));
        assertTrue(definition2.isMergeable(definition3));
        assertTrue(definition3.isMergeable(definition2));

        FlowPropertyDefinitionImpl definition4 = new FlowPropertyDefinitionImpl("foo", Boolean.class, Map.class);
        assertFalse(definition4.isMergeable(definition));
        assertFalse(definition4.isMergeable(definition3));
        FlowPropertyDefinitionImpl definition5 = new FlowPropertyDefinitionImpl("foo", Boolean.class, Map.class, Set.class);
        FlowPropertyDefinitionImpl definition6 = new FlowPropertyDefinitionImpl("foo", null, Map.class, Set.class);
        assertTrue(definition5.isMergeable(definition6));
        assertTrue(definition6.isMergeable(definition5));
    }
View Full Code Here

        assertFalse(dataClassDefinition.isMap());
    }

    @Test(enabled=TEST_ENABLED)
    public void testFlowPropertyDefinitionCloning() {
        FlowPropertyDefinitionImpl original = new FlowPropertyDefinitionImpl("foo", Boolean.class, FlowActivityPhase.advance, Set.class, List.class);
        FlowPropertyDefinitionImpl cloned = new FlowPropertyDefinitionImpl(original);
        assertEquals(original, cloned, "cloning failed");
    }
View Full Code Here

     * Test some values to make sure that the serialization /parse operations end up with the original result.
     * @param original
     */
    @Test(enabled=TEST_ENABLED, dataProvider="serializationData")
    public void testSerializeAndParse(String original) {
        FlowPropertyDefinitionImpl def = new FlowPropertyDefinitionImpl("test");
        FlowPropertyProvider flowPropertyProvider = null;

        String result = def.parse(flowPropertyProvider, def.serialize(original));
        assertEquals(result, original);
    }
View Full Code Here

    @Test(enabled=TEST_ENABLED)
    @SuppressWarnings("unchecked")
    public void testListCollectionHandling() throws Exception {
        FlowPropertyProvider flowPropertyProvider = null;

        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl(URI, URI.class, FlowActivityPhase.advance, List.class);
        new FlowTestingUtils().resolveAndInit(definition);
        List<URI> list = Arrays.asList(new URI("http://foo.com"), new URI("http://gg.gov"));
        String strV = definition.serialize(list);
        assertEquals(strV, "[\"http://foo.com\",\"http://gg.gov\"]");
        List<URI> result = (List<URI>) definition.parse(flowPropertyProvider, strV);
        assertTrue(list.containsAll(result));
        assertTrue(result.containsAll(list));
    }
View Full Code Here

     */
    @Test(enabled=TEST_ENABLED)
    @SuppressWarnings("unchecked")
    public void testSetCollectionHandling() throws Exception {
        FlowPropertyProvider flowPropertyProvider = null;
        FlowPropertyDefinitionImpl definition = new FlowPropertyDefinitionImpl(URI, URI.class, FlowActivityPhase.advance, Set.class);
        new FlowTestingUtils().resolveAndInit(definition);
        Set<URI> set = new LinkedHashSet<URI>(Arrays.asList(new URI("http://foo.com"), new URI("http://gg.gov")));
        String strV = definition.serialize(set);
        assertEquals(strV, "[\"http://foo.com\",\"http://gg.gov\"]");
        Set<URI> result = (Set<URI>) definition.parse(flowPropertyProvider, strV);
        assertTrue(set.containsAll(result));
        assertTrue(set.containsAll(set));
    }
View Full Code Here

TOP

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

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.