Search in sources :

Example 6 with BasicExpressionFunctions

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        "));
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 7 with BasicExpressionFunctions

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

Example 8 with BasicExpressionFunctions

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");
}
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 9 with BasicExpressionFunctions

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(""));
}
Also used : BasicExpressionFunctions(com.evolveum.midpoint.model.common.expression.functions.BasicExpressionFunctions) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 10 with BasicExpressionFunctions

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

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