Package hu.sztaki.ilab.longneck.process.block

Examples of hu.sztaki.ilab.longneck.process.block.Sequence


    }
   
    @Test
    public void testSwitchCase1() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "aaa"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here


    }
   
    @Test
    public void testSwitchCase2() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

    }
   
    @Test   
    public void testSwitchCase3() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "ccc"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

    }
   
    @Test   
    public void testSwitchAllCasesFail() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "ddd"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

        assertTrue(rec.has("after"));
    }
   
    public static Sequence createTryAllSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        TryAll ta = new TryAll();
        ta.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(ta);
       
        // Case 1
        Case c1 = new Case();
        c1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 3, 3, 0));
        far.put(c1);
       
        // Case 1 check
        Check c1check = new Check();
        c1check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 4, 4, 0));
        far.put(c1check);
       
        EqualsConstraint c1equals = new EqualsConstraint();
        c1equals.setApplyTo("a");
        c1equals.setValue("aaa");
        c1check.setConstraints(Arrays.asList(new Constraint[] { c1equals }));
       
        // Case 1 block
        Set c1set = new Set();
        c1set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 5, 5, 0));
        far.put(c1set);
        c1set.setApplyTo("b");
        c1set.setValue("case1");       
       
        Set c1set2 = new Set();
        c1set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 6, 6, 0));
        far.put(c1set2);
        c1set2.setApplyTo("c1");
        c1set2.setValue("case1");
       
        c1.setBlocks(Arrays.asList(new Block[] { c1check, c1set, c1set2 }));
       
       
        // Case 2
        Case c2 = new Case();
        c2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 7, 7, 0));
        far.put(c2);
       
        // Case 2 check
        Check c2check = new Check();
        c2check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 8, 8, 0));
        far.put(c2check);
       
        EqualsConstraint c2equals = new EqualsConstraint();
        c2equals.setApplyTo("a");
        c2equals.setValue("bbb");
        c2check.setConstraints(Arrays.asList(new Constraint[] { c2equals }));
       
        // Case 2 block
        Set c2set = new Set();
        c2set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 9, 9, 0));
        far.put(c2set);
        c2set.setApplyTo("b");
        c2set.setValue("case2");
       
        Set c2set2 = new Set();
        c2set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 10, 10, 0));
        far.put(c2set2);
        c2set2.setApplyTo("c2");
        c2set2.setValue("case2");
       
        c2.setBlocks(Arrays.asList(new Block[] { c2check, c2set, c2set2 }));

       
        // Case 3
        Case c3 = new Case();
        c3.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 11, 11, 0));
        far.put(c1);
       
        // Case 3 block
        Set c3set = new Set();
        c3set.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 13, 13, 0));
        far.put(c3set);
        c3set.setApplyTo("b");
        c3set.setValue("case3");       
       
        Set c3set2 = new Set();
        c3set2.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 14, 14, 0));
        far.put(c3set2);
        c3set2.setApplyTo("c3");
        c3set2.setValue("case3");
       
        c3.setBlocks(Arrays.asList(new Block[] { c3set, c3set2 }));

        Set afterSet = new Set();
        afterSet.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 15, 15, 0));
        far.put(afterSet);
        afterSet.setApplyTo("after");
        afterSet.setValue("true");

        // Add cases to switch
        ta.setCases(Arrays.asList(new Case[] { c1, c2, c3 }));
        // Add blocks to top-level sequence       
        seq.setBlocks(Arrays.asList(new Block[] { ta, afterSet }));
       
        return seq;
    }
View Full Code Here

    }
   
    @Test
    public void testTryAllCase13() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createTryAllSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "aaa"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

    }
   
    @Test
    public void testTryAllCase23() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createTryAllSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

    }
   
    @Test   
    public void testTryAllCase3() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createTryAllSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "ccc"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

        assertTrue(rec.has("after"));
    }
   
    public static Sequence createBlockRefSequence1(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        // Block 1
        GenericBlock b1 = new GenericBlock();
        b1.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 1, 1, 0));
        b1.setId("b1");
        b1.setVersion("1");
       
        Set b1set = new Set();
        b1set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 2, 2, 0));
        far.put(b1set);
        b1set.setApplyTo("b");
        b1set.setValue("b1");       
       
        BlockReference br2 = new BlockReference();
        br2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 3, 3, 0));
        far.put(br2);
        br2.setId("pkg1:b2");
        br2.setVersion("1");
       
        Set b1set2 = new Set();
        b1set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b1:1", 4, 4, 0));
        far.put(b1set2);
        b1set2.setApplyTo("c");
        b1set2.setValue("b1");
       
        b1.setBlocks(Arrays.asList(new Block[] { b1set, br2, b1set2 }));
       
        // Block 2
        GenericBlock b2 = new GenericBlock();
        b2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", null, 5, 5, 0));
        b2.setId("b2");
        b2.setVersion("1");
       
        Set b2set = new Set();
        b2set.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 6, 6, 0));
        far.put(b2set);
        b2set.setApplyTo("b");
        b2set.setValue("b2");
       
        Set b2set2 = new Set();
        b2set2.setSourceInfo(new SourceInfo("file:///pkg1.blocks.xml", "b2:1", 7, 7, 0));
        far.put(b2set2);
        b2set2.setApplyTo("d");
        b2set2.setValue("b2");
       
        b2.setBlocks(Arrays.asList(new Block[] { b2set, b2set2 }));
        br2.setReferredBlock(b2);
       
       
        BlockReference br1 = new BlockReference();
        br1.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(br1);
        br1.setId("pkg1:b1");
        br1.setVersion("1");
       
        br1.setReferredBlock(b1);
        seq.setBlocks(Arrays.asList(new Block[] { br1 }));
       
        return seq;      
    }
View Full Code Here

    }
   
    @Test
    public void testBlockReference1() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createBlockRefSequence1(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

TOP

Related Classes of hu.sztaki.ilab.longneck.process.block.Sequence

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.