Search in sources :

Example 36 with Client

use of gov.ca.cwds.rest.api.domain.cms.Client in project API by ca-cwds.

the class ClientServiceTest method testUpdateReturnsCorrectEntity.

@Override
@Test
public void testUpdateReturnsCorrectEntity() throws Exception {
    String id = "Aaeae9r0F4";
    Client expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Client/valid/serviceValid.json"), Client.class);
    gov.ca.cwds.data.persistence.cms.Client client = new gov.ca.cwds.data.persistence.cms.Client(id, expected, "ABC");
    when(clientDao.find("ABC1234567")).thenReturn(client);
    when(clientDao.update(any())).thenReturn(client);
    Object retval = clientService.update("ABC1234567", expected);
    assertThat(retval.getClass(), is(Client.class));
}
Also used : Client(gov.ca.cwds.rest.api.domain.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Test(org.junit.Test)

Example 37 with Client

use of gov.ca.cwds.rest.api.domain.cms.Client in project API by ca-cwds.

the class ClientServiceTest method testCreateReturnsPostedClass.

// create test
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
    String id = "Aaeae9r0F4";
    Client clientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Client/valid/serviceValid.json"), Client.class);
    gov.ca.cwds.data.persistence.cms.Client toCreate = new gov.ca.cwds.data.persistence.cms.Client(id, clientDomain, "q1p");
    Client request = new Client(toCreate, false);
    when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(toCreate);
    Response response = clientService.create(request);
    assertThat(response.getClass(), is(PostedClient.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Client(gov.ca.cwds.rest.api.domain.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Test(org.junit.Test)

Example 38 with Client

use of gov.ca.cwds.rest.api.domain.cms.Client in project API by ca-cwds.

the class ClientServiceTest method testCreateNullIDError.

@Override
@Test
public void testCreateNullIDError() throws Exception {
    try {
        Client clientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Client/valid/serviceValid.json"), Client.class);
        gov.ca.cwds.data.persistence.cms.Client toCreate = new gov.ca.cwds.data.persistence.cms.Client(null, clientDomain, "ABC");
        when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(toCreate);
    } catch (ServiceException e) {
        assertEquals("Client ID cannot be empty", e.getMessage());
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) Client(gov.ca.cwds.rest.api.domain.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Test(org.junit.Test)

Example 39 with Client

use of gov.ca.cwds.rest.api.domain.cms.Client in project API by ca-cwds.

the class ClientServiceTest method testCreateReturnsNonNull.

@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() throws Exception {
    String id = "Aaeae9r0F4";
    Client clientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Client/valid/serviceValid.json"), Client.class);
    gov.ca.cwds.data.persistence.cms.Client toCreate = new gov.ca.cwds.data.persistence.cms.Client(id, clientDomain, "q1p");
    Client request = new Client(toCreate, false);
    when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(toCreate);
    PostedClient postedClient = clientService.create(request);
    assertThat(postedClient, is(notNullValue()));
}
Also used : PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Client(gov.ca.cwds.rest.api.domain.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Test(org.junit.Test)

Example 40 with Client

use of gov.ca.cwds.rest.api.domain.cms.Client in project API by ca-cwds.

the class ClientServiceTest method testFindReturnsCorrectEntity.

@Override
@Test
public void testFindReturnsCorrectEntity() throws Exception {
    String id = "AaiU7IW0Rt";
    Client expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Client/valid/serviceValid.json"), Client.class);
    gov.ca.cwds.data.persistence.cms.Client client = new gov.ca.cwds.data.persistence.cms.Client(id, expected, "04Z");
    when(clientDao.find(id)).thenReturn(client);
    Client found = clientService.find(id);
    assertThat(found, is(expected));
}
Also used : Client(gov.ca.cwds.rest.api.domain.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) Test(org.junit.Test)

Aggregations

Client (gov.ca.cwds.rest.api.domain.cms.Client)60 Test (org.junit.Test)52 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)47 Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)46 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)46 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)46 LinkedHashSet (java.util.LinkedHashSet)46 Referral (gov.ca.cwds.rest.api.domain.cms.Referral)45 Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)45 Set (java.util.Set)45 Response (gov.ca.cwds.rest.api.Response)44 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)43 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)42 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)42 Address (gov.ca.cwds.rest.api.domain.cms.Address)42 ClientAddress (gov.ca.cwds.rest.api.domain.cms.ClientAddress)42 LongText (gov.ca.cwds.rest.api.domain.cms.LongText)42 ErrorMessage (gov.ca.cwds.rest.api.domain.error.ErrorMessage)22 ExpectedException (org.junit.rules.ExpectedException)17 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)14