use case more clear, use AtomicInteger API
This commit is contained in:
@@ -34,7 +34,7 @@ public class Course {
|
||||
}
|
||||
|
||||
public Course enrollStudent() {
|
||||
return newCourse().numberOfStudents(numberOfStudents.get() + 1).build();
|
||||
return newCourse().numberOfStudents(numberOfStudents.incrementAndGet()).build();
|
||||
}
|
||||
|
||||
private CourseBuilder newCourse() {
|
||||
|
||||
@@ -72,7 +72,8 @@ public class EnrollStudentUseCase implements EnrollStudentInputPort {
|
||||
persistenceOps.persist(enrollResult.getStudent());
|
||||
|
||||
final Course course = persistenceOps.obtainCourseById(courseId);
|
||||
persistenceOps.persist(course.enrollStudent());
|
||||
final Course updatedCourse = course.enrollStudent();
|
||||
persistenceOps.persist(updatedCourse);
|
||||
}
|
||||
|
||||
// present the result of enrollment
|
||||
|
||||
Reference in New Issue
Block a user