Search in sources :

Example 1 with PaginationResponse

use of org.broadinstitute.consent.http.models.PaginationResponse in project consent by DataBiosphere.

the class DarCollectionResourceTest method testQueryCollectionsByFiltersAndUserRoles.

@Test
public void testQueryCollectionsByFiltersAndUserRoles() {
    PaginationResponse<DarCollection> paginationResponse = new PaginationResponse<>();
    when(userService.findUserByEmail(anyString())).thenReturn(researcher);
    when(darCollectionService.queryCollectionsByFiltersAndUserRoles(any(User.class), any(PaginationToken.class), anyString())).thenReturn(paginationResponse);
    initResource();
    Response response = resource.queryCollectionsByFiltersAndUserRoles(authUser, "researcher", "DESC", "filterTerm", "projectTitle", 10);
    assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) PaginationResponse(org.broadinstitute.consent.http.models.PaginationResponse) AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) PaginationResponse(org.broadinstitute.consent.http.models.PaginationResponse) PaginationToken(org.broadinstitute.consent.http.models.PaginationToken) DarCollection(org.broadinstitute.consent.http.models.DarCollection) Test(org.junit.Test)

Example 2 with PaginationResponse

use of org.broadinstitute.consent.http.models.PaginationResponse in project consent by DataBiosphere.

the class DarCollectionResourceTest method testGetCollectionsByToken.

@Test
public void testGetCollectionsByToken() {
    PaginationResponse<DarCollection> paginationResponse = new PaginationResponse<>();
    when(userService.findUserByEmail(anyString())).thenReturn(researcher);
    when(darCollectionService.queryCollectionsByFiltersAndUserRoles(any(User.class), any(PaginationToken.class), anyString())).thenReturn(paginationResponse);
    initResource();
    String token = "eyJwYWdlIjoyLCJwYWdlU2l6ZSI6MSwic29ydEZpZWxkIjoiZGFyX2NvZGUiLCJzb3J0RGlyZWN0aW9uIjoiREVTQyIsImZpbHRlcmVkQ291bnQiOjQsImZpbHRlcmVkUGFnZUNvdW50Ijo0LCJ1bmZpbHRlcmVkQ291bnQiOjQsImFjY2VwdGFibGVTb3J0RmllbGRzIjp7InByb2plY3RUaXRsZSI6InByb2plY3RUaXRsZSIsInJlc2VhcmNoZXIiOiJyZXNlYXJjaGVyIiwiaW5zdGl0dXRpb24iOiJpbnN0aXR1dGlvbl9uYW1lIiwiZGFyQ29kZSI6ImRhcl9jb2RlIn19";
    Response response = resource.getCollectionsByToken(authUser, token, "researcher");
    assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) PaginationResponse(org.broadinstitute.consent.http.models.PaginationResponse) AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) PaginationResponse(org.broadinstitute.consent.http.models.PaginationResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PaginationToken(org.broadinstitute.consent.http.models.PaginationToken) DarCollection(org.broadinstitute.consent.http.models.DarCollection) Test(org.junit.Test)

Aggregations

Response (javax.ws.rs.core.Response)2 AuthUser (org.broadinstitute.consent.http.models.AuthUser)2 DarCollection (org.broadinstitute.consent.http.models.DarCollection)2 PaginationResponse (org.broadinstitute.consent.http.models.PaginationResponse)2 PaginationToken (org.broadinstitute.consent.http.models.PaginationToken)2 User (org.broadinstitute.consent.http.models.User)2 Test (org.junit.Test)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1