use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldHandleStringEquality.
@Test
public void shouldHandleStringEquality() throws Exception {
// Given
String value = "testValue";
QueryRequest request = mockQueryRequest(QueryFilter.equalTo(new JsonPointer(STRING_ATTRIBUTE), value));
// When
testStore.query(request);
// Then
verify(mockManager).search(singleton(new SearchFilter(STRING_SEARCH_ATTRIBUTE, value)));
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class PrivilegePolicyStoreTest method shouldRejectPresenceQueries.
@Test(expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*not supported.*")
public void shouldRejectPresenceQueries() throws Exception {
// Given
QueryRequest request = mockQueryRequest(QueryFilter.present(new JsonPointer((STRING_ATTRIBUTE))));
// When
testStore.query(request);
// Then - exception
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class SubjectTypesResourceTest method testSuccessfulJsonificationAndQuery.
@Test
public void testSuccessfulJsonificationAndQuery() throws Exception {
//given
SSOTokenContext mockSubjectContext = mock(SSOTokenContext.class);
RealmContext realmContext = new RealmContext(mockSubjectContext);
Context mockServerContext = ClientContext.newInternalClientContext(realmContext);
Subject mockSubject = new Subject();
given(mockSubjectContext.getCallerSubject()).willReturn(mockSubject);
QueryRequest mockRequest = mock(QueryRequest.class);
JsonSchema mockSchema = mock(JsonSchema.class);
QueryResourceHandler mockHandler = mock(QueryResourceHandler.class);
given(mockRequest.getPageSize()).willReturn(2);
given(mockHandler.handleResource(any(ResourceResponse.class))).willReturn(true);
given(mockMapper.generateJsonSchema((Class<?>) any(Class.class))).willReturn(mockSchema);
//when
Promise<QueryResponse, ResourceException> promise = testResource.queryCollection(mockServerContext, mockRequest, mockHandler);
//then
assertThat(promise).succeeded();
verify(mockHandler, times(2)).handleResource(any(ResourceResponse.class));
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldRejectOrQueries.
@Test(expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*'Or' not supported.*")
public void shouldRejectOrQueries() throws Exception {
// Given
QueryRequest request = mockQueryRequest(or(QueryFilter.<JsonPointer>alwaysTrue(), QueryFilter.<JsonPointer>alwaysTrue()));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then - exception
}
use of org.forgerock.json.resource.QueryRequest in project OpenAM by OpenRock.
the class ApplicationsResourceTest method shouldRejectUnsupportedQueryOperators.
@Test(dataProvider = "UnsupportedOperators", expectedExceptions = EntitlementException.class, expectedExceptionsMessageRegExp = ".*not supported.*")
public void shouldRejectUnsupportedQueryOperators(String queryOperator) throws Exception {
// Given
QueryRequest request = mockQueryRequest(comparisonFilter(new JsonPointer(NUMERIC_ATTRIBUTE), queryOperator, 123l));
Subject subject = new Subject();
// When
applicationsResource.query(request, subject, "/abc");
// Then - exception
}
Aggregations