RosterStudentDTOService.java

1
package edu.ucsb.cs156.frontiers.services;
2
3
import java.io.IOException;
4
import java.io.OutputStream;
5
import java.io.OutputStreamWriter;
6
import java.io.Writer;
7
import java.nio.charset.StandardCharsets;
8
import java.util.List;
9
import java.util.stream.Collectors;
10
import java.util.stream.StreamSupport;
11
12
import com.opencsv.bean.StatefulBeanToCsv;
13
import com.opencsv.bean.StatefulBeanToCsvBuilder;
14
import org.springframework.beans.factory.annotation.Autowired;
15
import org.springframework.stereotype.Service;
16
17
import edu.ucsb.cs156.frontiers.entities.RosterStudent;
18
import edu.ucsb.cs156.frontiers.models.RosterStudentDTO;
19
import edu.ucsb.cs156.frontiers.repositories.RosterStudentRepository;
20
21
@Service
22
public class RosterStudentDTOService {
23
24
25
    @Autowired
26
    private RosterStudentRepository rosterStudentRepository;
27
28
    /**
29
     * This method gets a list of RosterStudentDTOs based on the courseId
30
     * 
31
     * @param courseId if of the course
32
     * @return a list of RosterStudentDTOs
33
     */
34
    public List<RosterStudentDTO> getRosterStudentDTOs(Long courseId) {
35
        Iterable<RosterStudent> matchedStudents = rosterStudentRepository.findByCourseId(courseId);
36
        
37 1 1. getRosterStudentDTOs : replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/services/RosterStudentDTOService::getRosterStudentDTOs → KILLED
        return StreamSupport.stream(matchedStudents.spliterator(), false)
38
            .map(RosterStudentDTO::from)
39
            .collect(Collectors.toList());
40
41
    }
42
43
    public StatefulBeanToCsv<RosterStudentDTO> getStatefulBeanToCSV(Writer writer) throws IOException {
44 1 1. getStatefulBeanToCSV : replaced return value with null for edu/ucsb/cs156/frontiers/services/RosterStudentDTOService::getStatefulBeanToCSV → KILLED
        return new StatefulBeanToCsvBuilder<RosterStudentDTO>(writer).build();
45
    }
46
47
   
48
}

Mutations

37

1.1
Location : getRosterStudentDTOs
Killed by : edu.ucsb.cs156.frontiers.services.RosterStudentDTOServiceTests.[engine:junit-jupiter]/[class:edu.ucsb.cs156.frontiers.services.RosterStudentDTOServiceTests]/[method:test_getRosterStudentDTOById_success()]
replaced return value with Collections.emptyList for edu/ucsb/cs156/frontiers/services/RosterStudentDTOService::getRosterStudentDTOs → KILLED

44

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

Active mutators

Tests examined


Report generated by PIT 1.17.0