Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update text-ui-test to test file error handling of Storage #221

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/tutorlink/storage/ComponentStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* The file contains data on each component with its name, maximum score, and weight.
*/
public class ComponentStorage extends Storage {
private static final double MAX_SCORE = 10000.0;

/**
* Constructs a {@code ComponentStorage} with the specified file path.
Expand Down Expand Up @@ -87,7 +88,7 @@ private Component getComponentFromFileLine(
throw new InvalidDataFileLineException(fileLine);
}

boolean isValidMaxScore = (maxScore >= 0);
boolean isValidMaxScore = (maxScore >= 0 && maxScore <= MAX_SCORE);
boolean isValidWeight = (weight >= 0 && (weight + totalWeight) <= 100);
Component newComponent = new Component(name, maxScore, weight);
if (!isValidMaxScore || !isValidWeight || components.contains(newComponent)) {
Expand Down
17 changes: 17 additions & 0 deletions text-ui-test/EXPECTED.TXT
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
-------------------------------------------------------------
Discarded student data:
A1111111B| John Smith
A1111111B | John Smith
A123B | Beth
-------------------------------------------------------------
Discarded component data:
Attendance | 5 | 5
Finals | 80 | 96
Test 1 | 10 | -0.1
Test 2 | -0.01 | 5
Test 3 | 10000.01 | 5
-------------------------------------------------------------
Discarded grade data:
Attendance | A1111111B | 5.01
Attendance | A1111111B | 4
Attendance | A1111111B | 4
-------------------------------------------------------------
___________ __ .____ .__ __
\__ ___/_ ___/ |_ ___________| | |__| ____ | | __
| | | | \ __\/ _ \_ __ \ | | |/ \| |/ /
Expand Down
5 changes: 5 additions & 0 deletions text-ui-test/data_init/componentlist.txt
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
Attendance | 5 | 5
Attendance | 5 | 5
Finals | 80 | 96
Test 1 | 10 | -0.1
Test 2 | -0.01 | 5
Test 3 | 10000.01 | 5
3 changes: 3 additions & 0 deletions text-ui-test/data_init/gradelist.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Attendance | A1111111B | 5.01
Attendance | A1111111B | 4
Attendance | A1111111B | 4
Attendance | A1111111B | 4
3 changes: 3 additions & 0 deletions text-ui-test/data_init/studentlist.txt
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
A1111111B| John Smith
A1111111B | John Smith
A1111111B | John Smith
A123B | Beth
Loading