Search in sources :

Example 1 with ItemsPerPreview

use of de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview in project Neuronizer by djuelg.

the class PreviewRepositoryImplTest method testGetPreviewManyItemsPerPreview.

@Test
public void testGetPreviewManyItemsPerPreview() {
    Iterable<Preview> previews = repository.getAll(new ItemsPerPreview(100));
    assertEquals("Header 1", previews.iterator().next().getSubtitle());
    assertEquals(1, Lists.newArrayList(previews).size());
}
Also used : ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) Preview(de.djuelg.neuronizer.domain.model.preview.Preview) ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 2 with ItemsPerPreview

use of de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview in project Neuronizer by djuelg.

the class DisplayPreviewInteractorImpl method run.

@Override
public void run() {
    Iterable<Preview> previews = repository.preview().getAll(new ItemsPerPreview(MAX_DISPLAYED_ITEMS));
    postPreviews(previews);
}
Also used : ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) Preview(de.djuelg.neuronizer.domain.model.preview.Preview) ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview)

Example 3 with ItemsPerPreview

use of de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview in project Neuronizer by djuelg.

the class PreviewRepositoryImpl method getAll.

@Override
public Iterable<Preview> getAll(ItemsPerPreview itemsPerPreview) {
    Realm realm = Realm.getInstance(configuration);
    RealmResults<TodoListDAO> allTodoListDAO = realm.where(TodoListDAO.class).findAllSorted("position", Sort.DESCENDING);
    RealmResults<NoteDAO> allNoteDAO = realm.where(NoteDAO.class).findAllSorted("position", Sort.DESCENDING);
    List<Preview> previews = new ArrayList<>(allTodoListDAO.size() + allNoteDAO.size());
    for (TodoListDAO todoListDAO : allTodoListDAO) {
        previews.add(constructPreview(realm, todoListDAO, itemsPerPreview));
    }
    for (NoteDAO noteDAO : allNoteDAO) {
        previews.add(new NotePreview(RealmConverter.convert(noteDAO)));
    }
    realm.close();
    return previews;
}
Also used : NoteDAO(de.djuelg.neuronizer.storage.model.NoteDAO) NotePreview(de.djuelg.neuronizer.domain.model.preview.NotePreview) ArrayList(java.util.ArrayList) Preview(de.djuelg.neuronizer.domain.model.preview.Preview) NotePreview(de.djuelg.neuronizer.domain.model.preview.NotePreview) ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) TodoListPreview(de.djuelg.neuronizer.domain.model.preview.TodoListPreview) Realm(io.realm.Realm) TodoListDAO(de.djuelg.neuronizer.storage.model.TodoListDAO)

Example 4 with ItemsPerPreview

use of de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview in project Neuronizer by djuelg.

the class PreviewRepositoryImplTest method testEmptyGetPreview.

@Test
public void testEmptyGetPreview() {
    clearRealm();
    Iterable<Preview> previews = repository.getAll(new ItemsPerPreview(0));
    assertEquals(false, previews.iterator().hasNext());
    fillRealm();
}
Also used : ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) Preview(de.djuelg.neuronizer.domain.model.preview.Preview) ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Example 5 with ItemsPerPreview

use of de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview in project Neuronizer by djuelg.

the class PreviewRepositoryImplTest method testGetPreviewCorrectHeader.

@Test
public void testGetPreviewCorrectHeader() {
    Iterable<Preview> previews = repository.getAll(new ItemsPerPreview(0));
    assertEquals("Header 1", previews.iterator().next().getSubtitle());
}
Also used : ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) Preview(de.djuelg.neuronizer.domain.model.preview.Preview) ItemsPerPreview(de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview) MediumTest(android.support.test.filters.MediumTest) Test(org.junit.Test)

Aggregations

ItemsPerPreview (de.djuelg.neuronizer.domain.model.preview.ItemsPerPreview)5 Preview (de.djuelg.neuronizer.domain.model.preview.Preview)5 MediumTest (android.support.test.filters.MediumTest)3 Test (org.junit.Test)3 NotePreview (de.djuelg.neuronizer.domain.model.preview.NotePreview)1 TodoListPreview (de.djuelg.neuronizer.domain.model.preview.TodoListPreview)1 NoteDAO (de.djuelg.neuronizer.storage.model.NoteDAO)1 TodoListDAO (de.djuelg.neuronizer.storage.model.TodoListDAO)1 Realm (io.realm.Realm)1 ArrayList (java.util.ArrayList)1