### Question:
LandingZoneProcessor implements Processor { @Override public void process(Exchange exchange) throws Exception { Stage stage = Stage.createAndStartStage(LZ_STAGE, LZ_STAGE_DESC); String batchJobId = null; ReportStats reportStats = new SimpleReportStats(); NewBatchJob currentJob = null; File lzFile = exchange.getIn().getHeader("filePath", File.class); boolean hasErrors = false; String lzDirectoryPathName = lzFile.getParent(); if (!isValidLandingZone(lzDirectoryPathName)) { hasErrors = true; LOG.error("LandingZoneProcessor: {} is not a valid landing zone.", lzDirectoryPathName); reportStats.incError(); } else { currentJob = createNewBatchJob(lzFile); createResourceEntryAndAddToJob(lzFile, currentJob); batchJobId = currentJob.getId(); String lzFileName = lzFile.getName(); if (!isZipFile(lzFileName)) { hasErrors = true; handleProcessingError(exchange, batchJobId, lzFileName, lzDirectoryPathName, reportStats); } BatchJobUtils.stopStageAndAddToJob(stage, currentJob); batchJobDAO.saveBatchJob(currentJob); } setExchangeBody(exchange, reportStats, currentJob, hasErrors); }  @Override void process(Exchange exchange); static final BatchJobStageType LZ_STAGE; }### Answer:
@Test public void testValidLz() throws Exception { File validLzPathFile = new File("/test/lz/inbound/TEST-LZ/testFile.zip"); String validLzPathname = validLzPathFile.getParent(); List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add(validLzPathname); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setHeader("filePath", validLzPathFile.getPath()); landingZoneProcessor.process(exchange); assertFalse("Header on exchange should indicate success", exchange.getIn().getBody(WorkNote.class).hasErrors()); }
@Test public void testInvalidLz() throws Exception { File validLzPathFile = new File("/test/lz/inbound/TEST-LZ/testFile.zip"); String validLzPathname = validLzPathFile.getParent(); List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add(validLzPathname); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); File inValidLzPathFile = new File("/test/lz/inbound/BAD-TEST-LZ/testFile.zip"); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setHeader("filePath", inValidLzPathFile.getPath()); landingZoneProcessor.process(exchange); assertTrue("Header on exchange should indicate failure", exchange.getIn().getBody(WorkNote.class).hasErrors()); }
@Test public void testNonZipFileInLz() throws Exception { File unzippedLzPathFile = new File("/test/lz/inbound/TEST-LZ/testFile.ctl"); String validLzPathname = unzippedLzPathFile.getParent(); List<String> testLzPaths = new ArrayList<String>(); testLzPaths.add(validLzPathname); when(mockedTenantDA.getLzPaths()).thenReturn(testLzPaths); Exchange exchange = new DefaultExchange(new DefaultCamelContext()); exchange.getIn().setHeader("filePath", unzippedLzPathFile.getPath()); landingZoneProcessor.process(exchange); assertTrue("Header on exchange should indicate failure", exchange.getIn().getBody(WorkNote.class).hasErrors()); }