use of org.motechproject.mds.testutil.records.Record in project motech by motech.
the class MdsRestFacadeTest method shouldDoUpdateOperation.
@Test
public void shouldDoUpdateOperation() throws IOException {
setUpCrudAccess(false, false, true, false);
try (InputStream recordAsStream = toInputStream(recordOne)) {
mdsRestFacade.update(recordAsStream);
}
ArgumentCaptor<Record> captor = ArgumentCaptor.forClass(Record.class);
ArgumentCaptor<Set> fieldsToCopyCaptor = ArgumentCaptor.forClass(Set.class);
verify(dataService).updateFromTransient(captor.capture(), fieldsToCopyCaptor.capture());
assertNotNull(captor.getValue());
assertNotNull(fieldsToCopyCaptor.getValue());
assertEquals("restTest", captor.getValue().getValue());
assertEquals(3, fieldsToCopyCaptor.getValue().size());
assertTrue(fieldsToCopyCaptor.getValue().contains("value"));
assertTrue(fieldsToCopyCaptor.getValue().contains("date"));
assertFalse(fieldsToCopyCaptor.getValue().contains("dateIgnoredByRest"));
}
use of org.motechproject.mds.testutil.records.Record in project motech by motech.
the class MdsRestFacadeTest method shouldDoCreateOperation.
@Test
public void shouldDoCreateOperation() throws IOException {
setUpCrudAccess(true, false, false, false);
recordOne.setBlob(blobFieldValue);
try (InputStream recordAsStream = toInputStream(recordOne)) {
mdsRestFacade.create(recordAsStream);
}
ArgumentCaptor<Record> captor = ArgumentCaptor.forClass(Record.class);
verify(dataService).create(captor.capture());
assertNotNull(captor.getValue());
assertEquals("restTest", captor.getValue().getValue());
assertArrayEquals(blobFieldValue, captor.getValue().getBlob());
assertNull(captor.getValue().getDateIgnoredByRest());
}
use of org.motechproject.mds.testutil.records.Record in project motech by motech.
the class TrashServiceTest method shouldMoveObjectToTrash.
@Test
public void shouldMoveObjectToTrash() throws Exception {
doReturn(Record__Trash.class).when(classLoader).loadClass(Record__Trash.class.getName());
Entity entity = mock(Entity.class);
Field field = mock(Field.class);
Type type = mock(Type.class);
doReturn(17L).when(entity).getEntityVersion();
doReturn(field).when(entity).getField("id");
doReturn(field).when(entity).getField("value");
doReturn(type).when(field).getType();
doReturn(false).when(type).isRelationship();
doReturn(entity).when(allEntities).retrieveByClassName(anyString());
Record instance = new Record();
trashService.moveToTrash(instance, 1L);
verify(manager).makePersistent(trashCaptor.capture());
Record__Trash trash = trashCaptor.getValue();
assertEquals(instance.getValue(), trash.getValue());
}
use of org.motechproject.mds.testutil.records.Record in project motech by motech.
the class TrashServiceTest method shouldMoveObjectFromTrash.
@Test
public void shouldMoveObjectFromTrash() {
Record instance = new Record();
Record__Trash trash = new Record__Trash();
doReturn(entity).when(allEntities).retrieveByClassName(anyString());
doReturn(true).when(entity).isRecordHistory();
trashService.removeFromTrash(trash);
verify(manager).deletePersistent(trashCaptor.capture());
Record__Trash captor = trashCaptor.getValue();
assertEquals(captor.getValue(), trash.getValue());
}
use of org.motechproject.mds.testutil.records.Record in project motech by motech.
the class InMemoryQueryFilterTest method shouldOrderByAsc.
@Test
public void shouldOrderByAsc() {
QueryParams queryParams = new QueryParams(new Order("value", Order.Direction.ASC));
List<Record> result = InMemoryQueryFilter.filter(testCollection, queryParams);
assertListByValues(result, asList("aaa", "hmm", "hmm", "nullRecord", "something", "test", "zet"));
assertListByIds(result, asList(4L, 5L, 6L, null, 3L, 2L, 1L));
}
Aggregations