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);
}
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);
}
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);
}
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);
}
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(" "));
}
Aggregations