Refactor SMDRL + Claims CSV parsing (#1704)

This uses the Apache commons CSV parsing instead of rolling our own.

Annoyingly, the results that we're given aren't exactly proper CSVs
since they have a non-standard line of data at the top, and the header
is actually the second line.
This commit is contained in:
gbrodman
2022-07-12 15:42:12 -04:00
committed by GitHub
parent 02145d34d9
commit dbb96d36d3
6 changed files with 56 additions and 62 deletions
@@ -79,7 +79,7 @@ class SmdrlCsvParserTest {
}
@Test
void testOneRow() {
void testOneRow() throws Exception {
SignedMarkRevocationList smdrl =
SmdrlCsvParser.parse(
ImmutableList.of(
@@ -93,7 +93,7 @@ class SmdrlCsvParserTest {
}
@Test
void testEmpty() {
void testEmpty() throws Exception {
SignedMarkRevocationList smdrl =
SmdrlCsvParser.parse(
ImmutableList.of("1,2014-11-24T23:30:04.3Z", "smd-id,insertion-datetime"));
@@ -128,7 +128,9 @@ class SmdrlCsvParserTest {
"1,2013-11-24T23:30:04.3Z",
"lol,cat",
"0000001681375789102250-65535,2013-08-09T12:00:00.0Z")));
assertThat(thrown).hasMessageThat().contains("header");
assertThat(thrown)
.hasMessageThat()
.isEqualTo("Mapping for smd-id not found, expected one of [lol, cat]");
}
@Test
@@ -142,6 +144,6 @@ class SmdrlCsvParserTest {
"1,2013-11-24T23:30:04.3Z",
"smd-id,insertion-datetime",
"0000001681375789102250-65535,haha,2013-08-09T12:00:00.0Z")));
assertThat(thrown).hasMessageThat().contains("elements");
assertThat(thrown).hasMessageThat().isEqualTo("Invalid format: \"haha\"");
}
}