Search in sources :

Example 1 with DacBuilder

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

the class DacResourceTest method testFindById_success.

@Test
public void testFindById_success() {
    Dac dac = new DacBuilder().setDacId(1).setName("name").setDescription("description").build();
    when(dacService.findById(1)).thenReturn(dac);
    Response response = dacResource.findById(dac.getDacId());
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) DacBuilder(org.broadinstitute.consent.http.models.DacBuilder) Dac(org.broadinstitute.consent.http.models.Dac) Test(org.junit.Test)

Example 2 with DacBuilder

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

the class DacResourceTest method testUpdateDac_badRequest_2.

@Test(expected = BadRequestException.class)
public void testUpdateDac_badRequest_2() {
    Dac dac = new DacBuilder().setDacId(null).setName("name").setDescription("description").build();
    dacResource.updateDac(authUser, gson.toJson(dac));
}
Also used : DacBuilder(org.broadinstitute.consent.http.models.DacBuilder) Dac(org.broadinstitute.consent.http.models.Dac) Test(org.junit.Test)

Example 3 with DacBuilder

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

the class DacResourceTest method testCreateDac_badRequest_2.

@Test(expected = BadRequestException.class)
public void testCreateDac_badRequest_2() throws Exception {
    Dac dac = new DacBuilder().setName(null).setDescription("description").build();
    when(dacService.createDac(any(), any())).thenReturn(1);
    when(dacService.findById(1)).thenReturn(dac);
    dacResource.createDac(authUser, gson.toJson(dac));
}
Also used : DacBuilder(org.broadinstitute.consent.http.models.DacBuilder) Dac(org.broadinstitute.consent.http.models.Dac) Test(org.junit.Test)

Example 4 with DacBuilder

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

the class DacResourceTest method testUpdateDac_badRequest_3.

@Test(expected = BadRequestException.class)
public void testUpdateDac_badRequest_3() {
    Dac dac = new DacBuilder().setDacId(1).setName(null).setDescription("description").build();
    dacResource.updateDac(authUser, gson.toJson(dac));
}
Also used : DacBuilder(org.broadinstitute.consent.http.models.DacBuilder) Dac(org.broadinstitute.consent.http.models.Dac) Test(org.junit.Test)

Example 5 with DacBuilder

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

the class DacResourceTest method testUpdateDac_success.

@Test
public void testUpdateDac_success() {
    Dac dac = new DacBuilder().setDacId(1).setName("name").setDescription("description").build();
    doNothing().when(dacService).updateDac(isA(String.class), isA(String.class), isA(Integer.class));
    when(dacService.findById(1)).thenReturn(dac);
    Response response = dacResource.updateDac(authUser, gson.toJson(dac));
    assertEquals(200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) DacBuilder(org.broadinstitute.consent.http.models.DacBuilder) Dac(org.broadinstitute.consent.http.models.Dac) Test(org.junit.Test)

Aggregations

Dac (org.broadinstitute.consent.http.models.Dac)10 DacBuilder (org.broadinstitute.consent.http.models.DacBuilder)10 Test (org.junit.Test)10 Response (javax.ws.rs.core.Response)5 JsonArray (com.google.gson.JsonArray)1