Search in sources :

Example 16 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testgetResourceIcfConfigurationPropertyValueStringHost.

@Test
public void testgetResourceIcfConfigurationPropertyValueStringHost() throws Exception {
    final String TEST_NAME = "testgetResourceIcfConfigurationPropertyValueStringHost";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<ResourceType> resource = PrismTestUtil.parseObject(RESOURCE_OPENDJ_FILE);
    // WHEN
    String val = f.getResourceIcfConfigurationPropertyValue(resource.asObjectable(), "host");
    // THEN
    assertEquals("Wrong value of ICF configuration property", "localhost", 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)

Example 17 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testDetermineLdapSingleAttributeValue01.

@Test
public void testDetermineLdapSingleAttributeValue01() throws Exception {
    final String TEST_NAME = "testDetermineLdapSingleAttributeValue01";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    String dn = "uid=foo, 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", "foo", 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 18 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testGetAttributeValueDefaultRi.

@Test
public void testGetAttributeValueDefaultRi() throws Exception {
    final String TEST_NAME = "testGetAttributeValueDefaultRi";
    TestUtil.displayTestTile(TEST_NAME);
    // GIVEN
    BasicExpressionFunctions f = createBasicFunctions();
    PrismObject<ShadowType> accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE);
    // WHEN
    String attrVal = f.getAttributeValue(accountJack.asObjectable(), 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 19 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testDetermineLdapSingleAttributeValueSingle.

/**
     * Single value is always returned regardless of DN
     */
@Test
public void testDetermineLdapSingleAttributeValueSingle() throws Exception {
    System.out.println("\n===[ testDetermineLdapSingleAttributeValueSingle ]===\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, values);
    // THEN
    assertNotNull("Result value is null", resultValue);
    System.out.println("Resulting value: " + resultValue);
    assertEquals("Wrong result value", "heh", 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 20 with BasicExpressionFunctions

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

the class TestExpressionFunctions method testComposeDn.

@Test
public void testComposeDn() throws Exception {
    final String TEST_NAME = "testComposeDn";
    TestUtil.displayTestTile(TEST_NAME);
    BasicExpressionFunctions basic = createBasicFunctions();
    assertEquals("cn=foo,o=bar", basic.composeDn("cn", "foo", "o", "bar"));
    assertEquals("cn=foo,o=bar", basic.composeDn("cn", PrismTestUtil.createPolyString("foo"), "o", "bar"));
    assertEquals("cn=foo,o=bar", basic.composeDn("cn", PrismTestUtil.createPolyStringType("foo"), "o", "bar"));
    assertEquals("cn=foo,o=bar", basic.composeDn("cn", "foo", new Rdn("o", "bar")));
    assertEquals("cn=foo,ou=baz,o=bar", basic.composeDn(new Rdn("cn", "foo"), "ou", "baz", new Rdn("o", "bar")));
    assertEquals("cn=foo,ou=baz,o=bar", basic.composeDn(new Rdn("cn", "foo"), "ou", "baz", "o", "bar"));
    assertEquals("cn=foo,ou=baz,o=bar", basic.composeDn(new Rdn("cn", "foo"), new LdapName("ou=baz,o=bar")));
    assertEquals("cn=foo,ou=baz,o=bar", basic.composeDn("cn", "foo", new LdapName("ou=baz,o=bar")));
    assertEquals("cn=foo\\,foo,ou=baz,o=bar", basic.composeDn("cn", "foo,foo", new LdapName("ou=baz,o=bar")));
    assertEquals("cn=foo\\=foo,ou=baz,o=bar", basic.composeDn("cn", "foo=foo", new LdapName("ou=baz,o=bar")));
    assertEquals(null, basic.composeDn(null));
    assertEquals(null, basic.composeDn());
    assertEquals(null, basic.composeDn(""));
    assertEquals(null, basic.composeDn("   "));
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Rdn(javax.naming.ldap.Rdn) LdapName(javax.naming.ldap.LdapName) 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