use of com.sun.identity.entitlement.util.SearchAttribute in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldHandleAndQueries.
@Test
public void shouldHandleAndQueries() throws Exception {
// Given
String value1 = "value1";
String value2 = "value2";
QueryRequest request = mockQueryRequest(and(equalTo(new JsonPointer(STRING_ATTRIBUTE), value1), equalTo(new JsonPointer(STRING_ATTRIBUTE), value2)));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
SearchFilter searchFilter1 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value1);
SearchFilter searchFilter2 = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value2);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter1, searchFilter2)));
}
use of com.sun.identity.entitlement.util.SearchAttribute in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldSupportDateQueries.
@Test(dataProvider = "SupportedQueryOperators")
public void shouldSupportDateQueries(String queryOperator, SearchFilter.Operator expectedOperator) throws Exception {
// Given
// Note: only second accuracy supported in timestamp format
Date value = new Date(123456789000l);
QueryRequest request = mockQueryRequest(comparisonFilter(new JsonPointer(DATE_ATTRIBUTE), queryOperator, DateUtils.toUTCDateFormat(value)));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
// Date should be converted into a time-stamp long value
SearchFilter searchFilter = new SearchFilter(new SearchAttribute(DATE_ATTRIBUTE, "ou"), value.getTime(), expectedOperator);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter)));
}
use of com.sun.identity.entitlement.util.SearchAttribute in project OpenAM by OpenRock.
the class ApplicationsResourceTest method setUp.
@BeforeMethod
public void setUp() {
debug = mock(Debug.class);
applicationManagerWrapper = mock(ApplicationManagerWrapper.class);
applicationTypeManagerWrapper = mock(ApplicationTypeManagerWrapper.class);
applicationWrapper = mock(ApplicationWrapper.class);
queryAttributes = new HashMap<String, QueryAttribute>();
queryAttributes.put(STRING_ATTRIBUTE, new QueryAttribute(AttributeType.STRING, new SearchAttribute(STRING_ATTRIBUTE, "ou")));
queryAttributes.put(NUMERIC_ATTRIBUTE, new QueryAttribute(AttributeType.NUMBER, new SearchAttribute(NUMERIC_ATTRIBUTE, "ou")));
queryAttributes.put(DATE_ATTRIBUTE, new QueryAttribute(AttributeType.TIMESTAMP, new SearchAttribute(DATE_ATTRIBUTE, "ou")));
applicationsResource = new ApplicationsResource(debug, applicationManagerWrapper, applicationTypeManagerWrapper, queryAttributes, resourceErrorHandler) {
@Override
protected ApplicationWrapper createApplicationWrapper(JsonValue jsonValue, Subject mySubject) throws EntitlementException {
return applicationWrapper;
}
};
}
use of com.sun.identity.entitlement.util.SearchAttribute in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldHandleStringEquality.
@Test
public void shouldHandleStringEquality() throws Exception {
// Given
String value = "testValue";
QueryRequest request = mockQueryRequest(equalTo(new JsonPointer(STRING_ATTRIBUTE), value));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
SearchFilter searchFilter = new SearchFilter(new SearchAttribute(STRING_ATTRIBUTE, "ou"), value);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter)));
}
use of com.sun.identity.entitlement.util.SearchAttribute in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldTranslateSupportedOperators.
@Test(dataProvider = "SupportedQueryOperators")
public void shouldTranslateSupportedOperators(String queryOperator, SearchFilter.Operator expectedOperator) throws Exception {
// Given
long value = 123l;
QueryRequest request = mockQueryRequest(comparisonFilter(new JsonPointer(NUMERIC_ATTRIBUTE), queryOperator, value));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then
SearchFilter searchFilter = new SearchFilter(new SearchAttribute(NUMERIC_ATTRIBUTE, "ou"), value, expectedOperator);
verify(applicationManagerWrapper).search(eq(subject), eq("/abc"), eq(asSet(searchFilter)));
}
Aggregations