RecordFilePoller implements FilePoller { @Override @Scheduled(fixedDelayString = "${hedera.mirror.importer.parser.record.frequency:100}") public void poll() { if (ShutdownHelper.isStopping()) { return; } Path path = parserProperties.getValidPath(); log.debug("Parsing record files from {}", path); try { File file = path.toFile(); if (file.isDirectory()) { String[] files = file.list(); if (files == null || files.length == 0) { log.debug("No files to parse in directory {}", file.getPath()); return; } Arrays.sort(files); log.trace("Processing record files: {}", files); loadRecordFiles(files); } else { log.error("Input parameter is not a folder: {}", path); } } catch (Exception e) { log.error("Error parsing files", e); } }  @Override @Scheduled(fixedDelayString = "${hedera.mirror.importer.parser.record.frequency:100}") void poll();  }
@Test void poll() throws Exception { fileCopier.copy(); recordFilePoller.poll(); assertAllProcessed(); }
@Test void pollAndKeepFiles() throws Exception { parserProperties.setKeepFiles(true); fileCopier.copy(); recordFilePoller.poll(); assertAllProcessed(); }
@Test void noFiles() throws Exception { recordFilePoller.poll(); verifyNoInteractions(recordFileParser); }
@Test void pathNotDirectory() throws Exception { fileCopier.copy(); parserProperties.getMirrorProperties().setDataPath(dataPath.resolve("file.txt")); recordFilePoller.poll(); assertValidFiles(); verifyNoInteractions(recordFileParser); }
@Test void fileNotFoundFromRecordFileParser() { fileCopier.copy(); RecordParserProperties mockParserProperties = Mockito.mock(RecordParserProperties.class); doReturn(Path.of("/var/folders/tmp")).when(mockParserProperties).getValidPath(); recordFilePoller = new RecordFilePoller(mockParserProperties, recordFileParser); recordFilePoller.poll(); assertValidFiles(); }
@Test void errorFromRecordFileParser() { fileCopier.copy(); doThrow(ParserException.class).when(recordFileParser).parse(any()); recordFilePoller.poll(); assertValidFiles(); }