Search in sources :

Example 1 with TosResponse

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

the class SamServiceTest method testPostTosAcceptedStatus.

@Test
public void testPostTosAcceptedStatus() {
    TosResponse.Enabled enabled = new TosResponse.Enabled().setAdminEnabled(true).setTosAccepted(true).setGoogle(true).setAllUsersGroup(true).setLdap(true);
    UserStatus.UserInfo info = new UserStatus.UserInfo().setUserEmail("test@test.org").setUserSubjectId("subjectId");
    TosResponse tosResponse = new TosResponse().setEnabled(enabled).setUserInfo(info);
    mockServerClient.when(request()).respond(response().withHeader(Header.header("Content-Type", "application/json")).withStatusCode(200).withBody(tosResponse.toString()));
    try {
        service.postTosAcceptedStatus(authUser);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : TosResponse(org.broadinstitute.consent.http.models.sam.TosResponse) UserStatus(org.broadinstitute.consent.http.models.sam.UserStatus) BadRequestException(javax.ws.rs.BadRequestException) ForbiddenException(javax.ws.rs.ForbiddenException) NotFoundException(javax.ws.rs.NotFoundException) ConsentConflictException(org.broadinstitute.consent.http.exceptions.ConsentConflictException) NotAuthorizedException(javax.ws.rs.NotAuthorizedException) Test(org.junit.Test)

Example 2 with TosResponse

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

the class SamResourceTest method testPostSelfTos.

@Test
public void testPostSelfTos() throws Exception {
    TosResponse.Enabled enabled = new TosResponse.Enabled().setAdminEnabled(true).setTosAccepted(true).setGoogle(true).setAllUsersGroup(true).setLdap(true);
    UserStatus.UserInfo info = new UserStatus.UserInfo().setUserEmail("test@test.org").setUserSubjectId("subjectId");
    TosResponse tosResponse = new TosResponse().setEnabled(enabled).setUserInfo(info);
    when(service.postTosAcceptedStatus(any())).thenReturn(tosResponse);
    initResource();
    Response response = resource.postSelfTos(authUser);
    assertEquals(HttpStatusCodes.STATUS_CODE_OK, response.getStatus());
}
Also used : TosResponse(org.broadinstitute.consent.http.models.sam.TosResponse) Response(javax.ws.rs.core.Response) TosResponse(org.broadinstitute.consent.http.models.sam.TosResponse) UserStatus(org.broadinstitute.consent.http.models.sam.UserStatus) Test(org.junit.Test)

Aggregations

TosResponse (org.broadinstitute.consent.http.models.sam.TosResponse)2 UserStatus (org.broadinstitute.consent.http.models.sam.UserStatus)2 Test (org.junit.Test)2 BadRequestException (javax.ws.rs.BadRequestException)1 ForbiddenException (javax.ws.rs.ForbiddenException)1 NotAuthorizedException (javax.ws.rs.NotAuthorizedException)1 NotFoundException (javax.ws.rs.NotFoundException)1 Response (javax.ws.rs.core.Response)1 ConsentConflictException (org.broadinstitute.consent.http.exceptions.ConsentConflictException)1