use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testConcatName.
@Test
public void testConcatName() throws Exception {
final String TEST_NAME = "testConcatName";
TestUtil.displayTestTile(TEST_NAME);
BasicExpressionFunctions basic = createBasicFunctions();
assertEquals("foo bar", basic.concatName("foo", "bar"));
assertEquals("foo bar", basic.concatName(poly("foo"), "bar"));
assertEquals("foo bar", basic.concatName("foo", poly("bar")));
assertEquals("foo", basic.concatName("foo", ""));
assertEquals("foo", basic.concatName("foo", null));
assertEquals("foo bar", basic.concatName("foo", null, "bar"));
assertEquals("foo bar", basic.concatName("foo", "", "bar"));
assertEquals("foo bar", basic.concatName("foo ", "bar"));
assertEquals("foo bar", basic.concatName("foo", " bar"));
assertEquals("foo bar", basic.concatName(" foo ", " bar "));
assertEquals("foo bar", basic.concatName(" foo ", null, " bar "));
assertEquals("foo bar", basic.concatName(" foo ", " ", " bar "));
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testComposeDnWithSuffix.
@Test
public void testComposeDnWithSuffix() throws Exception {
final String TEST_NAME = "testComposeDnWithSuffix";
TestUtil.displayTestTile(TEST_NAME);
BasicExpressionFunctions basic = createBasicFunctions();
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix(new Rdn("cn", "foo"), "ou=baz,o=bar"));
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix(new Rdn("cn", "foo"), new LdapName("ou=baz,o=bar")));
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo", "ou=baz,o=bar"));
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", PrismTestUtil.createPolyString("foo"), "ou=baz,o=bar"));
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", PrismTestUtil.createPolyStringType("foo"), "ou=baz,o=bar"));
assertEquals("cn=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo", new LdapName("ou=baz,o=bar")));
assertEquals("cn=foo,ou=baz\\,baz,o=bar", basic.composeDnWithSuffix("cn", "foo", "ou=baz\\,baz,o=bar"));
assertEquals("cn=foo,ou=baz\\,baz,o=bar", basic.composeDnWithSuffix("cn", "foo", new LdapName("ou=baz\\,baz,o=bar")));
assertEquals("cn=foo\\,foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo,foo", "ou=baz,o=bar"));
assertEquals("cn=foo\\,foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo,foo", new LdapName("ou=baz,o=bar")));
assertEquals("cn=foo\\=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo=foo", "ou=baz,o=bar"));
assertEquals("cn=foo\\=foo,ou=baz,o=bar", basic.composeDnWithSuffix("cn", "foo=foo", new LdapName("ou=baz,o=bar")));
assertEquals("ou=baz,o=bar", basic.composeDnWithSuffix("ou=baz,o=bar"));
assertEquals("ou=baz, o=bar", basic.composeDnWithSuffix("ou=baz, o=bar"));
assertEquals("OU=baz, o=bar", basic.composeDnWithSuffix("OU=baz, o=bar"));
assertEquals("ou=baz,o=bar", basic.composeDnWithSuffix(new LdapName("ou=baz,o=bar")));
assertEquals(null, basic.composeDnWithSuffix(null));
assertEquals(null, basic.composeDnWithSuffix());
assertEquals(null, basic.composeDnWithSuffix(""));
assertEquals(null, basic.composeDnWithSuffix(" "));
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testGetAttributeValuesParts.
@Test
public void testGetAttributeValuesParts() throws Exception {
final String TEST_NAME = "testGetAttributeValuesParts";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
PrismObject<ShadowType> accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE);
// WHEN
Collection<String> attrVals = f.getAttributeValues(accountJack.asObjectable(), MidPointConstants.NS_RI, ATTR_WEAPON_LOCAL_PART);
// THEN
TestUtil.assertSetEquals("Wrong value for attribute " + ATTR_WEAPON_LOCAL_PART, attrVals, "rum", "smell");
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testStringify.
@Test
public void testStringify() throws Exception {
final String TEST_NAME = "testStringifyString";
TestUtil.displayTestTile(TEST_NAME);
BasicExpressionFunctions basic = createBasicFunctions();
assertEquals("foo", basic.stringify("foo"));
assertEquals("foo", basic.stringify(poly("foo")));
assertEquals("foo", basic.stringify(PrismTestUtil.createPolyStringType("foo")));
assertEquals("42", basic.stringify(42));
assertEquals("", basic.stringify(null));
assertEquals("", basic.stringify(""));
}
use of com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions in project midpoint by Evolveum.
the class TestExpressionFunctions method testGetAttributeValuesDefaultRi.
@Test
public void testGetAttributeValuesDefaultRi() throws Exception {
final String TEST_NAME = "testGetAttributeValuesDefaultRi";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
BasicExpressionFunctions f = createBasicFunctions();
PrismObject<ShadowType> accountJack = PrismTestUtil.parseObject(ACCOUNT_JACK_FILE);
// WHEN
Collection<String> attrVals = f.getAttributeValues(accountJack.asObjectable(), ATTR_WEAPON_LOCAL_PART);
// THEN
TestUtil.assertSetEquals("Wrong value for attribute " + ATTR_WEAPON_LOCAL_PART, attrVals, "rum", "smell");
}
Aggregations