Exercise 8 PR #95
|
@ -56,6 +56,7 @@ public class ApplyForTaskControllerTest {
|
|||
Mockito.when(applyForTaskUseCase.applyForTask(applyForTaskCommand))
|
||||
.thenReturn(taskStub);
|
||||
|
||||
// TODO Add slash at the front
|
||||
mockMvc.perform(post("tasks/apply/")
|
||||
.contentType("application/json")
|
||||
.content(jsonPayLoad))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ch.unisg.roster.roster.application.service;
|
||||
|
||||
import ch.unisg.common.valueobject.ExecutorURI;
|
||||
import ch.unisg.roster.roster.application.port.in.AddRosterItemPort;
|
||||
import ch.unisg.roster.roster.application.port.in.ApplyForTaskCommand;
|
||||
import ch.unisg.roster.roster.application.port.in.DeleteRosterItem;
|
||||
|
@ -12,6 +13,7 @@ import ch.unisg.roster.roster.domain.RosterItem;
|
|||
import ch.unisg.roster.roster.domain.Task;
|
||||
import ch.unisg.roster.roster.domain.event.NewTaskEvent;
|
||||
import ch.unisg.roster.roster.domain.event.TaskAssignedEvent;
|
||||
import ch.unisg.roster.roster.domain.valueobject.ExecutorType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
@ -39,7 +41,7 @@ public class AddNewAssignmentToRosterServiceTest {
|
|||
|
||||
Task newTask = givenATaskWithIdAndType("test-id", "test-type", "test-input");
|
||||
RosterItem newRosterItem = givenARosterItemWithIdAndTypeAndExecutorUri("test-id", "test-type", "test-uri");
|
||||
|
||||
// TODO Add task to queue
|
||||
|
||||
ApplyForTaskCommand applyForTaskCommand = new ApplyForTaskCommand(newTask.getTaskType(), newRosterItem.getExecutorURI());
|
||||
|
||||
|
@ -57,14 +59,14 @@ public class AddNewAssignmentToRosterServiceTest {
|
|||
RosterItem rosterItem = Mockito.mock(RosterItem.class);
|
||||
given(rosterItem.getTaskID()).willReturn(taskId);
|
||||
given(rosterItem.getTaskType()).willReturn(taskType);
|
||||
given(rosterItem.getExecutorURI().getValue()).willReturn(URI.create(executorURI));
|
||||
given(rosterItem.getExecutorURI()).willReturn(new ExecutorURI(executorURI));
|
||||
return rosterItem;
|
||||
}
|
||||
|
||||
private Task givenATaskWithIdAndType(String taskId, String taskType, String inputData) {
|
||||
Task task = Mockito.mock(Task.class);
|
||||
given(task.getTaskID()).willReturn(taskId);
|
||||
given(task.getTaskType().getValue()).willReturn(taskType);
|
||||
given(task.getTaskType()).willReturn(new ExecutorType(taskType));
|
||||
given(task.getInputData()).willReturn(inputData);
|
||||
return task;
|
||||
}
|
||||
|
|
|
@ -18,13 +18,18 @@ public class RosterTest {
|
|||
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
|
||||
|
@ -37,5 +42,6 @@ public class RosterTest {
|
|||
boolean test = roster.deleteTask("test-id", new ExecutorType("test-type"));
|
||||
|
||||
assertThat(test).isEqualTo(true);
|
||||
// TODO check that the queue has size 0
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user