use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testFormatDateTime.
@Test
public void testFormatDateTime() throws Exception {
System.out.println("\n===[ testFormatDateTime ]===\n");
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
// don't use GMT (offset 0) because serialized value is then in local time
XMLGregorianCalendar xmlCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 22, 30, 0, 0, DatatypeConstants.FIELD_UNDEFINED);
// WHEN
// don't include timezone in the format string, it is hard to check then
String resultValue = f.formatDateTime("yyyy MM dd HH:mm:ss.SSS", xmlCal);
// THEN
assertNotNull("Result value is null", resultValue);
System.out.println("Resulting value: " + resultValue);
assertEquals("Wrong result value", "1975 05 30 22:30:00.000", resultValue);
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testDetermineLdapSingleAttributeValue02.
@Test
public void testDetermineLdapSingleAttributeValue02() throws Exception {
System.out.println("\n===[ testDetermineLdapSingleAttributeValue02 ]===\n");
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
String dn = "cn=jack+uid=FooBAR, ou=People, dc=example,dc=com";
String attributeName = "uid";
Collection<String> values = MiscUtil.createCollection("bar", "foo", "FooBAR");
// WHEN
String resultValue = f.determineLdapSingleAttributeValue(dn, attributeName, values);
// THEN
assertNotNull("Result value is null", resultValue);
System.out.println("Resulting value: " + resultValue);
assertEquals("Wrong result value", "FooBAR", resultValue);
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method createBasicFunctions.
private BasicExpressionFunctions createBasicFunctions() throws SchemaException, SAXException, IOException {
PrismContext prismContext = PrismTestUtil.createInitializedPrismContext();
Protector protector = new ProtectorImpl();
return new BasicExpressionFunctions(prismContext, protector);
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testDetermineLdapSingleAttributeValueNull.
@Test
public void testDetermineLdapSingleAttributeValueNull() throws Exception {
System.out.println("\n===[ testDetermineLdapSingleAttributeValueNull ]===\n");
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
String dn = "cn=jack+uid=FooBar, ou=People, dc=example,dc=com";
String attributeName = "uid";
Collection<String> values = MiscUtil.createCollection("heh");
// WHEN
String resultValue = f.determineLdapSingleAttributeValue(dn, attributeName, null);
// THEN
System.out.println("Resulting value: " + resultValue);
assertNull("Result value is not null", resultValue);
}
Aggregations