protected void applyFilters(AuthorizationQuery query) { if (id != null) { query.authorizationId(id); } if (type != null) { query.authorizationType(type); } if (userIdIn != null) { query.userIdIn(userIdIn); } if (groupIdIn != null) { query.groupIdIn(groupIdIn); } if (resourceType != null) { query.resourceType(resourceType); } if (resourceId != null) { query.resourceId(resourceId); } }
protected void applyFilters(AuthorizationQuery query) { if (id != null) { query.authorizationId(id); } if (type != null) { query.authorizationType(type); } if (userIdIn != null) { query.userIdIn(userIdIn); } if (groupIdIn != null) { query.groupIdIn(groupIdIn); } if (resourceType != null) { query.resourceType(resourceType); } if (resourceId != null) { query.resourceId(resourceId); } }
@Test public void testCompleteGetParameters() { List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations(); AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations); Map<String, String> queryParameters = getCompleteStringQueryParameters(); RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE); for (Entry<String, String> paramEntry : queryParameters.entrySet()) { requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue()); } requestSpecification.expect().statusCode(Status.OK.getStatusCode()) .when().get(SERVICE_PATH); verify(mockQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID); verify(mockQuery).authorizationType(MockProvider.EXAMPLE_AUTHORIZATION_TYPE); verify(mockQuery).userIdIn(new String[]{MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_ID2}); verify(mockQuery).groupIdIn(new String[]{MockProvider.EXAMPLE_GROUP_ID, MockProvider.EXAMPLE_GROUP_ID2}); verify(mockQuery).resourceType(MockProvider.EXAMPLE_RESOURCE_TYPE_ID); verify(mockQuery).resourceId(MockProvider.EXAMPLE_RESOURCE_ID); verify(mockQuery).list(); }
@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")); }
protected void applyFilters(AuthorizationQuery query) { if (id != null) { query.authorizationId(id); } if (type != null) { query.authorizationType(type); } if (userIdIn != null) { query.userIdIn(userIdIn); } if (groupIdIn != null) { query.groupIdIn(groupIdIn); } if (resourceType != null) { query.resourceType(resourceType); } if (resourceId != null) { query.resourceId(resourceId); } }