1 | package edu.ucsb.cs156.courses.services; | |
2 | ||
3 | import edu.ucsb.cs156.courses.entities.Grade; | |
4 | import lombok.extern.slf4j.Slf4j; | |
5 | import org.springframework.stereotype.Service; | |
6 | ||
7 | import java.io.Reader; | |
8 | import java.util.ArrayList; | |
9 | import java.util.List; | |
10 | ||
11 | import java.io.FileReader; | |
12 | import com.opencsv.CSVReaderBuilder; | |
13 | import com.opencsv.CSVReader; | |
14 | ||
15 | @Slf4j | |
16 | @Service | |
17 | public class CSVToGradeHistoryServiceImpl implements CSVToGradeHistoryService { | |
18 | ||
19 | @Override | |
20 | public List<Grade> parse(Reader reader) throws Exception { | |
21 | List<Grade> gradeHistoryList = new ArrayList<Grade>(); | |
22 | log.info("Parsing CSV file with grade history... "); | |
23 | CSVReader csvReader = new CSVReader(reader); | |
24 | List<String[]> myEntries = csvReader.readAll(); | |
25 | for (String[] row : myEntries) { | |
26 | Grade grade = Grade.builder() | |
27 | .quarter(row[0]) | |
28 | .courseLevel(row[1]) | |
29 | .courseName(row[2]) | |
30 | .Instructor(row[3]) | |
31 | .grade(row[4]) | |
32 | .studentCount(Integer.parseInt(row[5])) | |
33 | .build(); | |
34 | log.info("Parsed: " + grade.toString()); | |
35 | gradeHistoryList.add(grade); | |
36 | } | |
37 |
1
1. parse : removed call to com/opencsv/CSVReader::close → NO_COVERAGE |
csvReader.close(); |
38 |
1
1. parse : replaced return value with Collections.emptyList for edu/ucsb/cs156/courses/services/CSVToGradeHistoryServiceImpl::parse → NO_COVERAGE |
return gradeHistoryList; |
39 | } | |
40 | ||
41 | } | |
Mutations | ||
37 |
1.1 |
|
38 |
1.1 |