-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JUnit tests for graalvm js script evaluator.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.lsc.utils; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import mockit.Mocked; | ||
import mockit.NonStrictExpectations; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.lsc.Task; | ||
import org.lsc.configuration.*; | ||
import org.lsc.exception.LscServiceConfigurationException; | ||
import org.lsc.exception.LscServiceException; | ||
import org.lsc.jndi.SimpleJndiSrcService; | ||
|
||
import java.util.*; | ||
|
||
public class ScriptingEvaluatorTest { | ||
|
||
@Mocked Task task; | ||
|
||
@Before | ||
public void setUp() throws LscServiceConfigurationException { | ||
new NonStrictExpectations() { | ||
{ | ||
TaskType taskConf = LscConfiguration.getTask("ldap2ldapTestTask"); | ||
task.getSourceService(); result = new SimpleJndiSrcService(taskConf); | ||
} | ||
}; | ||
} | ||
|
||
@Test | ||
public void testString() throws LscServiceException { | ||
String expression = "gjs:dn='ou=test-user' + ',ou=people,dc=example,dc=com'"; | ||
String stringOutput = ScriptingEvaluator.evalToString(task, expression, new HashMap<>()); | ||
assertEquals("ou=test-user,ou=people,dc=example,dc=com", stringOutput); | ||
} | ||
|
||
@Test | ||
public void testBoolean() throws LscServiceException { | ||
String expression = "gjs:booleanVariable=true"; | ||
boolean booleanOutput = ScriptingEvaluator.evalToBoolean(task, expression, new HashMap<>()); | ||
assertTrue(booleanOutput); | ||
} | ||
} |