Skip to content

Commit

Permalink
Correct field name
Browse files Browse the repository at this point in the history
  • Loading branch information
seadowg committed Sep 16, 2021
1 parent d176628 commit 829d1dd
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@

public class CsvExternalInstanceTest {
private TreeElement commaSeparated;
private TreeElement tabSeparated;
private TreeElement semiColonSeparated;

@Before
public void setUp() throws IOException {
commaSeparated = CsvExternalInstance.parse("id", r("external-secondary-comma-complex.csv").toString());
tabSeparated = CsvExternalInstance.parse("id", r("external-secondary-semicolon-complex.csv").toString());
semiColonSeparated = CsvExternalInstance.parse("id", r("external-secondary-semicolon-complex.csv").toString());
}

@Test
public void heading_has_no_extra_quotes() {
assertEquals("label", commaSeparated.getChildAt(0).getChildAt(0).getName());
assertEquals("label", tabSeparated.getChildAt(0).getChildAt(0).getName());
assertEquals("label", semiColonSeparated.getChildAt(0).getChildAt(0).getName());
}

@Test
public void value_has_no_extra_quotes() {
assertEquals("A", commaSeparated.getChildAt(0).getChildAt(0).getValue().getValue());
assertEquals("A", tabSeparated.getChildAt(0).getChildAt(0).getValue().getValue());
assertEquals("A", semiColonSeparated.getChildAt(0).getChildAt(0).getValue().getValue());
}

@Test
public void quoted_string_with_comma() {
assertEquals("121 Main St, NE", commaSeparated.getChildAt(6).getChildAt(0).getValue().getValue());
assertEquals("121 Main St, NE", tabSeparated.getChildAt(6).getChildAt(0).getValue().getValue());
assertEquals("121 Main St, NE", semiColonSeparated.getChildAt(6).getChildAt(0).getValue().getValue());
}

@Test
public void quoted_string_with_semicolon() {
assertEquals("text; more text", commaSeparated.getChildAt(7).getChildAt(0).getValue().getValue());
assertEquals("text; more text", tabSeparated.getChildAt(7).getChildAt(0).getValue().getValue());
assertEquals("text; more text", semiColonSeparated.getChildAt(7).getChildAt(0).getValue().getValue());
}

@Test
public void missing_fields_replaced_with_spaces() {
for (int fieldIndex = 1; fieldIndex < 2; fieldIndex++) {
assertEquals("", commaSeparated.getChildAt(5).getChildAt(fieldIndex).getValue().getValue());
assertEquals("", tabSeparated.getChildAt(5).getChildAt(fieldIndex).getValue().getValue());
assertEquals("", semiColonSeparated.getChildAt(5).getChildAt(fieldIndex).getValue().getValue());
}
}
}

0 comments on commit 829d1dd

Please sign in to comment.