@Test public void build() { List<Task> user1Tasks = mockTasks(USER1_TOTAL_TASKS, USER1_PINNED_TASKS, "container1", 1L); User user1 = mockUser(1, user1Tasks); List<Task> user2Tasks = mockTasks(USER2_TOTAL_TASKS, USER2_PINNED_TASKS, "container2", 2L); User user2 = mockUser(2, user2Tasks); List<Task> user3Tasks = mockTasks(USER3_TOTAL_TASKS, USER3_PINNED_TASKS, "container3", 3L); User user3 = mockUser(3, user3Tasks); List<Task> user4Tasks = mockTasks(USER4_TOTAL_TASKS, USER4_PINNED_TASKS, "container4", 4L); User user4 = mockUser(4, user4Tasks); List<Task> user5Tasks = mockTasks(USER5_TOTAL_TASKS, USER5_PINNED_TASKS, "container5", 5L); User user5 = mockUser(5, user5Tasks); List<Task> user6Tasks = mockTasks(USER6_TOTAL_TASKS, USER6_PINNED_TASKS, "container6", 6L); User user6 = mockUser(6, user6Tasks); List<Task> planningUserTasks = mockTasks(PLANNING_USER_TASKS, 0, "container7", 7L); User planningUser = initializeUser(new User(-1, PLANNING_USER_ID), planningUserTasks); List<Task> totalTasks = new ArrayList<>(); totalTasks.addAll(user1Tasks); totalTasks.addAll(user2Tasks); totalTasks.addAll(user3Tasks); totalTasks.addAll(user4Tasks); totalTasks.addAll(user5Tasks); totalTasks.addAll(user6Tasks); totalTasks.addAll(planningUserTasks); List<User> totalUsers = Arrays.asList(user1, user2, user3, user4, user5, user6, planningUser); TaskAssigningSolution solution = new TaskAssigningSolution(1, totalUsers, totalTasks); List<PlanningItem> planningItems = PlanningBuilder.create() .withPublishWindowSize(publishWindowSize) .withSolution(solution) .build(); assertPlanningItems(user1, publishWindowSize, planningItems); assertPlanningItems(user2, publishWindowSize, planningItems); assertPlanningItems(user3, publishWindowSize, planningItems); assertPlanningItems(user4, publishWindowSize, planningItems); assertPlanningItems(user5, publishWindowSize, planningItems); assertPlanningItems(user6, publishWindowSize, planningItems); assertPlanningUserPlanningItems(planningUser, publishWindowSize, planningItems); }
public List<PlanningItem> build() { return solution.getUserList().stream() .map(this::buildPlanningItems) .flatMap(Collection::stream) .filter(item -> item.getPlanningTask().isPublished()).collect(Collectors.toList()); }
PlanningBuilder { public List<PlanningItem> build() { return solution.getUserList().stream() .map(this::buildPlanningItems) .flatMap(Collection::stream) .filter(item -> item.getPlanningTask().isPublished()).collect(Collectors.toList()); } }
PlanningBuilder { public List<PlanningItem> build() { return solution.getUserList().stream() .map(this::buildPlanningItems) .flatMap(Collection::stream) .filter(item -> item.getPlanningTask().isPublished()).collect(Collectors.toList()); } private  PlanningBuilder(); }
PlanningBuilder { public List<PlanningItem> build() { return solution.getUserList().stream() .map(this::buildPlanningItems) .flatMap(Collection::stream) .filter(item -> item.getPlanningTask().isPublished()).collect(Collectors.toList()); } private  PlanningBuilder(); static PlanningBuilder create(); PlanningBuilder withSolution(TaskAssigningSolution solution); PlanningBuilder withPublishWindowSize(int publishWindowSize); List<PlanningItem> build(); }
PlanningBuilder { public List<PlanningItem> build() { return solution.getUserList().stream() .map(this::buildPlanningItems) .flatMap(Collection::stream) .filter(item -> item.getPlanningTask().isPublished()).collect(Collectors.toList()); } private  PlanningBuilder(); static PlanningBuilder create(); PlanningBuilder withSolution(TaskAssigningSolution solution); PlanningBuilder withPublishWindowSize(int publishWindowSize); List<PlanningItem> build();  }