package ch.unisg.roster.roster.domain;

import ch.unisg.common.valueobject.ExecutorURI;
import ch.unisg.roster.roster.domain.valueobject.ExecutorType;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

import static org.assertj.core.api.Assertions.*;


public class RosterTest {

    @Test
    void addAssignmentToRosterMapTest(){
        Roster roster = Roster.getInstance();
        Collection<RosterItem> rosterMap = roster.getRosterMap();
        rosterMap.clear();
        // TODO change test-type to upper case
        roster.addTaskToQueue(new Task("test-id", "test-type"));
        Task task = roster.assignTaskToExecutor(new ExecutorType("test-type"), new ExecutorURI("Test-URI"));

        assertThat(rosterMap.size()).isEqualTo(1);
        assertThat(rosterMap.iterator().next().getTaskID()).isEqualTo("test-id");
        assertThat(rosterMap.iterator().next().getTaskType()).isEqualTo("test-type");
        // TODO test uri

        // TODO test id and type of Task task

        // TODO test that the task was removed from the Queue similar to below
    }

    @Test
    void removeTaskFromQueue(){
        Roster roster = Roster.getInstance();
        Collection<ArrayList<Task>> queues = roster.getAllTasksFromQueue();
        queues.clear();
        roster.addTaskToQueue(new Task("test-id", "test-type"));

        boolean test = roster.deleteTask("test-id", new ExecutorType("test-type"));

        assertThat(test).isEqualTo(true);
        // TODO check that the queue has size 0
    }
}
