Fixed some roster tests
This commit is contained in:
parent
3442702197
commit
af74eaaeeb
|
@ -17,6 +17,7 @@ public class ApplyForTaskController {
|
|||
this.applyForTaskUseCase = applyForTaskUseCase;
|
||||
}
|
||||
|
||||
// TODO fix return type
|
||||
/**
|
||||
* Checks if task is available for the requesting executor.
|
||||
* @return a task or null if no task found
|
||||
|
|
|
@ -28,7 +28,7 @@ public class AddNewAssignmentToRosterServiceSystemTest {
|
|||
|
||||
String rosterItemId = "TEST-ID";
|
||||
String executorType = "TEST-TYPE";
|
||||
String executorURI = "TEST-URI";
|
||||
String executorURI = "http://localhost:6969";
|
||||
|
||||
ResponseEntity response = whenAddNewAssignmentToRoster(rosterItemId, executorType, executorURI);
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ public class ApplyForTaskControllerTest {
|
|||
void testApplyForTask() throws Exception{
|
||||
|
||||
String executorType = "TEST-TYPE";
|
||||
String executorURI = "TEST-URI";
|
||||
String executorURI = "http://localhost:6969";
|
||||
String taskId = "TEST-ID";
|
||||
|
||||
String jsonPayLoad = new JSONObject()
|
||||
.put("executorType", executorType )
|
||||
.put("executorUri",executorURI)
|
||||
.put("executorURI",executorURI)
|
||||
.toString();
|
||||
|
||||
RosterItem rosterItem = new RosterItem(taskId, executorType,
|
||||
|
@ -60,7 +60,7 @@ public class ApplyForTaskControllerTest {
|
|||
mockMvc.perform(post("/task/apply/")
|
||||
.contentType("application/json")
|
||||
.content(jsonPayLoad))
|
||||
.andExpect(status().isCreated());
|
||||
.andExpect(status().is2xxSuccessful());
|
||||
|
||||
//TODO: No idea why this does not work yet
|
||||
then(applyForTaskUseCase).should()
|
||||
|
|
|
@ -10,9 +10,11 @@ import org.springframework.boot.test.autoconfigure.data.mongo.AutoConfigureDataM
|
|||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@AutoConfigureDataMongo
|
||||
@Import({RosterPersistenceAdapter.class, RosterMapper.class})
|
||||
public class RosterPersistenceAdapterTest {
|
||||
|
@ -26,7 +28,7 @@ public class RosterPersistenceAdapterTest {
|
|||
@Test
|
||||
void addsNewRosterItem(){
|
||||
|
||||
String taskId = "TEST-ID";
|
||||
String taskId = UUID.randomUUID().toString();
|
||||
String executorType = "TEST-TYPE";
|
||||
String executorURI = "TEST-URI";
|
||||
|
||||
|
@ -35,6 +37,8 @@ public class RosterPersistenceAdapterTest {
|
|||
executorType,
|
||||
new ExecutorURI(executorURI)
|
||||
);
|
||||
|
||||
|
||||
adapterUnderTest.addRosterItem(testRosterItem);
|
||||
|
||||
MongoRosterDocument retrievedDoc = rosterRepository.findByTaskId(taskId);
|
||||
|
@ -48,7 +52,7 @@ public class RosterPersistenceAdapterTest {
|
|||
@Test
|
||||
void retrievesRosterItem(){
|
||||
|
||||
String taskId = "TEST-ID";
|
||||
String taskId = UUID.randomUUID().toString();
|
||||
String executorType = "TEST-TYPE";
|
||||
String executorURI = "TEST-URI";
|
||||
|
||||
|
@ -59,6 +63,6 @@ public class RosterPersistenceAdapterTest {
|
|||
|
||||
assertThat(retrievedRosterItem.getTaskID()).isEqualTo(taskId);
|
||||
assertThat(retrievedRosterItem.getTaskType()).isEqualTo(executorType);
|
||||
assertThat(retrievedRosterItem.getExecutorURI()).isEqualTo(executorURI);
|
||||
assertThat(retrievedRosterItem.getExecutorURI().getValue().toString()).isEqualTo(executorURI);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
spring.data.mongodb.uri=mongodb://127.0.0.1:27017
|
||||
spring.data.mongodb.database=tapas-tasks
|
||||
spring.data.mongodb.database=tapas-roster
|
||||
|
|
|
@ -26,28 +26,30 @@ public class TaskPersistenceAdapterTest {
|
|||
@Test
|
||||
void addsNewTask() {
|
||||
|
||||
// String testTaskId = UUID.randomUUID().toString();
|
||||
// String testTaskName = "adds-persistence-task-name";
|
||||
// String testTaskType = "adds-persistence-task-type";
|
||||
// String testTaskOuri = "adds-persistence-test-task-ouri";
|
||||
// String testTaskStatus = Task.Status.OPEN.toString();
|
||||
// String testTaskListName = "tapas-tasks-tutors";
|
||||
String testTaskId = UUID.randomUUID().toString();
|
||||
String testTaskName = "adds-persistence-task-name";
|
||||
String testTaskType = "adds-persistence-task-type";
|
||||
String testTaskOuri = "adds-persistence-test-task-ouri";
|
||||
String testTaskStatus = Task.Status.OPEN.toString();
|
||||
String testTaskListName = "tapas-tasks-tutors";
|
||||
|
||||
|
||||
// Task testTask = new Task(
|
||||
// new Task.TaskId(testTaskId),
|
||||
// new Task.TaskName(testTaskName),
|
||||
// new Task.TaskType(testTaskType),
|
||||
// new Task.OriginalTaskUri(testTaskOuri),
|
||||
// new Task.TaskStatus(Task.Status.valueOf(testTaskStatus))
|
||||
// );
|
||||
// adapterUnderTest.addTask(testTask);
|
||||
Task testTask = new Task(
|
||||
new Task.TaskId(testTaskId),
|
||||
new Task.TaskName(testTaskName),
|
||||
new Task.TaskType(testTaskType),
|
||||
new Task.OriginalTaskUri(testTaskOuri),
|
||||
new Task.TaskStatus(Task.Status.valueOf(testTaskStatus)),
|
||||
new Task.InputData("asd"),
|
||||
new Task.OutputData("")
|
||||
);
|
||||
adapterUnderTest.addTask(testTask);
|
||||
|
||||
// MongoTaskDocument retrievedDoc = taskRepository.findByTaskId(testTaskId,testTaskListName);
|
||||
MongoTaskDocument retrievedDoc = taskRepository.findByTaskId(testTaskId,testTaskListName);
|
||||
|
||||
// assertThat(retrievedDoc.taskId).isEqualTo(testTaskId);
|
||||
// assertThat(retrievedDoc.taskName).isEqualTo(testTaskName);
|
||||
// assertThat(retrievedDoc.taskListName).isEqualTo(testTaskListName);
|
||||
assertThat(retrievedDoc.taskId).isEqualTo(testTaskId);
|
||||
assertThat(retrievedDoc.taskName).isEqualTo(testTaskName);
|
||||
assertThat(retrievedDoc.taskListName).isEqualTo(testTaskListName);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user