CourseStaffDTOService.java

1
package edu.ucsb.cs156.frontiers.services;
2
3
import com.opencsv.bean.StatefulBeanToCsv;
4
import com.opencsv.bean.StatefulBeanToCsvBuilder;
5
import edu.ucsb.cs156.frontiers.entities.CourseStaff;
6
import edu.ucsb.cs156.frontiers.models.CourseStaffDTO;
7
import edu.ucsb.cs156.frontiers.repositories.CourseStaffRepository;
8
import java.io.IOException;
9
import java.io.Writer;
10
import java.util.List;
11
import java.util.stream.Collectors;
12
import java.util.stream.StreamSupport;
13
import org.springframework.beans.factory.annotation.Autowired;
14
import org.springframework.stereotype.Service;
15
16
@Service
17
public class CourseStaffDTOService {
18
19
  @Autowired private CourseStaffRepository courseStaffRepository;
20
21
  /**
22
   * This method gets a list of CourseStaffDTOs based on the courseId
23
   *
24
   * @param courseId id of the course
25
   * @return a list of CourseStaffDTOs
26
   */
27
  public List<CourseStaffDTO> getCourseStaffDTOs(Long courseId) {
28
    Iterable<CourseStaff> matchedStaff = courseStaffRepository.findByCourseId(courseId);
29
30 1 1. getCourseStaffDTOs : replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/services/CourseStaffDTOService::getCourseStaffDTOs → KILLED
    return StreamSupport.stream(matchedStaff.spliterator(), false)
31
        .map(CourseStaffDTO::new)
32
        .collect(Collectors.toList());
33
  }
34
35
  public StatefulBeanToCsv<CourseStaffDTO> getStatefulBeanToCSV(Writer writer) throws IOException {
36 1 1. getStatefulBeanToCSV : replaced return value with null for edu/ucsb/cs156/frontiers/services/CourseStaffDTOService::getStatefulBeanToCSV → KILLED
    return new StatefulBeanToCsvBuilder<CourseStaffDTO>(writer).build();
37
  }
38
}

Mutations

30

1.1
Location : getCourseStaffDTOs
Killed by : edu.ucsb.cs156.frontiers.services.CourseStaffDTOServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.CourseStaffDTOServiceTests]/[method:test_getCourseStaffDTOs_nullUser()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/services/CourseStaffDTOService::getCourseStaffDTOs → KILLED

36

1.1
Location : getStatefulBeanToCSV
Killed by : edu.ucsb.cs156.frontiers.controllers.CSVDownloadsControllerTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.controllers.CSVDownloadsControllerTests]/[method:test_staff_csv_download()]
replaced return value with null for edu/ucsb/cs156/frontiers/services/CourseStaffDTOService::getStatefulBeanToCSV → KILLED

Active mutators

Tests examined


Report generated by PIT 1.17.0