Skip to content
Snippets Groups Projects
Commit 8f2c4c1a authored by TalatAltan's avatar TalatAltan
Browse files

lect09 Aufgabe 2.2

parent ad4172a0
No related branches found
No related tags found
No related merge requests found
......@@ -62,6 +62,8 @@ public class AccountServiceController {
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
}
restService.updateTasksOnUserUpdateTaskService(userUpdate, id);
log.info("Updated registered user to: {\n{}}", updatedUser.toString());
return new ResponseEntity<>(updatedUser, HttpStatus.OK);
}
......@@ -73,6 +75,8 @@ public class AccountServiceController {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
restService.deleteTasksForUserWithIdFromTaskService(userId);
log.info("Returning task: {\n{}}", task.toString());
return new ResponseEntity<>(task, HttpStatus.OK);
}
......
......@@ -11,7 +11,7 @@
<artifactId>TaskManagerTaskServiceHBRS</artifactId>
<groupId>de.hbrs.demo.taskservice</groupId>
<name>Task Manager Account Service</name>
<name>Task Manager Task Service</name>
<description>Demo project for Micro Service Communication: Task Manager MS</description>
<properties>
......
......@@ -82,8 +82,8 @@ public class TaskServiceController {
return new ResponseEntity(HttpStatus.NOT_FOUND);
}
final List<Task> updatedTasks = new ArrayList<>();
// TODO: implement: final List<Task> updatedTasks = ephemeralStorage.trimTasksToMaxTasks(userId, userByIdFromAccountService.getMaxTasks());
//final List<Task> updatedTasks = new ArrayList<>();
final List<Task> updatedTasks = ephemeralStorage.trimTasksToMaxTasks(userId, userByIdFromAccountService.getMaxTasks());
log.info("Updated tasks of user to assignment limit: {\n{}}", updatedTasks.toString());
return new ResponseEntity<>(updatedTasks, HttpStatus.OK);
......
......@@ -6,6 +6,7 @@ import de.hbrs.demo.taskservice.model.User;
import org.springframework.stereotype.Repository;
import java.util.*;
import java.util.stream.Collectors;
@Repository
public class EphemeralStorage {
......@@ -82,4 +83,9 @@ public class EphemeralStorage {
public List<Task> getTasksForUserWithId(final long id) {
return this.tasks.get(id);
}
public List<Task> trimTasksToMaxTasks(long userId, long maxTasks) {
tasks.put(userId, getTasksForUserWithId(userId).stream().limit(maxTasks).collect(Collectors.toList()));
return getTasksForUserWithId(userId);
}
}
......@@ -69,9 +69,9 @@ class EphemeralStorageTest {
underTest.addTask(1, task);
underTest.addTask(1, taskTwo);
final int sizeBeforeTrim = underTest.getTasksForUserWithId(1).size();
// TODO: underTest.trimTasksToMaxTasks(1, 2);
underTest.trimTasksToMaxTasks(1, 2);
final int sizeNoTrim = underTest.getTasksForUserWithId(1).size();
// TODO: underTest.trimTasksToMaxTasks(1, 1);
underTest.trimTasksToMaxTasks(1, 1);
final List<Task> tasksForUserWithIdTrim = underTest.getTasksForUserWithId(1);
// then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment