Search in sources :

Example 1 with ElementGeometryDao

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);
}
Also used : QuestType(de.westnordost.streetcomplete.data.QuestType) OsmNoteQuestDao(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) OsmQuestDao(de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao) ElementGeometryDao(de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao)

Example 2 with ElementGeometryDao

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();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) OpenChangesetsDao(de.westnordost.streetcomplete.data.changesets.OpenChangesetsDao) ArrayList(java.util.ArrayList) OsmQuestDao(de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao) OsmQuest(de.westnordost.streetcomplete.data.osm.OsmQuest) ElementGeometryDao(de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao) MergedElementDao(de.westnordost.streetcomplete.data.osm.persist.MergedElementDao)

Aggregations

ElementGeometryDao (de.westnordost.streetcomplete.data.osm.persist.ElementGeometryDao)2 OsmQuestDao (de.westnordost.streetcomplete.data.osm.persist.OsmQuestDao)2 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)1 QuestType (de.westnordost.streetcomplete.data.QuestType)1 OpenChangesetsDao (de.westnordost.streetcomplete.data.changesets.OpenChangesetsDao)1 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)1 MergedElementDao (de.westnordost.streetcomplete.data.osm.persist.MergedElementDao)1 OsmNoteQuestDao (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestDao)1 ArrayList (java.util.ArrayList)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1