Source:
<code>public void testDeserializationMissingNode() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.createObjectNode(); root.put("id", 123123123); byte[] serializedJson = objectMapper.writeValueAsBytes(root); DataType dataType = ROW(FIELD("name", STRING())); RowType schema = (RowType) dataType.getLogicalType(); JsonRowDataDeserializationSchema deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), false, false, TimestampFormat.ISO_8601); Row expected = new Row(1); Row actual = convertToExternal(deserializationSchema.deserialize(serializedJson), dataType); assertEquals(expected, actual); deserializationSchema = deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), true, false, TimestampFormat.ISO_8601); String errorMessage = "Failed to deserialize JSON '{\"id\":123123123}'."; try { deserializationSchema.deserialize(serializedJson); <START> throw new RuntimeException("expecting exception message: " + errorMessage); <END> } catch (Throwable t) { assertEquals(errorMessage, t.getMessage()); } deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), false, true, TimestampFormat.ISO_8601); actual = convertToExternal(deserializationSchema.deserialize(serializedJson), dataType); assertEquals(expected, actual); errorMessage = "JSON format doesn't support failOnMissingField and ignoreParseErrors are both enabled."; try { new JsonRowDataDeserializationSchema( schema, new RowDataTypeInfo(schema), true, true, TimestampFormat.ISO_8601); throw new RuntimeException("expecting exception message: " + errorMessage); } catch (Throwable t) { assertEquals(errorMessage, t.getMessage()); } }</code><technical_language>org.junit.Assert#fail(java.lang.String) instead: fail("expecting exception message: " + errorMessage);</technical_language>

Target:
public void testDeserializationMissingNode() throws Exception { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode root = objectMapper.createObjectNode(); root.put("id", 123123123); byte[] serializedJson = objectMapper.writeValueAsBytes(root); DataType dataType = ROW(FIELD("name", STRING())); RowType schema = (RowType) dataType.getLogicalType(); JsonRowDataDeserializationSchema deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), false, false, TimestampFormat.ISO_8601); Row expected = new Row(1); Row actual = convertToExternal(deserializationSchema.deserialize(serializedJson), dataType); assertEquals(expected, actual); deserializationSchema = deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), true, false, TimestampFormat.ISO_8601); String errorMessage = "Failed to deserialize JSON '{\"id\":123123123}'."; try { deserializationSchema.deserialize(serializedJson); Assert.fail("expecting exception message: " + errorMessage); } catch (Throwable t) { assertEquals(errorMessage, t.getMessage()); } deserializationSchema = new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), false, true, TimestampFormat.ISO_8601); actual = convertToExternal(deserializationSchema.deserialize(serializedJson), dataType); assertEquals(expected, actual); errorMessage = "JSON format doesn't support failOnMissingField and ignoreParseErrors are both enabled."; try { new JsonRowDataDeserializationSchema( schema, WrapperTypeInfo.of(schema), true, true, TimestampFormat.ISO_8601); Assert.fail("expecting exception message: " + errorMessage); } catch (Throwable t) { assertEquals(errorMessage, t.getMessage()); } }