mirror of https://github.com/apache/nifi.git
[NIFI-11511] Added Provenance route events for all the relationships.
This closes #7221 Signed-off-by: Mike Thomsen <mthomsen@apache.org>
This commit is contained in:
parent
9f3284393a
commit
71c7d38c75
|
@ -187,15 +187,18 @@ public class ValidateJson extends AbstractProcessor {
|
|||
|
||||
if (errors.isEmpty()) {
|
||||
getLogger().debug("JSON {} valid", flowFile);
|
||||
session.getProvenanceReporter().route(flowFile, REL_VALID);
|
||||
session.transfer(flowFile, REL_VALID);
|
||||
} else {
|
||||
final String validationMessages = errors.toString();
|
||||
flowFile = session.putAttribute(flowFile, ERROR_ATTRIBUTE_KEY, validationMessages);
|
||||
getLogger().warn("JSON {} invalid: Validation Errors {}", flowFile, validationMessages);
|
||||
session.getProvenanceReporter().route(flowFile, REL_INVALID);
|
||||
session.transfer(flowFile, REL_INVALID);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
getLogger().error("JSON processing failed {}", flowFile, e);
|
||||
session.getProvenanceReporter().route(flowFile, REL_FAILURE);
|
||||
session.transfer(flowFile, REL_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.nifi.processors.standard;
|
|||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.nifi.processor.Relationship;
|
||||
import org.apache.nifi.provenance.ProvenanceEventType;
|
||||
import org.apache.nifi.util.TestRunner;
|
||||
import org.apache.nifi.util.TestRunners;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -32,6 +33,7 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
@ -62,6 +64,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 1);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_VALID, false);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -77,6 +81,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 1);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_VALID, false);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -93,6 +99,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 1);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_VALID, false);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -109,6 +117,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 0);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_INVALID, true);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -125,6 +135,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 0);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_INVALID, true);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -141,6 +153,8 @@ class TestValidateJson {
|
|||
runner.assertTransferCount(ValidateJson.REL_VALID, 0);
|
||||
|
||||
assertValidationErrors(ValidateJson.REL_FAILURE, false);
|
||||
assertEquals(1, runner.getProvenanceEvents().size());
|
||||
assertEquals(ProvenanceEventType.ROUTE, runner.getProvenanceEvents().get(0).getEventType());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue