Search in sources :

Example 21 with BasicExpressionFunctions

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);
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 22 with BasicExpressionFunctions

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);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 23 with BasicExpressionFunctions

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);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PrismContext(com.evolveum.midpoint.prism.PrismContext) ProtectorImpl(com.evolveum.midpoint.prism.crypto.ProtectorImpl) Protector(com.evolveum.midpoint.prism.crypto.Protector)

Example 24 with BasicExpressionFunctions

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);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Aggregations

BasicExpressionFunctions (com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions)24 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)23 Test (org.testng.annotations.Test)23 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)4 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 LdapName (javax.naming.ldap.LdapName)2 Rdn (javax.naming.ldap.Rdn)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 PrismContext (com.evolveum.midpoint.prism.PrismContext)1 Protector (com.evolveum.midpoint.prism.crypto.Protector)1 ProtectorImpl (com.evolveum.midpoint.prism.crypto.ProtectorImpl)1 QName (javax.xml.namespace.QName)1