use of gov.ca.cwds.rest.api.PrimaryKeyResponse in project api-core by ca-cwds.
the class ServiceBackedResourceDelegateTest method setup.
@Before
public void setup() throws Exception {
nonUniqueDomainObject = new ResourceDelegateTestDomainObject(ID_FOUND);
uniqueDomainObject = new ResourceDelegateTestDomainObject(ID_NOT_FOUND);
unexpectedExceptionDomainObject = new ResourceDelegateTestDomainObject(new Long(13));
validationErrorMessageDomainObject = new ResourceDelegateTestDomainObject(new Long(15));
ArrayList messages = new ArrayList<>();
validationErrorMessageDomainObject.setMessages(messages);
when(crudsService.find(ID_NOT_FOUND)).thenReturn(null);
when(crudsService.find(ID_FOUND)).thenReturn(nonUniqueDomainObject);
when(crudsService.delete(ID_NOT_FOUND)).thenReturn(null);
when(crudsService.delete(ID_FOUND)).thenReturn(nonUniqueDomainObject);
when(crudsService.create(eq(uniqueDomainObject))).thenReturn(new PrimaryKeyResponse(nonUniqueDomainObject.getId()));
when(crudsService.create(eq(nonUniqueDomainObject))).thenThrow(new ServiceException(new EntityExistsException()));
when(crudsService.create(eq(unexpectedExceptionDomainObject))).thenThrow(new ServiceException(new RuntimeException()));
when(crudsService.create(eq(validationErrorMessageDomainObject))).thenReturn(validationErrorMessageDomainObject);
when(crudsService.update(eq(1L), eq(unexpectedExceptionDomainObject))).thenThrow(new ServiceException(new RuntimeException()));
when(crudsService.update(eq(-1L), eq(uniqueDomainObject))).thenThrow(new ServiceException(new EntityNotFoundException()));
when(crudsService.update(eq(1L), eq(nonUniqueDomainObject))).thenReturn(new PrimaryKeyResponse(nonUniqueDomainObject.getId()));
}
Aggregations