use of de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao in project StreetComplete by westnordost.
the class OsmQuestUnlockerTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
ElementGeometryDao elementGeometryDao = mock(ElementGeometryDao.class);
when(elementGeometryDao.get(Element.Type.NODE, 1)).thenReturn(new ElementGeometry(POS));
osmNoteQuestDao = mock(OsmNoteQuestDao.class);
when(osmNoteQuestDao.getAllPositions(any(BoundingBox.class))).thenReturn(Collections.emptyList());
osmQuestDao = mock(OsmQuestDao.class);
when(osmQuestDao.getAll(null, null, null, Element.Type.NODE, 1L)).thenReturn(Collections.emptyList());
questType = mock(OsmElementQuestType.class);
final List<QuestType> questTypes = Collections.singletonList(questType);
osmQuestUnlocker = new OsmQuestUnlocker(osmNoteQuestDao, osmQuestDao, elementGeometryDao, () -> questTypes);
}
use of de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao in project StreetComplete by westnordost.
the class OsmQuestChangesUploadTest method testCancel.
public void testCancel() throws InterruptedException {
OsmQuestDao questDb = mock(OsmQuestDao.class);
ElementGeometryDao elementGeometryDao = mock(ElementGeometryDao.class);
MergedElementDao elementDB = mock(MergedElementDao.class);
OpenChangesetsDao openChangesetsDb = mock(OpenChangesetsDao.class);
when(questDb.getAll(null, QuestStatus.ANSWERED)).thenAnswer(invocation -> {
// take your time...
Thread.sleep(1000);
ArrayList<OsmQuest> result = new ArrayList<>();
result.add(null);
return result;
});
final OsmQuestChangesUpload u = new OsmQuestChangesUpload(null, questDb, elementDB, elementGeometryDao, null, openChangesetsDb, null, null, null, null);
final AtomicBoolean cancel = new AtomicBoolean(false);
Thread t = new Thread(() -> u.upload(cancel));
t.start();
cancel.set(true);
// cancelling the thread works if we come out here without exceptions. If the upload
// would actually try to start anything, there would be a nullpointer exception since we
// feeded it only with nulls to work with
t.join();
// this is not called anymore immediately since quests are kept in DB for some time before deletion (#373)
// verify(elementGeometryDao).deleteUnreferenced();
// verify(elementDB).deleteUnreferenced();
}
Aggregations