Let a null input to CSVRecord#get(Enum) fail in CSVRecord#get(String).
This commit is contained in:
parent
e3eca25d13
commit
7c5c08921c
|
@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A CSV record parsed from a CSV file.
|
||||
|
@ -65,7 +66,7 @@ public final class CSVRecord implements Serializable, Iterable<String> {
|
|||
* @return the String at the given enum String
|
||||
*/
|
||||
public String get(final Enum<?> e) {
|
||||
return get(e.toString());
|
||||
return get(Objects.toString(e, null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,6 +91,11 @@ public class CSVRecordTest {
|
|||
assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get(EnumFixture.UNKNOWN_COLUMN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetNullEnum() {
|
||||
assertThrows(IllegalArgumentException.class, () -> recordWithHeader.get((Enum<?>) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUnmappedName() {
|
||||
assertThrows(IllegalArgumentException.class, () -> assertNull(recordWithHeader.get("fourth")));
|
||||
|
|
Loading…
Reference in New Issue