use of org.camunda.bpm.engine.authorization.AuthorizationQuery in project camunda-bpm-platform by camunda.
the class AuthorizationRestServiceQueryTest method setUpMockQuery.
private AuthorizationQuery setUpMockQuery(List<Authorization> list) {
AuthorizationQuery query = mock(AuthorizationQuery.class);
when(query.list()).thenReturn(list);
when(query.count()).thenReturn((long) list.size());
when(processEngine.getAuthorizationService().createAuthorizationQuery()).thenReturn(query);
return query;
}
use of org.camunda.bpm.engine.authorization.AuthorizationQuery in project camunda-bpm-platform by camunda.
the class AuthorizationRestServiceQueryTest method testSimpleAuthorizationQuery.
@Test
public void testSimpleAuthorizationQuery() {
List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);
Response response = given().queryParam("type", Authorization.AUTH_TYPE_GLOBAL).then().expect().statusCode(Status.OK.getStatusCode()).when().get(SERVICE_PATH);
InOrder inOrder = inOrder(mockQuery);
inOrder.verify(mockQuery).authorizationType(Authorization.AUTH_TYPE_GLOBAL);
inOrder.verify(mockQuery).list();
String content = response.asString();
List<String> instances = from(content).getList("");
Assert.assertEquals("There should be one authorization returned.", 1, instances.size());
Assert.assertNotNull("The returned authorization should not be null.", instances.get(0));
Authorization mockAuthorization = mockAuthorizations.get(0);
Assert.assertEquals(mockAuthorization.getId(), from(content).getString("[0].id"));
Assert.assertEquals(mockAuthorization.getAuthorizationType(), from(content).getInt("[0].type"));
Assert.assertEquals(Permissions.READ.getName(), from(content).getString("[0].permissions[0]"));
Assert.assertEquals(Permissions.UPDATE.getName(), from(content).getString("[0].permissions[1]"));
Assert.assertEquals(mockAuthorization.getUserId(), from(content).getString("[0].userId"));
Assert.assertEquals(mockAuthorization.getGroupId(), from(content).getString("[0].groupId"));
Assert.assertEquals(mockAuthorization.getResourceType(), from(content).getInt("[0].resourceType"));
Assert.assertEquals(mockAuthorization.getResourceId(), from(content).getString("[0].resourceId"));
}
use of org.camunda.bpm.engine.authorization.AuthorizationQuery in project camunda-bpm-platform by camunda.
the class AuthorizationRestServiceQueryTest method testQueryCount.
@Test
public void testQueryCount() {
AuthorizationQuery mockQuery = setUpMockQuery(MockProvider.createMockAuthorizations());
expect().statusCode(Status.OK.getStatusCode()).body("count", equalTo(3)).when().get(SERVICE_COUNT_PATH);
verify(mockQuery).count();
}
Aggregations