Remove test method

pull/467/head
Alex Baker 8 years ago
parent 9584e92578
commit f81f52dccb

@ -16,17 +16,24 @@ public class GtaskListMaker {
public static final Property<GtasksList, String> REMOTE_ID = newProperty();
public static final Property<GtasksList, Long> LAST_SYNC = newProperty();
public static final Property<GtasksList, String> NAME = newProperty();
public static final Property<GtasksList, Boolean> SAVED = newProperty();
public static GtasksList newGtaskList(PropertyValue<? super GtasksList, ?>... properties) {
return make(instantiator, properties);
}
private static final Instantiator<GtasksList> instantiator = lookup -> new GtasksList(new StoreObject() {{
setType(GtasksList.TYPE);
setValue(StoreObject.ID, lookup.valueOf(GtaskListMaker.ID, 1L));
setValue(StoreObject.ITEM, lookup.valueOf(REMOTE_ID, "1"));
setValue(StoreObject.VALUE1, lookup.valueOf(NAME, "Default"));
setValue(StoreObject.VALUE2, String.valueOf(lookup.valueOf(ORDER, 0)));
setValue(StoreObject.VALUE3, String.valueOf(lookup.valueOf(LAST_SYNC, 0L)));
}});
private static final Instantiator<GtasksList> instantiator = lookup -> {
StoreObject storeObject = new StoreObject() {{
setType(GtasksList.TYPE);
setValue(StoreObject.ID, lookup.valueOf(GtaskListMaker.ID, 0L));
setValue(StoreObject.ITEM, lookup.valueOf(REMOTE_ID, "1"));
setValue(StoreObject.VALUE1, lookup.valueOf(NAME, "Default"));
setValue(StoreObject.VALUE2, String.valueOf(lookup.valueOf(ORDER, 0)));
setValue(StoreObject.VALUE3, String.valueOf(lookup.valueOf(LAST_SYNC, 0L)));
}};
if (lookup.valueOf(SAVED, false)) {
storeObject.markSaved();
}
return new GtasksList(storeObject);
};
}

@ -21,6 +21,8 @@ import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertNull;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.tasks.makers.GtaskListMaker.ID;
import static org.tasks.makers.GtaskListMaker.SAVED;
import static org.tasks.time.DateTimeUtils.currentTimeMillis;
import static org.tasks.makers.GtaskListMaker.LAST_SYNC;
import static org.tasks.makers.GtaskListMaker.NAME;
@ -55,14 +57,16 @@ public class GtasksListServiceTest extends DatabaseTestCase {
with(RemoteGtaskListMaker.NAME, "Default")));
verify(storeObjectDao).persist(newGtaskList(
with(ID, 1L),
with(REMOTE_ID, "1"),
with(NAME, "Default")));
with(NAME, "Default"),
with(SAVED, true)));
}
@Test
public void testGetListByRemoteId() {
GtasksList list = newGtaskList(with(REMOTE_ID, "1"));
storeObjectDao.createNew(list.getStoreObject());
storeObjectDao.persist(list);
assertEquals(list, gtasksListService.getList("1"));
}
@ -74,7 +78,7 @@ public class GtasksListServiceTest extends DatabaseTestCase {
@Test
public void testDeleteMissingList() {
storeObjectDao.createNew(newGtaskList(with(REMOTE_ID, "1")).getStoreObject());
storeObjectDao.persist(newGtaskList(with(REMOTE_ID, "1")));
setLists(newRemoteList(with(RemoteGtaskListMaker.REMOTE_ID, "2")));
@ -83,9 +87,9 @@ public class GtasksListServiceTest extends DatabaseTestCase {
@Test
public void testUpdateListName() {
storeObjectDao.createNew(newGtaskList(
storeObjectDao.persist(newGtaskList(
with(REMOTE_ID, "1"),
with(NAME, "oldName")).getStoreObject());
with(NAME, "oldName")));
setLists(newRemoteList(
with(RemoteGtaskListMaker.REMOTE_ID, "1"),
@ -108,7 +112,7 @@ public class GtasksListServiceTest extends DatabaseTestCase {
setLists(taskList);
assertEquals(
asList(newGtaskList(with(REMOTE_ID, "1"), with(LAST_SYNC, 0L))),
asList(newGtaskList(with(ID, 1L), with(REMOTE_ID, "1"), with(LAST_SYNC, 0L), with(SAVED, true))),
gtasksListService.getListsToUpdate(asList(taskList)));
}

@ -82,9 +82,5 @@ public class StoreObjectDao {
public void delete(long id) {
dao.delete(id);
}
public void createNew(StoreObject storeObject) {
dao.createNew(storeObject);
}
}

Loading…
Cancel
Save