use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testCreateReturnsNonNull.
@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() throws Exception {
String id = "Aaeae9r0F4";
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
Allegation request = new Allegation(toCreate);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
PostedAllegation postedAllegation = allegationService.create(request);
assertThat(postedAllegation, is(notNullValue()));
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testCreateReturnsCorrectEntity.
@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
String id = "Aaeae9r0F4";
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
Allegation request = new Allegation(toCreate);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
PostedAllegation expected = new PostedAllegation(toCreate);
PostedAllegation returned = allegationService.create(request);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method createReturnsGeneratedId.
/*
* Test for checking the new Allegation Id generated and lenght is 10
*/
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.Allegation>() {
@Override
public gov.ca.cwds.data.persistence.cms.Allegation answer(InvocationOnMock invocation) throws Throwable {
gov.ca.cwds.data.persistence.cms.Allegation report = (gov.ca.cwds.data.persistence.cms.Allegation) invocation.getArguments()[0];
return report;
}
});
PostedAllegation returned = allegationService.create(allegationDomain);
assertEquals(returned.getId().length(), 10);
PostedAllegation newReturned = allegationService.create(allegationDomain);
Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testCreateReturnsPostedClass.
// create test
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
String id = "Aaeae9r0F4";
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
Allegation request = new Allegation(toCreate);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
Response response = allegationService.create(request);
assertThat(response.getClass(), is(PostedAllegation.class));
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationResourceTest method updateValidatesEntity.
@Test
public void updateValidatesEntity() throws Exception {
Allegation serialized = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/invalid/abuseEndDateWrongFormat.json"), Allegation.class);
int status = inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(serialized, MediaType.APPLICATION_JSON)).getStatus();
assertThat(status, is(422));
}
Aggregations