use of org.motechproject.mds.testutil.records.history.Record__Trash 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.history.Record__Trash 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.history.Record__Trash in project motech by motech.
the class TrashServiceTest method shouldFindTrashEntityById.
@Test
public void shouldFindTrashEntityById() throws Exception {
doReturn(Record__Trash.class).when(classLoader).loadClass("org.test.history.TestEntity__Trash");
doReturn(query).when(manager).newQuery(Record__Trash.class);
Entity entity = mock(Entity.class);
Field field = mock(Field.class);
Type type = mock(Type.class);
doReturn(17L).when(entity).getEntityVersion();
doReturn("org.test.TestEntity").when(entity).getClassName();
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).retrieveById(1L);
doReturn(new Record__Trash()).when(query).execute(anyLong());
Object trash = trashService.findTrashById(1L, "org.test.TestEntity");
assertNotNull(trash);
}
Aggregations