use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Any1Final.
/**
* Test parsing of a request with a Substrings Filter with 1 Any and 1 Final elements
*/
@Test
public void testRequestWithSubstrings1Any1Final() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_any_1_final.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
List<String> initials = substringFilter.getAny();
assertEquals(1, initials.size());
assertEquals("kate", initials.get(0));
assertEquals("john", substringFilter.getFinal());
}
use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Initial1Final.
/**
* Test parsing of a request with a Substrings Filter with 1 Initial and 1 Final elements
*/
@Test
public void testRequestWithSubstrings1Initial1Final() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_initial_1_final.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
assertEquals("jack", substringFilter.getInitial());
assertEquals("john", substringFilter.getFinal());
}
use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Initial.
/**
* Test parsing of a request with a Substrings Filter with 1 Initial element
*/
@Test
public void testRequestWithSubstrings1Initial() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_initial.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
assertEquals("jack", substringFilter.getInitial().toString());
}
use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstringsFilter.
/**
* Test parsing of a request with an Substrings Filter
*/
@Test
public void testRequestWithSubstringsFilter() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
assertEquals("sn", substringFilter.getAttribute());
}
use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1EmptyAny.
/**
* Test parsing of a request with a Substrings Filter with 1 empty Any element
*/
@Test
public void testRequestWithSubstrings1EmptyAny() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_empty_any.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
List<String> initials = substringFilter.getAny();
assertEquals(0, initials.size());
}
Aggregations