Search in sources :

Example 1 with TestPersonAttributesGroupTestDefinition

use of org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition in project uPortal by Jasig.

the class InvertedRegexTesterTest method testRegexPatterns.

@Test
public void testRegexPatterns() {
    InvertedRegexTester tester = new InvertedRegexTester(new TestPersonAttributesGroupTestDefinition("fakeAttribute", "^02([A-D])*"));
    Assert.assertFalse(tester.test("02A"));
    Assert.assertFalse(tester.test("02ABCD"));
    Assert.assertTrue(tester.test("A02D"));
    Assert.assertFalse(tester.test("02"));
    Assert.assertTrue(tester.test("02MisMatch"));
    Assert.assertTrue(tester.test("PatternWillNeverMatch"));
}
Also used : TestPersonAttributesGroupTestDefinition(org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition) Test(org.junit.Test)

Example 2 with TestPersonAttributesGroupTestDefinition

use of org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition in project uPortal by Jasig.

the class LowercasedRegexTesterTest method testRegexPatterns.

@Test
public void testRegexPatterns() {
    LowercasedRegexTester tester = new LowercasedRegexTester(new TestPersonAttributesGroupTestDefinition("fakeAttribute", "^02([a-d])*"));
    Assert.assertTrue(tester.test("02A"));
    Assert.assertTrue(tester.test("02ABCD"));
    Assert.assertFalse(tester.test("A02D"));
    Assert.assertTrue(tester.test("02"));
    Assert.assertFalse(tester.test("02MisMatch"));
    Assert.assertFalse(tester.test("PatternWillNeverMatch"));
}
Also used : TestPersonAttributesGroupTestDefinition(org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition) Test(org.junit.Test)

Example 3 with TestPersonAttributesGroupTestDefinition

use of org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition in project uPortal by Jasig.

the class RegexTesterTest method testRegexPatterns.

@Test
public void testRegexPatterns() {
    RegexTester tester = new RegexTester(new TestPersonAttributesGroupTestDefinition("fakeAttribute", "^02([A-D])*"));
    Assert.assertTrue(tester.test("02A"));
    Assert.assertTrue(tester.test("02ABCD"));
    Assert.assertFalse(tester.test("A02D"));
    Assert.assertTrue(tester.test("02"));
    Assert.assertFalse(tester.test("02MisMatch"));
    Assert.assertFalse(tester.test("PatternWillNeverMatch"));
}
Also used : TestPersonAttributesGroupTestDefinition(org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition) Test(org.junit.Test)

Example 4 with TestPersonAttributesGroupTestDefinition

use of org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition in project uPortal by Jasig.

the class InjectAttributeRegexTesterTest method testInjectAttributeRegexTester.

@Test
public void testInjectAttributeRegexTester() throws Exception {
    IPerson newPerson = getIPerson("de3");
    Assert.assertNotNull(newPerson);
    // add matching value of Person attribute in key 2
    stringList.add(new String(randomStrings[0] + randomStrings[1] + randomStrings[0]));
    final String key4 = attributeNames[4];
    final String key5 = "ESCOUAICourant";
    newPerson.setAttribute(key1, randomStrings[0]);
    newPerson.setAttribute(key2, randomStrings[1]);
    newPerson.setAttribute(key3, stringList);
    newPerson.setAttribute(key4, null);
    newPerson.setAttribute(key5, "0450822X");
    //  test with an injected attribute not given, so like equals test.  Should return true.
    IPersonTester tester1 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key1, randomStrings[0]));
    // test with an injected attributes.  Should return true.
    String testValue2 = randomStrings[0] + "@" + key2 + "@.*";
    IPersonTester tester2 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key3, testValue2));
    // test an injected attributes that doesn't exist.  Should return false.
    String testValue3 = randomStrings[0] + "@" + missingKey + "@.*";
    IPersonTester tester3 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key3, testValue3));
    //  test an injected attribute with same String.  Should return true.
    String testValue4 = ".*@" + key2 + "@.*";
    IPersonTester tester4 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key2, testValue4));
    // test an injected attribute with different String.  Should return false.
    String testValue5 = ".*@" + key2 + "@.*";
    IPersonTester tester5 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key1, testValue5));
    // test value on null user attribute value.  Should return false.
    String testValue6 = ".*@" + key2 + "@.*";
    IPersonTester tester6 = new InjectAttributeRegexTester(new TestPersonAttributesGroupTestDefinition(key4, testValue6));
    Assert.assertTrue(tester1.test(newPerson));
    Assert.assertTrue(tester2.test(newPerson));
    Assert.assertFalse(tester3.test(newPerson));
    Assert.assertTrue(tester4.test(newPerson));
    Assert.assertFalse(tester5.test(newPerson));
    Assert.assertFalse(tester6.test(newPerson));
}
Also used : IPerson(org.apereo.portal.security.IPerson) IPersonTester(org.apereo.portal.groups.pags.IPersonTester) TestPersonAttributesGroupTestDefinition(org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition) Test(org.junit.Test)

Example 5 with TestPersonAttributesGroupTestDefinition

use of org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition in project uPortal by Jasig.

the class EagerRegexTesterTest method testEagerPatterns.

@Test
public void testEagerPatterns() {
    EagerRegexTester tester = new EagerRegexTester(new TestPersonAttributesGroupTestDefinition("fakeAttribute", "^02([A-D])*"));
    Assert.assertTrue(tester.test("02A"));
    Assert.assertTrue(tester.test("02ABCD"));
    Assert.assertFalse(tester.test("A02D"));
    Assert.assertTrue(tester.test("02"));
    Assert.assertTrue(tester.test("02MisMatch"));
    Assert.assertFalse(tester.test("PatternWillNeverMatch"));
}
Also used : TestPersonAttributesGroupTestDefinition(org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition) Test(org.junit.Test)

Aggregations

TestPersonAttributesGroupTestDefinition (org.apereo.portal.groups.pags.TestPersonAttributesGroupTestDefinition)7 Test (org.junit.Test)7 IPersonTester (org.apereo.portal.groups.pags.IPersonTester)1 IPerson (org.apereo.portal.security.IPerson)1