use of it.niedermann.owncloud.notes.shared.model.DBStatus.LOCAL_EDITED in project nextcloud-notes by stefan-niedermann.
the class NotesDaoTest method getRemoteIds.
@Test
public void getRemoteIds() {
final var secondAccount = setupSecondAccount();
db.getNoteDao().addNote(new Note(1, 4711L, Calendar.getInstance(), "T", "C", "", false, "1", VOID, account.getId(), "", 0));
db.getNoteDao().addNote(new Note(2, 1234L, Calendar.getInstance(), "T", "C", "", false, "1", LOCAL_EDITED, account.getId(), "", 0));
db.getNoteDao().addNote(new Note(3, 1234L, Calendar.getInstance(), "T", "C", "", false, "1", LOCAL_EDITED, secondAccount.getId(), "", 0));
db.getNoteDao().addNote(new Note(4, 6969L, Calendar.getInstance(), "T", "C", "", false, "1", LOCAL_DELETED, account.getId(), "", 0));
final List<Long> remoteIdsOfAccount = db.getNoteDao().getRemoteIds(account.getId());
assertTrue(remoteIdsOfAccount.stream().anyMatch(id -> 4711 == id));
assertTrue(remoteIdsOfAccount.stream().anyMatch(id -> 1234 == id));
assertEquals("Remote IDs can only occur a single time, like in a set.", 1, remoteIdsOfAccount.stream().filter(id -> 1234 == id).count());
assertFalse("Remote IDs from notes of other accounts must not be returned.", remoteIdsOfAccount.stream().anyMatch(id -> 6969 == id));
}
use of it.niedermann.owncloud.notes.shared.model.DBStatus.LOCAL_EDITED in project nextcloud-notes by stefan-niedermann.
the class NotesDaoTest method getRemoteIdAndId.
@Test
public void getRemoteIdAndId() {
db.getNoteDao().addNote(new Note(815, 4711L, Calendar.getInstance(), "T", "C", "", false, "1", VOID, account.getId(), "", 0));
db.getNoteDao().addNote(new Note(666, 1234L, Calendar.getInstance(), "T", "C", "", false, "1", LOCAL_EDITED, account.getId(), "", 0));
db.getNoteDao().addNote(new Note(987, 6969L, Calendar.getInstance(), "T", "C", "", false, "1", LOCAL_DELETED, account.getId(), "", 0));
final var pair = db.getNoteDao().getRemoteIdAndId(account.getId());
assertEquals(2, pair.size());
assertTrue(pair.stream().anyMatch(note -> 815 == note.getId() && Long.valueOf(4711).equals(note.getRemoteId())));
assertTrue(pair.stream().anyMatch(note -> 666 == note.getId() && Long.valueOf(1234).equals(note.getRemoteId())));
assertFalse("Result must not contain deleted note", pair.stream().anyMatch(note -> 987 == note.getId()));
assertFalse("Result must not contain deleted note", pair.stream().anyMatch(note -> Long.valueOf(6969).equals(note.getRemoteId())));
}
Aggregations