use of io.jawg.osmcontributor.ui.managers.NoteManager in project osm-contributor by jawg.
the class NoteManagerTest method testSaveAndQuery.
@Test
public void testSaveAndQuery() {
NoteManager noteManager = component.getNoteManager();
Note note = getNote(1);
Note saved = noteManager.saveNote(note);
Note queried = noteManager.queryForId(saved.getId());
Comment queriedComment = ((ArrayList<Comment>) queried.getComments()).get(0);
assertThat(queried.getLatitude()).isEqualTo(42.0);
assertThat(queried.getLongitude()).isEqualTo(73.0);
assertThat(queried.getUpdated()).isTrue();
assertThat(queriedComment.getText()).isEqualTo("firstComment1");
}
use of io.jawg.osmcontributor.ui.managers.NoteManager in project osm-contributor by jawg.
the class NoteManagerTest method testBulkSaveAndBulkUpdate.
@Test
public void testBulkSaveAndBulkUpdate() {
NoteManager noteManager = component.getNoteManager();
// try to save and then update 1000 notes.
// 1000 because it can happen in real life and pose problems if we try to do an "IN" sql clause
List<Note> notes = new ArrayList<>(1000);
for (int i = 0; i < 1000; i++) {
notes.add(getNote(i));
}
noteManager.saveNotes(notes);
for (Note note : notes) {
assertThat(note.getId()).isNotNull();
}
for (Note note : notes) {
Comment newComment = new Comment();
newComment.setText("secondComment");
newComment.setAction(Comment.ACTION_OPEN);
newComment.setNote(note);
newComment.setUpdated(true);
newComment.setCreatedDate(new DateTime());
note.getComments().clear();
note.getComments().add(newComment);
}
List<Note> savedNotes = noteManager.saveNotes(notes);
for (Note note : savedNotes) {
assertThat(note.getComments()).hasSize(1);
Comment com = ((ArrayList<Comment>) note.getComments()).get(0);
assertThat(com.getText()).isEqualTo("secondComment");
}
}