use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.
the class UserClass_SubtreeTest method initNames.
/**
* Initialize name instances
*/
@Before
public void initNames() throws Exception {
SubtreeSpecification subtreeSpecA = new BaseSubtreeSpecification();
SubtreeSpecification subtreeSpecB = new BaseSubtreeSpecification();
SubtreeSpecification subtreeSpecC = new BaseSubtreeSpecification();
SubtreeSpecification subtreeSpecD = new BaseSubtreeSpecification(new Dn("cn=dummy"));
Set<SubtreeSpecification> colA = new HashSet<SubtreeSpecification>();
colA.add(subtreeSpecA);
colA.add(subtreeSpecB);
colA.add(subtreeSpecC);
Set<SubtreeSpecification> colB = new HashSet<SubtreeSpecification>();
colB.add(subtreeSpecA);
colB.add(subtreeSpecB);
colB.add(subtreeSpecC);
Set<SubtreeSpecification> colC = new HashSet<SubtreeSpecification>();
colC.add(subtreeSpecB);
colC.add(subtreeSpecC);
colC.add(subtreeSpecD);
subtreeA = new Subtree(colA);
subtreeACopy = new Subtree(colA);
subtreeB = new Subtree(colB);
subtreeC = new Subtree(colC);
}
use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.
the class SubtreeSpecificationParserTest method testSpecWithAllInOne.
/**
* Tests the parser with a valid specification with all components set.
*/
@Test
public void testSpecWithAllInOne() throws Exception {
SubtreeSpecification ss = parser.parse(SPEC_WITH_ALL_IN_ONE);
assertNotNull(ss);
}
use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.
the class SubtreeSpecificationParserTest method testSpecWithMinimumAndMaximum.
/**
* Tests the parser with a valid specification with minimum and maximum set.
*/
@Test
public void testSpecWithMinimumAndMaximum() throws Exception {
SubtreeSpecification ss = parser.parse(SPEC_WITH_MINIMUM_AND_MAXIMUM);
assertEquals(1, ss.getMinBaseDistance());
assertEquals(2, ss.getMaxBaseDistance());
// try a second time
ss = parser.parse(SPEC_WITH_MINIMUM_AND_MAXIMUM);
assertEquals(1, ss.getMinBaseDistance());
assertEquals(2, ss.getMaxBaseDistance());
// try a third time
ss = parser.parse(SPEC_WITH_MINIMUM_AND_MAXIMUM);
assertEquals(1, ss.getMinBaseDistance());
assertEquals(2, ss.getMaxBaseDistance());
}
use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.
the class SubtreeSpecificationParserTest method testSpecWithRefinement.
/**
* Tests the parser with a valid specification with refinement set.
*/
@Test
public void testSpecWithRefinement() throws Exception {
SubtreeSpecification ss = parser.parse(SPEC_WITH_REFINEMENT);
// The items
Refinement topItem = new ItemRefinement(topOC);
Refinement aliasItem = new ItemRefinement(aliasOC);
Refinement personItem = new ItemRefinement(personOC);
Refinement countryItem = new ItemRefinement(countryOC);
// The inner OR refinement or:{item:2.5.6.1, item:person}
List<Refinement> orList = new ArrayList<Refinement>();
orList.add(aliasItem);
orList.add(personItem);
Refinement orRefinement = new OrRefinement(orList);
// The inner AND refinement and:{ item:2.5.6.0, or:... }
List<Refinement> innerAndList = new ArrayList<Refinement>();
innerAndList.add(topItem);
innerAndList.add(orRefinement);
Refinement innerAndRefinement = new AndRefinement(innerAndList);
// The NOT refinement not:item:2.5.6.2
Refinement notRefinement = new NotRefinement(countryItem);
// The outer AND refinement and:{and:..., not:...}
List<Refinement> outerAndList = new ArrayList<Refinement>();
outerAndList.add(innerAndRefinement);
outerAndList.add(notRefinement);
StringBuilder buffer = new StringBuilder();
ss.getRefinement().printRefinementToBuffer(buffer);
// assertEquals( outerAndRefinement.toString(), buffer );
assertEquals("and: { and: { item: 2.5.6.0, or: { item: 2.5.6.1, item: person } }, not: item: 2.5.6.2 }", buffer.toString());
}
use of org.apache.directory.api.ldap.model.subtree.SubtreeSpecification in project directory-ldap-api by apache.
the class SubtreeSpecificationParserTest method testSpecWithSpecificExclusions.
/**
* Tests the parser with a valid specification with some specific exclusions
* set.
*/
@Test
public void testSpecWithSpecificExclusions() throws Exception {
SubtreeSpecification ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
// try a second time
ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
// try a third time
ss = parser.parse(SPEC_WITH_SPECIFICEXCLUSIONS);
assertFalse(ss.getChopBeforeExclusions().isEmpty());
assertFalse(ss.getChopAfterExclusions().isEmpty());
assertTrue(ss.getChopBeforeExclusions().contains(new Dn(schemaManager, "cn=cd")));
assertTrue(ss.getChopAfterExclusions().contains(new Dn(schemaManager, "cn=gh")));
}
Aggregations