Search in sources :

Example 1 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testGetAttributeValueParts.

@Test
public void testGetAttributeValueParts() throws Exception {
    final String TEST_NAME = "testGetAttributeValueParts";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<ShadowType> accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE);
    // WHEN
    String attrVal = f.getAttributeValue(accountJack.asObjectable(), MidPointConstants.NS_RI, ATTR_FULLNAME_LOCAL_PART);
    // THEN
    assertEquals("Wrong value for attribute " + ATTR_FULLNAME_LOCAL_PART, "Jack Sparrow", attrVal);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 2 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testDetermineLdapSingleAttributeValueFallback.

@Test
public void testDetermineLdapSingleAttributeValueFallback() throws Exception {
    System.out.println("\n===[ testDetermineLdapSingleAttributeValueFallback ]===\n");
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    String dn = "cn=jack, ou=People, dc=example,dc=com";
    String attributeName = "uid";
    Collection<String> values = MiscUtil.createCollection("foo", "bar", "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", "bar", 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 3 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testGetExtensionPropertyValueNullObject.

@Test
public void testGetExtensionPropertyValueNullObject() throws Exception {
    final String TEST_NAME = "testGetExtensionPropertyValueNullObject";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    // WHEN
    String shipExtension = f.getExtensionPropertyValue(null, SchemaTestConstants.EXTENSION_SHIP_ELEMENT);
    // THEN
    assertNull("Unexpected value for extension " + SchemaTestConstants.EXTENSION_SHIP_ELEMENT + ": " + shipExtension, shipExtension);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 4 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testParseFullName.

@Test
public void testParseFullName() throws Exception {
    final String TEST_NAME = "testParseFullName";
    TestUtil.displayTestTile(TEST_NAME);
    BasicExpressionFunctions basic = createBasicFunctions();
    assertEquals(null, basic.parseGivenName(null));
    assertEquals(null, basic.parseGivenName("   "));
    assertEquals("Jack", basic.parseGivenName("Jack Sparrow"));
    assertEquals("Jack", basic.parseGivenName(" Jack     Sparrow  "));
    assertEquals("Jack", basic.parseGivenName(new PolyString("Jack Sparrow")));
    assertEquals("Sparrow", basic.parseFamilyName("Jack Sparrow"));
    assertEquals("Sparrow", basic.parseFamilyName("   Jack    Sparrow   "));
    assertEquals("Tim", basic.parseGivenName("Tim Berners-Lee"));
    assertEquals("Berners-Lee", basic.parseFamilyName("Tim Berners-Lee"));
    assertEquals("Cassius", basic.parseGivenName("Cassius Marcellus \"Muhammad Ali\" Clay, Jr."));
    assertEquals("Marcellus", basic.parseAdditionalName("Cassius Marcellus \"Muhammad Ali\" Clay, Jr."));
    assertEquals("Clay", basic.parseFamilyName("Cassius Marcellus \"Muhammad Ali\" Clay, Jr."));
    assertEquals("Muhammad Ali", basic.parseNickName("Cassius Marcellus \"Muhammad Ali\" Clay, Jr."));
    assertEquals("Jr.", basic.parseHonorificSuffix("Cassius Marcellus \"Muhammad Ali\" Clay, Jr."));
    assertEquals("Radovan", basic.parseGivenName("Ing. Radovan Semančík, PhD."));
    assertEquals("Semančík", basic.parseFamilyName("Ing. Radovan Semančík, PhD."));
    assertEquals("Ing.", basic.parseHonorificPrefix("Ing. Radovan Semančík, PhD."));
    assertEquals("PhD.", basic.parseHonorificSuffix("Ing. Radovan Semančík, PhD."));
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 5 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testgetResourceIcfConfigurationPropertyValueStringPort.

@Test
public void testgetResourceIcfConfigurationPropertyValueStringPort() throws Exception {
    final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringPort";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE);
    // WHEN
    int val = f.getResourceIcfConfigurationPropertyValue(resource.asObjectable(), "port");
    // THEN
    assertEquals("Wrong value of ICF configuration property", 10389, val);
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) 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