Search in sources :

Example 21 with Note

use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.

the class NoteDao method putAll.

public void putAll(Collection<Note> notes) {
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    db.beginTransaction();
    for (Note note : notes) {
        executeInsert(note);
    }
    db.setTransactionSuccessful();
    db.endTransaction();
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) Note(de.westnordost.osmapi.notes.Note)

Example 22 with Note

use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.

the class CreateNoteUploadTest method testCreateNoteUploadsImagesAndDisplaysLinks.

public void testCreateNoteUploadsImagesAndDisplaysLinks() {
    CreateNote createNote = createACreateNote();
    createNote.imagePaths = new ArrayList<>();
    createNote.imagePaths.add("hello");
    Note note = createNote(null);
    when(notesDao.create(any(LatLon.class), anyString())).thenReturn(note);
    when(imageUploader.upload(createNote.imagePaths)).thenReturn(Collections.singletonList("hello, too"));
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(imageUploader).upload(createNote.imagePaths);
    verify(notesDao).create(createNote.position, "jo ho\n\nAttached photo(s):\nhello, too");
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Note(de.westnordost.osmapi.notes.Note)

Example 23 with Note

use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.

the class CreateNoteUploadTest method testCommentNoteUploadsImagesAndDisplaysLinks.

public void testCommentNoteUploadsImagesAndDisplaysLinks() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    createNote.imagePaths = new ArrayList<>();
    createNote.imagePaths.add("hello");
    Note note = createNote(createNote);
    setUpThereIsANoteFor(createNote, note);
    when(imageUploader.upload(createNote.imagePaths)).thenReturn(Collections.singletonList("hello, too"));
    when(notesDao.comment(anyLong(), anyString())).thenReturn(note);
    assertNotNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).comment(note.id, "jo ho\n\nAttached photo(s):\nhello, too");
    verifyNoteInsertedIntoDb(createNote.id, note);
}
Also used : Note(de.westnordost.osmapi.notes.Note)

Example 24 with Note

use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.

the class CreateNoteUploadTest method testCreateNoteOnExistingNoteWillCancelWhenConflictException.

public void testCreateNoteOnExistingNoteWillCancelWhenConflictException() {
    CreateNote createNote = createACreateNote();
    createNote.elementType = Element.Type.WAY;
    createNote.elementId = 5L;
    Note note = createNote(createNote);
    setUpThereIsANoteFor(createNote, note);
    when(notesDao.comment(anyLong(), anyString())).thenThrow(OsmConflictException.class);
    assertNull(createNoteUpload.uploadCreateNote(createNote));
    verify(notesDao).comment(note.id, createNote.text);
    verifyNoteNotInsertedIntoDb(createNote.id);
}
Also used : Note(de.westnordost.osmapi.notes.Note)

Example 25 with Note

use of de.westnordost.osmapi.notes.Note in project StreetComplete by westnordost.

the class OsmNoteQuestChangesUploadTest method createQuest.

private static OsmNoteQuest createQuest() {
    Note note = new Note();
    note.id = 1;
    note.position = new OsmLatLon(1.0, 2.0);
    OsmNoteQuest quest = new OsmNoteQuest(note, new OsmNoteQuestType());
    quest.setId(3);
    quest.setStatus(QuestStatus.NEW);
    quest.setComment("blablub");
    return quest;
}
Also used : Note(de.westnordost.osmapi.notes.Note) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Aggregations

Note (de.westnordost.osmapi.notes.Note)32 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)10 Date (java.util.Date)8 LatLon (de.westnordost.osmapi.map.data.LatLon)5 ArrayList (java.util.ArrayList)5 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)4 NoteComment (de.westnordost.osmapi.notes.NoteComment)3 Way (de.westnordost.osmapi.map.data.Way)2 QuestStatus (de.westnordost.streetcomplete.data.QuestStatus)2 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 View (android.view.View)1 Button (android.widget.Button)1 TextView (android.widget.TextView)1 Handler (de.westnordost.osmapi.common.Handler)1 SingleElementHandler (de.westnordost.osmapi.common.SingleElementHandler)1 OsmConflictException (de.westnordost.osmapi.common.errors.OsmConflictException)1 NotesDao (de.westnordost.osmapi.notes.NotesDao)1 User (de.westnordost.osmapi.user.User)1 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)1 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)1