Package hu.sztaki.ilab.longneck

Examples of hu.sztaki.ilab.longneck.RecordImpl


    @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);
        kernel.process(rec);

        assertTrue(rec.has("after"));
    }
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);
        kernel.process(rec);
       
        assertTrue(rec.has("b"));
        assertEquals("case3", rec.get("b").getValue())
       
        // Case 1 and case 3 was run
        assertTrue(rec.has("c1"));
        assertEquals("case1", rec.get("c1").getValue())
       
        assertFalse(rec.has("c2"));
       
        assertTrue(rec.has("c3"));
        assertEquals("case3", rec.get("c3").getValue())
       
        // After set was run
        assertTrue(rec.has("after"));
    }
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);
        kernel.process(rec);
       
        assertTrue(rec.has("b"));
        assertEquals("case3", rec.get("b").getValue())
       
        // Only case 2 was run
        assertTrue(rec.has("c2"));
        assertEquals("case2", rec.get("c2").getValue())
       
        assertFalse(rec.has("c1"));
       
        assertTrue(rec.has("c3"));
        assertEquals("case3", rec.get("c3").getValue())
       
        // After set was run
        assertTrue(rec.has("after"));
    }
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);
        kernel.process(rec);
       
        assertTrue(rec.has("b"));
        assertEquals("case3", rec.get("b").getValue())
       
        // Only case 3 was run
        assertTrue(rec.has("c3"));
        assertEquals("case3", rec.get("c3").getValue());
       
        assertFalse(rec.has("c1"));
        assertFalse(rec.has("c2"));
       
        // After set was run
        assertTrue(rec.has("after"));
    }
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);
        kernel.process(rec);
       
        assertTrue(rec.has("b"));
        assertEquals("b2", rec.get("b").getValue());
        assertTrue(rec.has("c"));
        assertEquals("b1", rec.get("c").getValue());
        assertTrue(rec.has("d"));
        assertEquals("b2", rec.get("d").getValue());
    }
View Full Code Here

    @Test
    public void testBlockReferenceSupressError() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createBlockRefSuppressErrorSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
        kernel.process(rec);
       
        assertTrue("Check fields set by b1", rec.has("b"));
        assertEquals("Check fields set by b1", "b1", rec.get("b").getValue());
       
        assertTrue("Check fields set by b1", rec.has("c"));
        assertEquals("Check fields set by b1", "b1", rec.get("c").getValue());
       
        assertFalse("Check that b2 did not set fields", rec.has("d"));
    }
View Full Code Here

    @Test
    public void createBlockRefPropagateErrorSequence() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createBlockRefPropagateErrorSequence(far);
       
        Record rec = new RecordImpl();
        rec.add(new Field("a", "bbb"));
       
        Kernel kernel = new Kernel(tested, far, null);
        kernel.process(rec);
       
        // Check fields set by b1 before reference
        assertTrue("Check fields set by b1 before reference", rec.has("b"));
        assertEquals("Check fields set by b1 before reference", "b1", rec.get("b").getValue());
       
        // Check that field after reference was not set
        assertFalse("Check that field after reference was not set", rec.has("c"));
       
        // Check that b2 did not set fields
        assertFalse("Check that b2 did not set fields", rec.has("d"));
    }
View Full Code Here

    @Test
    public void testMatchExtract() throws FailException, FilterException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createMatchExtractSequence(far);

        Record rec = new RecordImpl();
        rec.add(new Field("a", "abc"));

        Kernel kernel = new Kernel(tested, far, null);
        kernel.process(rec);

        assertTrue("First regexp group exists.", rec.has("var1"));
        assertEquals("First regexp group is correctly extracted", "a", rec.get("var1").getValue());

        assertTrue("Second regexp group exists.", rec.has("var2"));
        assertEquals("Second regexp group is correctly extracted", "b", rec.get("var2").getValue());

        assertTrue("Third regexp group exists.", rec.has("var3"));
        assertEquals("Third regexp group is correctly extracted", "c", rec.get("var3").getValue());
    }
