Skip to content

Commit

Permalink
JUnit tests for graalvm js script evaluator.
Browse files Browse the repository at this point in the history
  • Loading branch information
abpai94 committed Sep 11, 2024
1 parent 2a2e23f commit 6cc9492
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/test/java/org/lsc/utils/ScriptingEvaluatorTest.java
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);
}
}

0 comments on commit 6cc9492

Please sign in to comment.