From f81f52dccb5ea6227057a0eaf0e8379ddad640f1 Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Mon, 10 Oct 2016 11:21:17 -0500 Subject: [PATCH] Remove test method --- .../java/org/tasks/makers/GtaskListMaker.java | 23 ++++++++++++------- .../astrid/gtasks/GtasksListServiceTest.java | 16 ++++++++----- .../todoroo/astrid/dao/StoreObjectDao.java | 4 ---- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/androidTest/java/org/tasks/makers/GtaskListMaker.java b/src/androidTest/java/org/tasks/makers/GtaskListMaker.java index 12a82e680..221e085cb 100644 --- a/src/androidTest/java/org/tasks/makers/GtaskListMaker.java +++ b/src/androidTest/java/org/tasks/makers/GtaskListMaker.java @@ -16,17 +16,24 @@ public class GtaskListMaker { public static final Property REMOTE_ID = newProperty(); public static final Property LAST_SYNC = newProperty(); public static final Property NAME = newProperty(); + public static final Property SAVED = newProperty(); public static GtasksList newGtaskList(PropertyValue... properties) { return make(instantiator, properties); } - private static final Instantiator 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 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); + }; } diff --git a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java index 5d4ad70b8..251084b94 100644 --- a/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java +++ b/src/androidTestGoogleplay/java/com/todoroo/astrid/gtasks/GtasksListServiceTest.java @@ -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))); } diff --git a/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java b/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java index db943ffb3..78ca4259c 100644 --- a/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java +++ b/src/main/java/com/todoroo/astrid/dao/StoreObjectDao.java @@ -82,9 +82,5 @@ public class StoreObjectDao { public void delete(long id) { dao.delete(id); } - - public void createNew(StoreObject storeObject) { - dao.createNew(storeObject); - } }