Package hu.sztaki.ilab.longneck

Source Code of hu.sztaki.ilab.longneck.SetCharacterCaseTest

package hu.sztaki.ilab.longneck;

import hu.sztaki.ilab.longneck.process.BlockError;
import hu.sztaki.ilab.longneck.process.VariableSpace;
import hu.sztaki.ilab.longneck.process.block.SetCharacterCase;
import hu.sztaki.ilab.longneck.process.constraint.CharacterCase;
import hu.sztaki.ilab.longneck.process.constraint.CharacterTarget;
import java.util.Arrays;
import junit.framework.Assert;
import org.junit.Test;

/**
*
* @author Molnár Péter <molnarp@sztaki.mta.hu>
*/
public class SetCharacterCaseTest {
   
    @Test
    public void testCase1() throws BlockError {
        Record r = new RecordImpl();
        VariableSpace scope = new VariableSpace();
       
        r.add(new Field("test"));
        r.get("test").setValue("NAgy HAjnalka");
       
        SetCharacterCase scc = new SetCharacterCase();
        scc.setCase(CharacterCase.Lowercase);
        scc.setCharacters(CharacterTarget.ALL);
        scc.setApplyTo(Arrays.asList(new String[] { "test" }));
       
        scc.apply(r, scope);
       
        scc.setCase(CharacterCase.Uppercase);
        scc.setCharacters(CharacterTarget.TOKEN_INITIALS_NON_ALNUM);
        scc.setApplyTo(Arrays.asList(new String[] { "test" }));
       
        scc.apply(r, scope);
       
        Assert.assertEquals("Nagy Hajnalka", r.get("test").getValue());
    }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.