Search in sources :

Example 1 with Way

use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.

the class CreateNoteUploadTest method testCreateNoteWithNoQuestTitleButAssociatedElement.

public void testCreateNoteWithNoQuestTitleButAssociatedElement() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    when(mapDataDao.getWay(createNote.elementId)).thenReturn(mock(Way.class));
    Note note = createNote(null);
    when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).create(createNote.position, "for https://www.openstreetmap.org/way/5 via " + ApplicationConstants.USER_AGENT + ":\n\njo ho");
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note) Way(de.westnordost.osmapi.map.data.Way)

Example 2 with Way

use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.

the class CreateNoteUploadTest method testCreateNoteWithAssociatedElementAndNoNoteYet.

public void testCreateNoteWithAssociatedElementAndNoNoteYet() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    createNote.questTitle = "What?";
    when(mapDataDao.getWay(createNote.elementId)).thenReturn(mock(Way.class));
    Note note = createNote(createNote);
    when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).create(createNote.position, "Unable to answer \"What?\" for https://www.openstreetmap.org/way/5 via " + ApplicationConstants.USER_AGENT + ":\n\njo ho");
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note) Way(de.westnordost.osmapi.map.data.Way)

Example 3 with Way

use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.

the class MergedElementDao method putAll.

public void putAll(Collection<Element> elements) {
    Collection<Node> nodes = new ArrayList<>();
    Collection<Way> ways = new ArrayList<>();
    Collection<Relation> relations = new ArrayList<>();
    for (Element element : elements) {
        switch(element.getType()) {
            case NODE:
                nodes.add((Node) element);
                break;
            case WAY:
                ways.add((Way) element);
                break;
            case RELATION:
                relations.add((Relation) element);
                break;
        }
    }
    if (!nodes.isEmpty())
        nodeDao.putAll(nodes);
    if (!ways.isEmpty())
        wayDao.putAll(ways);
    if (!relations.isEmpty())
        relationDao.putAll(relations);
}
Also used : Relation(de.westnordost.osmapi.map.data.Relation) Node(de.westnordost.osmapi.map.data.Node) Element(de.westnordost.osmapi.map.data.Element) ArrayList(java.util.ArrayList) Way(de.westnordost.osmapi.map.data.Way)

Example 4 with Way

use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.

the class WayDaoTest method testPutGetNoTags.

public void testPutGetNoTags() {
    Way way = new OsmWay(5, 1, Arrays.asList(1L, 2L, 3L, 4L), null);
    dao.put(way);
    Way dbWay = dao.get(5);
    checkEqual(way, dbWay);
}
Also used : OsmWay(de.westnordost.osmapi.map.data.OsmWay) Way(de.westnordost.osmapi.map.data.Way) OsmWay(de.westnordost.osmapi.map.data.OsmWay)

Example 5 with Way

use of de.westnordost.osmapi.map.data.Way in project StreetComplete by westnordost.

the class MergedElementDaoTest method testPutWay.

public void testPutWay() {
    Way way = mock(Way.class);
    when(way.getType()).thenReturn(Element.Type.WAY);
    dao.put(way);
    verify(wayDao).put(way);
}
Also used : OsmWay(de.westnordost.osmapi.map.data.OsmWay) Way(de.westnordost.osmapi.map.data.Way)

Aggregations

Way (de.westnordost.osmapi.map.data.Way)9 OsmWay (de.westnordost.osmapi.map.data.OsmWay)4 Element (de.westnordost.osmapi.map.data.Element)3 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)3 LatLon (de.westnordost.osmapi.map.data.LatLon)2 Node (de.westnordost.osmapi.map.data.Node)2 Relation (de.westnordost.osmapi.map.data.Relation)2 Note (de.westnordost.osmapi.notes.Note)2 ArrayList (java.util.ArrayList)2 LongSparseArray (android.util.LongSparseArray)1 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)1 HashMap (java.util.HashMap)1 List (java.util.List)1