Skip to content

Commit da5d7ed

Browse files
Picked some changes from gbif branch
1 parent a6b9e93 commit da5d7ed

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/main/java/io/frictionlessdata/tableschema/field/DatetimeField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public ZonedDateTime parseValue(String value, String format, Map<String, Object>
4343

4444
return ZonedDateTime.from(dt);
4545
}else{
46-
throw new TypeInferringException("DateTime field not in ISO 8601 format yyyy-MM-dd'T'HH:mm:ss[.SSS]Z");
46+
throw new TypeInferringException("DateTime field value [" + value + "] not in ISO 8601 format yyyy-MM-dd'T'HH:mm:ss[.SSS]Z");
4747
}
4848
}
4949

src/main/java/io/frictionlessdata/tableschema/field/Field.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,8 @@ T castValue(String value, boolean enforceConstraints, Map<String, Object> option
659659

660660
} catch(ConstraintsException ce){
661661
throw ce;
662-
663-
} catch(TypeInferringException e){
664-
throw new InvalidCastException(e.getMessage());
662+
} catch (TypeInferringException e) {
663+
throw new InvalidCastException("Field [" + this.name + "] provided value [" + value + "] is not of [" + type + "] type.");
665664
} catch(Exception e){
666665
throw new InvalidCastException(e);
667666
}

src/test/java/io/frictionlessdata/tableschema/field/FieldCastTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void testCastNumberGroupChar() throws Exception{
188188
@Test
189189
void testCastNumberDecimalChar() throws Exception{
190190
String testValue = "1020,123";
191-
Map<String, Object> options = new HashMap();
191+
Map<String, Object> options = new HashMap<>();
192192
options.put("decimalChar", ",");
193193
NumberField field = new NumberField("int field");
194194
Number num = field.castValue(testValue, false, options);
@@ -391,7 +391,7 @@ void testIssue21() {
391391

392392
BigInteger intVal = intField.castValue("16289212000");
393393
Number floatVal = floatField.castValue("16289212000.0");
394-
Assertions.assertTrue(floatVal instanceof BigDecimal);
394+
Assertions.assertInstanceOf(BigDecimal.class, floatVal);
395395
Assertions.assertEquals(((BigDecimal)floatVal).toBigInteger(), intVal);
396396
}
397397

@@ -405,7 +405,7 @@ void test2Issue21() throws Exception{
405405
schema = Schema.fromJson (fis, false);
406406
}
407407
Table table = Table.fromSource(f, TestHelper.getTestDataDirectory(), schema, TableDataSource.getDefaultCsvFormat());
408-
Iterator iter = table.iterator(true, false, true, false);
408+
Iterator<?> iter = table.iterator(true, false, true, false);
409409
Object obj = null;
410410
int cnt = 0;
411411
while (iter.hasNext()) {
@@ -415,8 +415,8 @@ void test2Issue21() throws Exception{
415415
break;
416416
}
417417
}
418-
Object valueObj = ((Map)obj).get("Value");
419-
Assertions.assertTrue(valueObj instanceof BigInteger);
418+
Object valueObj = ((Map<String, Object>)obj).get("Value");
419+
Assertions.assertInstanceOf(BigInteger.class, valueObj);
420420
BigInteger val = (BigInteger)valueObj;
421421
Assertions.assertEquals(18624475000000L, val.longValue());
422422
}

0 commit comments

Comments
 (0)