mirror of https://github.com/tasks/tasks
Refactored ChangesHappened to use generics better, started writing tests for sync message classes
parent
646470c47b
commit
cf5c725879
@ -0,0 +1,39 @@
|
||||
package com.todoroo.astrid.sync;
|
||||
|
||||
import com.todoroo.andlib.service.Autowired;
|
||||
import com.todoroo.astrid.dao.TagDataDao;
|
||||
import com.todoroo.astrid.dao.TagOutstandingDao;
|
||||
import com.todoroo.astrid.dao.TaskDao;
|
||||
import com.todoroo.astrid.dao.TaskOutstandingDao;
|
||||
import com.todoroo.astrid.data.TagData;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.test.DatabaseTestCase;
|
||||
|
||||
public class NewSyncTestCase extends DatabaseTestCase {
|
||||
@Autowired
|
||||
protected TaskDao taskDao;
|
||||
@Autowired
|
||||
protected TagDataDao tagDataDao;
|
||||
|
||||
@Autowired
|
||||
protected TaskOutstandingDao taskOutstandingDao;
|
||||
@Autowired
|
||||
protected
|
||||
TagOutstandingDao tagOutstandingDao;
|
||||
|
||||
protected Task createTask() {
|
||||
Task task = new Task();
|
||||
task.setValue(Task.TITLE, "new task");
|
||||
|
||||
taskDao.createNew(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
protected TagData createTagData() {
|
||||
TagData tag = new TagData();
|
||||
tag.setValue(TagData.NAME, "new tag");
|
||||
|
||||
tagDataDao.createNew(tag);
|
||||
return tag;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.todoroo.astrid.sync;
|
||||
|
||||
import com.todoroo.astrid.actfm.sync.messages.ChangesHappened;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.data.TaskOutstanding;
|
||||
|
||||
public class SyncMessageTest extends NewSyncTestCase {
|
||||
|
||||
public void testTaskChangesHappenedConstructor() {
|
||||
Task t = createTask();
|
||||
try {
|
||||
ChangesHappened<Task, TaskOutstanding> changes = new ChangesHappened<Task, TaskOutstanding>(t, taskDao, taskOutstandingDao);
|
||||
assertTrue(changes.getChanges().size() > 0);
|
||||
} catch (Exception e) {
|
||||
fail("ChangesHappened constructor threw exception " + e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue