package dst.ass1.doc.tests;

import static org.hamcrest.Matchers.hasItems;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.util.List;

import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import dst.ass1.doc.DocumentTestData;
import dst.ass1.doc.EmbeddedMongo;
import dst.ass1.doc.MongoService;

public class Ass1_4_2bTest {

    @ClassRule
    public static EmbeddedMongo embeddedMongo = new EmbeddedMongo();

    @Rule
    public MongoService mongo = new MongoService(new DocumentTestData());

    @Test
    public void findIdsByType_returnsCorrectMaterialIds() throws Exception {
        List<Long> quizMaterialIds = mongo.getDocumentQuery().findIdsByType("quiz");
        assertThat(quizMaterialIds, hasItems(1L, 2L, 3L, 5L));
    }

    @Test
    public void findIdsByType_withNonExistingType_returnsNoMaterialIds() throws Exception {
        List<Long> quizMaterialIds = mongo.getDocumentQuery().findIdsByType("NONEXISTING");
        assertNotNull(quizMaterialIds);
        assertTrue(quizMaterialIds.isEmpty());
    }

}
