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

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


    public void setTestCases(List<TestCase> testCases) {
      this.testCases = testCases;
    }

    public LongneckProcess() {
        topLevelBlocks = new Sequence();
    }
View Full Code Here


public class KernelTest {
   
    public static Sequence createIfSequence(FrameAddressResolver far) {
       
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
        If ifBlock = new If();
        seq.setBlocks(Arrays.asList(new Block[] { ifBlock }));
       
        EqualsConstraint equals = new EqualsConstraint();
        equals.setApplyTo("a");
        equals.setValue("aaa");
        ifBlock.setConstraints(Arrays.asList(new Constraint[] { equals }));
       
        Sequence thenBranch = new Sequence();
        thenBranch.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(thenBranch);
        Set setbThen = new Set();
        setbThen.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 3, 3, 0));
        setbThen.setApplyTo("b");
        setbThen.setValue("then");       
        thenBranch.setBlocks(Arrays.asList(new Block[] { setbThen }));
        ifBlock.setThenBranch(thenBranch);
       
        Sequence elseBranch = new Sequence();
        elseBranch.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 4, 4, 0));
        far.put(elseBranch);
        Set setbElse = new Set();
        setbElse.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 5, 5, 0));
        setbElse.setApplyTo("b");
        setbElse.setValue("else");       
        elseBranch.setBlocks(Arrays.asList(new Block[] { setbElse }));
        ifBlock.setElseBranch(elseBranch);

        return seq;
    }
View Full Code Here

    @Test
    public void testIfThen() throws FailException, FilterException {       
        FrameAddressResolver far = new FrameAddressResolver();
       
        // Create an if sequence
        Sequence seq = createIfSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "aaa"));
       
        Kernel kernel = new Kernel(seq, far, null);
View Full Code Here

    @Test
    public void testIfElse() throws FailException, FilterException {       
        FrameAddressResolver far = new FrameAddressResolver();
       
        // Create an if sequence
        Sequence seq = createIfSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(seq, far, null);
View Full Code Here

        assertEquals("else", rec.get("b").getValue())
    }
   
    public static Sequence createSwitchStrictSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        SwitchStrict ss = new SwitchStrict();
        ss.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(ss);
       
        // 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 check
        Check c3check = new Check();
        c3check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 12, 12, 0));
        far.put(c3check);
       
        EqualsConstraint c3equals = new EqualsConstraint();
        c3equals.setApplyTo("a");
        c3equals.setValue("ccc");
        c3check.setConstraints(Arrays.asList(new Constraint[] { c3equals }));
       
        // 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[] { c3check, 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
        ss.setCases(Arrays.asList(new Case[] { c1, c2, c3 }));
        // Add blocks to top-level sequence       
        seq.setBlocks(Arrays.asList(new Block[] { ss, afterSet }));
       
        return seq;
    }
View Full Code Here

    }
   
    @Test
    public void testSwitchStrictCase1() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchStrictSequence(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 testSwitchStrictCase2() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchStrictSequence(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 testSwitchStrictCase3() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchStrictSequence(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 testSwitchStrictAllCasesFail() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createSwitchStrictSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "ddd"));
       
        Kernel kernel = new Kernel(tested, far, null);
View Full Code Here

        assertFalse(rec.has("after"));
    }

    public static Sequence createSwitchSequence(FrameAddressResolver far) {
        // Create an if sequence
        Sequence seq = new Sequence();
        seq.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 1, 1, 0));
        far.put(seq);
       
        Switch sw = new Switch();
        sw.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(sw);
       
        // 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 check
        Check c3check = new Check();
        c3check.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 12, 12, 0));
        far.put(c3check);
       
        EqualsConstraint c3equals = new EqualsConstraint();
        c3equals.setApplyTo("a");
        c3equals.setValue("ccc");
        c3check.setConstraints(Arrays.asList(new Constraint[] { c3equals }));
       
        // 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[] { c3check, 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
        sw.setCases(Arrays.asList(new Case[] { c1, c2, c3 }));
        // Add blocks to top-level sequence       
        seq.setBlocks(Arrays.asList(new Block[] { sw, afterSet }));
       
        return seq;
    }
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.