@Test public void testProcessResultFileFalure() { ProcessSession processSession = mock(ProcessSession.class); ComponentLog componentLog = mock(ComponentLog.class); FlowFile flowFile = mock(FlowFile.class); Exception exception = new Exception(); String name = "name"; when(processSession.putAttribute(eq(flowFile), anyString(), anyString())).thenReturn(flowFile); resultProcessor.process(processSession, componentLog, flowFile, exception, name); verify(processSession).putAttribute(flowFile, CoreAttributes.FILENAME.key(), name); verify(processSession).putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); verify(processSession).transfer(flowFile, failureRelationship); verify(componentLog).error(eq(ResultProcessor.UNABLE_TO_PROCESS_DUE_TO), any(Object[].class), eq(exception)); }
public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name) { updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name); updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); if (exception == null) { session.transfer(updated, successRelationship); } else { logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[]{name, exception}, exception); session.transfer(updated, failureRelationship); } }
ResultProcessor { public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name) { updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name); updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); if (exception == null) { session.transfer(updated, successRelationship); } else { logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[]{name, exception}, exception); session.transfer(updated, failureRelationship); } } }
ResultProcessor { public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name) { updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name); updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); if (exception == null) { session.transfer(updated, successRelationship); } else { logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[]{name, exception}, exception); session.transfer(updated, failureRelationship); } } ResultProcessor(Relationship successRelationship, Relationship failureRelationship); }
ResultProcessor { public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name) { updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name); updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); if (exception == null) { session.transfer(updated, successRelationship); } else { logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[]{name, exception}, exception); session.transfer(updated, failureRelationship); } } ResultProcessor(Relationship successRelationship, Relationship failureRelationship); void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name); }
ResultProcessor { public void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name) { updated = session.putAttribute(updated, CoreAttributes.FILENAME.key(), name); updated = session.putAttribute(updated, CoreAttributes.MIME_TYPE.key(), MediaType.APPLICATION_XML_UTF_8.toString()); if (exception == null) { session.transfer(updated, successRelationship); } else { logger.error(UNABLE_TO_PROCESS_DUE_TO, new Object[]{name, exception}, exception); session.transfer(updated, failureRelationship); } } ResultProcessor(Relationship successRelationship, Relationship failureRelationship); void process(ProcessSession session, ComponentLog logger, FlowFile updated, Exception exception, String name); static final String UNABLE_TO_PROCESS_DUE_TO; }