Search in sources :

Example 11 with BasicExpressionFunctions

use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.

the class TestExpressionFunctions method testParseDateTime.

@Test
public void testParseDateTime() throws Exception {
    final String TEST_NAME = "testParseDateTime";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    // WHEN
    XMLGregorianCalendar resultValue = f.parseDateTime("yyyy MM dd HH:mm:ss.SSS zzzz", "1975 05 30 22:30:00.000 Central European Time");
    // THEN
    assertNotNull("Result value is null", resultValue);
    System.out.println("Resulting value: " + resultValue);
    XMLGregorianCalendar xmlCal = XmlTypeConverter.createXMLGregorianCalendar(1975, 5, 30, 21, 30, 0);
    assertEquals("Wrong result value", xmlCal, 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 12 with BasicExpressionFunctions

use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.

the class TestExpressionFunctions method testGetExtensionPropertyValueNotPresent.

@Test
public void testGetExtensionPropertyValueNotPresent() throws Exception {
    final String TEST_NAME = "testGetExtensionPropertyValueNotPresent";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<UserType> userJack = PrismTestUtil.parseObject(USER_JACK_FILE);
    // WHEN
    String extensionVal = f.getExtensionPropertyValue(userJack.asObjectable(), new QName(SchemaTestConstants.NS_EXTENSION, "kajdsfhklfdsjh"));
    // THEN
    assertNull("Unexpected value for extension " + SchemaTestConstants.EXTENSION_SHIP_ELEMENT + ": " + extensionVal, extensionVal);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) QName(javax.xml.namespace.QName) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 13 with BasicExpressionFunctions

use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.

the class TestExpressionFunctions method testToAscii.

@Test
public void testToAscii() throws Exception {
    final String TEST_NAME = "testToAscii";
    TestUtil.displayTestTile(TEST_NAME);
    BasicExpressionFunctions basic = createBasicFunctions();
    assertEquals("foo", basic.toAscii("foo"));
    assertEquals("foo", basic.toAscii(poly("foo")));
    assertEquals("foo", basic.toAscii(PrismTestUtil.createPolyStringType("foo")));
    assertEquals("Cortuv hrad, tam Strasa!", basic.toAscii("Čórtův hrád, tam Strašá!"));
    assertEquals("hrabe Teleke z Toloko", basic.toAscii(poly("hrabě Teleke z Tölökö")));
    assertEquals("Vedeckotechnicka revoluce neni zadna idyla!", basic.toAscii(PrismTestUtil.createPolyStringType("Vědeckotechnická revoluce není žádná idyla!")));
    assertEquals(null, basic.toAscii(null));
    assertEquals("", basic.toAscii(""));
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 14 with BasicExpressionFunctions

use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.

the class TestExpressionFunctions method testGetExtensionPropertyValue.

@Test
public void testGetExtensionPropertyValue() throws Exception {
    final String TEST_NAME = "testGetExtensionPropertyValue";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<UserType> userJack = PrismTestUtil.parseObject(USER_JACK_FILE);
    // WHEN
    String shipExtension = f.getExtensionPropertyValue(userJack.asObjectable(), SchemaTestConstants.EXTENSION_SHIP_ELEMENT);
    // THEN
    assertEquals("Wrong value for extension " + SchemaTestConstants.EXTENSION_SHIP_ELEMENT, "Black Pearl", shipExtension);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 15 with BasicExpressionFunctions

use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.

the class TestExpressionFunctions method testGetExtensionPropertyValueParts.

@Test
public void testGetExtensionPropertyValueParts() throws Exception {
    final String TEST_NAME = "testGetExtensionPropertyValueParts";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<UserType> userJack = PrismTestUtil.parseObject(USER_JACK_FILE);
    // WHEN
    String shipExtension = f.getExtensionPropertyValue(userJack.asObjectable(), SchemaTestConstants.EXTENSION_SHIP_ELEMENT.getNamespaceURI(), SchemaTestConstants.EXTENSION_SHIP_ELEMENT.getLocalPart());
    // THEN
    assertEquals("Wrong value for extension " + SchemaTestConstants.EXTENSION_SHIP_ELEMENT, "Black Pearl", shipExtension);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) 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