Skip to content

Commit

Permalink
Merge pull request #50 from bgarciaentornos/errorTestCase
Browse files Browse the repository at this point in the history
Adding unit test for a different error case
  • Loading branch information
buckett committed Apr 8, 2022
2 parents 8bcd2d5 + 43e2a1b commit 181c346
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/test/java/edu/ksu/canvas/errors/ErrorsJsonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,21 @@ public void testFailedCourseDateError() {
assertNotNull(error.getMessage());
assertNotNull(error.getType());
}

@Test
public void testFailedCourseSisIdError() {
InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/SampleJson/course/CreateCourseSisidError.json"));
Gson gson = GsonResponseParser.getDefaultGsonParser(false);
GenericErrorResponse response = gson.fromJson(reader, GenericErrorResponse.class);
assertNotNull(response);
assertNotNull(response.getErrors());
assertNotNull(response.getErrors().get("sis_source_id"));
assertEquals(1, response.getErrors().get("sis_source_id").size());
List<ErrorDetails> errors = response.getErrors().get("sis_source_id");
assertNotNull(errors);
ErrorDetails error = errors.get(0);
assertEquals("sis_source_id", error.getAttribute());
assertNotNull(error.getMessage());
assertNotNull(error.getType());
}
}
11 changes: 11 additions & 0 deletions src/test/resources/SampleJson/course/CreateCourseSisidError.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"errors": {
"sis_source_id": [
{
"attribute": "sis_source_id",
"type": "SIS ID \"123\" is already in use",
"message": "SIS ID \"123\" is already in use"
}
]
}
}

0 comments on commit 181c346

Please sign in to comment.