View Full Code Here

        filter.setSourceInfo(new SourceInfo("file:///dummy.xml", null, 2, 2, 0));
        far.put(filter);

        seq.setBlocks(Arrays.asList(new Block[]{filter}));

        Record rec = new RecordImpl();
        rec.add(new Field("a", "abc"));

        Kernel kernel = new Kernel(seq, far, null);

        try {
            kernel.process(rec);
View Full Code Here

    public void testMapping() throws FailException {
        FrameAddressResolver far = new FrameAddressResolver();
        Sequence tested = createMappingTestSequence1(far);
        List<Record> localCloneQueue = new ArrayList<>();

        Record record = new RecordImpl();
        record.add(new Field("a", "a1"));

        Kernel kernel = new Kernel(tested, far, localCloneQueue);

        try {
            kernel.process(record);
        } catch (FailException | FilterException e) {
            fail();
        }

        // record out test
        assertTrue("Check field exist: a", record.has("a"));
        assertEquals("Check field value: a", "b2", record.get("a").getValue());

        assertTrue("Check field exist: c", record.has("c"));
        assertEquals("Check field value: c", "ok", record.get("c").getValue());

        assertTrue("Check that another field isn't exist.", record.getFields().size() == 2);


        // test clone1:
        Record clone1 = localCloneQueue.get(1);
        assertTrue("Check field exist: b", clone1.has("b"));
        assertEquals("Check field value: b", "b3", clone1.get("b").getValue());

        assertTrue("Check field exist: f", clone1.has("f"));
        assertEquals("Check field value: f", "ok", clone1.get("f").getValue());
       
        assertTrue("Check field exist: a", clone1.has("a"));
        assertEquals("Check field value: a", "error", clone1.get("a").getValue());

        assertTrue("Check that another field isn't exist.", clone1.getFields().size() == 3);
       
        // test clone1 parent
        Record parent1 = ((MappedRecord)clone1).getParent();
        assertTrue("Check field exist: a", parent1.has("a"));
        assertEquals("Check field value: a", "a1", parent1.get("a").getValue());
       
        assertTrue("Check that another field isn't exist.", parent1.getFields().size() == 1);

       
        // test clone2:
        Record clone2 = localCloneQueue.get(0);
        assertTrue("Check field exist: b", clone2.has("b"));
        assertEquals("Check field value: b", "error", clone2.get("b").getValue());

        assertTrue("Check field exist: c", clone2.has("c"));
        assertEquals("Check field value: c", "ok", clone2.get("c").getValue());
       
        assertTrue("Check field exist: a", clone2.has("a"));
        assertEquals("Check field value: a", "error", clone2.get("a").getValue());
       
        assertTrue("Check field exist: d", clone2.has("d"));
        assertEquals("Check field value: d", "b2", clone2.get("d").getValue());
       
        assertTrue("Check field exist: e", clone2.has("e"));
        assertEquals("Check field value: e", "b2", clone2.get("e").getValue());

        assertTrue("Check that another field isn't exist.", clone2.getFields().size() == 5);
       
        // test clone2 parent
        Record parent2 = ((MappedRecord)clone2).getParent();
        assertTrue("Check field exist: b", parent2.has("b"));
        assertEquals("Check field value: b", "b1", parent2.get("b").getValue());
       
        assertTrue("Check that another field isn't exist.", parent2.getFields().size() == 1);
       
        // test clone2 parent's parent
        Record parent3 = ((MappedRecord)parent2).getParent();
        assertTrue("Check field exist: a", parent3.has("a"));
        assertEquals("Check field value: a", "a1", parent3.get("a").getValue());
       
        assertTrue("Check that another field isn't exist.", parent3.getFields().size() == 1);
       
        // test clone2 out
        try {
            kernel.process(clone2);
            // Beacause the cloned records
            if (clone2 instanceof MappedRecord) {
                record = ((MappedRecord) clone2).getAncestor();
            }
        } catch (FailException | FilterException e) {
            fail();
        }
        assertTrue("Check field exist: a", record.has("a"));
        assertEquals("Check field value: a", "b2", record.get("a").getValue());

        assertTrue("Check field exist: c", record.has("c"));
        assertEquals("Check field value: c", "ok", record.get("c").getValue());

        assertTrue("Check that another field isn't exist.", record.getFields().size() == 2);
       
        // test clone1 out
        try {
            kernel.process(clone1);
            // Beacause the cloned records
            if (clone1 instanceof MappedRecord) {
                record = ((MappedRecord) clone1).getAncestor();
            }
        } catch (FailException | FilterException e) {
            fail();
        }
        assertTrue("Check field exist: a", record.has("a"));
        assertEquals("Check field value: a", "b3", record.get("a").getValue());

        assertTrue("Check field exist: c", record.has("c"));
        assertEquals("Check field value: c", "ok", record.get("c").getValue());

        assertTrue("Check that another field isn't exist.", record.getFields().size() == 2);
       
        // test clone2 cloned record cloned by clone1 record out
        Record clone3 = localCloneQueue.get(2);
        try {
            kernel.process(clone3);
            // Beacause the cloned records
            if (clone3 instanceof MappedRecord) {
                record = ((MappedRecord) clone3).getAncestor();
            }
        } catch (FailException | FilterException e) {
            fail();
        }
        assertTrue("Check field exist: a", record.has("a"));
        assertEquals("Check field value: a", "b3", record.get("a").getValue());

        assertTrue("Check field exist: c", record.has("c"));
        assertEquals("Check field value: c", "ok", record.get("c").getValue());

        assertTrue("Check that another field isn't exist.", record.getFields().size() == 2);
    }
View Full Code Here

TOP

Related Classes of hu.sztaki.ilab.longneck.RecordImpl

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.