Created
July 11, 2014 07:22
-
-
Save cikasfm/4f28e986a5a9a03e5cea to your computer and use it in GitHub Desktop.
Verifies MVEL "contains" operator behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static org.junit.Assert.*; | |
import java.util.*; | |
import org.junit.Test; | |
import org.mvel2.MVEL; | |
/** | |
* @author Zilvinas Vilutis | |
* @since 6.1 | |
* | |
*/ | |
public class MvelTest { | |
/** | |
* Test method for {@link org.mvel2.MVEL#eval(String, Map)}. | |
*/ | |
@Test | |
public final void testContainsExpression() { | |
final Map<String, String> params = new HashMap<String, String>(); | |
final String expression = "{ 'firstName', 'middleName', 'lastName' } contains updatedFieldName"; | |
params.put( "updatedFieldName", "firstName" ); | |
assertTrue( ( Boolean ) MVEL.eval( expression, params ) ); | |
params.put( "updatedFieldName", "middleName" ); | |
assertTrue( ( Boolean ) MVEL.eval( expression, params ) ); | |
params.put( "updatedFieldName", "lastName" ); | |
assertTrue( ( Boolean ) MVEL.eval( expression, params ) ); | |
params.put( "updatedFieldName", "address" ); | |
assertFalse( ( Boolean ) MVEL.eval( expression, params ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment