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

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


public class CutTest  extends AbstractBlockTest {
   
   
    @Test
    public void testUnmarshal() throws SAXException, IOException, MarshalException, ValidationException, Exception {
        Cut cut = new Cut();
       
        List<String> applyTo = new ArrayList<String>(3);
        applyTo.add("a");
        applyTo.add("b");
        applyTo.add("c");
       
        cut.setApplyTo(applyTo);
        cut.setValue(4);
       
        // Load document
        Document doc = documentBuilder.parse(classLoader.getResourceAsStream("unmarshal/cut.xml"));
       
        // Unmarshal document
        LongneckProcess process = (LongneckProcess) unmarshaller.unmarshal(doc);
       
        Assert.assertTrue((process.getBlocks().get(0) instanceof Cut));
       
        Cut testedCut = (Cut) process.getBlocks().get(0);
        Assert.assertEquals(cut.getApplyTo(), testedCut.getApplyTo());
        Assert.assertEquals(cut.getValue(), testedCut.getValue());
    }
View Full Code Here


        Assert.assertEquals(cut.getValue(), testedCut.getValue());
    }
   
    @Test
    public void testCut() throws BlockError {
        Cut cut = new Cut();
       
        List<String> applyTo = new ArrayList<String>(3);
        applyTo.add("a");
        applyTo.add("b");
       
        cut.setApplyTo(applyTo);
        cut.setValue(4);
       
        // Prepare record
        RecordImpl r = new RecordImpl();
        r.add(new Field("a", "aaaaaa"));
        r.add(new Field("b", "bbbbb"));
        r.add(new Field("c", "cccc"));
        r.add(new Field("d", "ddd"));
       
      
        // Perform copy
        cut.apply(r, new VariableSpace());
       
        Assert.assertEquals("aaaa", r.get("a").getValue());
        Assert.assertEquals("bbbb", r.get("b").getValue());
        Assert.assertEquals("cccc", r.get("c").getValue());       
        Assert.assertEquals("ddd", r.get("d").getValue());       
View Full Code Here

    }
   
    @Test
    public void testNonexistingApplyToIdentifier() throws BlockError {
        try {
            Cut cut = new Cut();

            List<String> applyTo = new ArrayList<String>(3);
            applyTo.add("i");

            cut.setApplyTo(applyTo);
            cut.setValue(4);

            // Prepare record
            RecordImpl r = new RecordImpl();
            r.add(new Field("a", "aaaaaa"));
            r.add(new Field("b", "bbbbb"));
            r.add(new Field("c", "cccc"));
            r.add(new Field("d", "ddd"));


            // Perform copy
            cut.apply(r, new VariableSpace());

            Assert.assertEquals("aaaaaa", r.get("a").getValue());
            Assert.assertEquals("bbbbb", r.get("b").getValue());
            Assert.assertEquals("cccc", r.get("c").getValue());
            Assert.assertEquals("ddd", r.get("d").getValue());
View Full Code Here

    }
   
    @Test
    public void testNegativeValue() throws BlockError {
        try {
            Cut cut = new Cut();

            List<String> applyTo = new ArrayList<String>(3);
            applyTo.add("a");

            cut.setApplyTo(applyTo);
            cut.setValue(-56);

            // Prepare record
            RecordImpl r = new RecordImpl();
            r.add(new Field("a", "aaaaaa"));
            r.add(new Field("b", "bbbbb"));
            r.add(new Field("c", "cccc"));
            r.add(new Field("d", "ddd"));


            // Perform copy
            cut.apply(r, new VariableSpace());

            Assert.assertEquals("", r.get("a").getValue());
        } catch (Exception ex) {
            Assert.fail("Method must not raise exception.");
        }
View Full Code Here

TOP

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

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.