SacLoader implements FileToWaveformConverter { @Override public Flux<Result<Waveform>> convertFiles(List<File> files) { return Flux.fromIterable(files).flatMap(this::convertFile); }  @Override Mono<Result<Waveform>> convertFile(File file); @Override Flux<Result<Waveform>> convertFiles(List<File> files); Result<Waveform> convertSacFileToWaveform(File file); @Override PathMatcher getMatchingPattern(); String getOrCreateEvid(Waveform waveform); String getOrCreateEvid(SACHeader header);  }
@Test public void testConvertFiles() throws Exception { List<List<File>> multipleFiles = IntStream.range(0, 3).mapToObj(i -> { try (Stream<Path> stream = Files.walk(Paths.get("src/test/resources/sac/"))) { return stream.filter(path -> path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".sac")).map(path -> path.toFile()).collect(Collectors.toList()); } catch (IOException e) { e.printStackTrace(); return null; } }).filter(o -> o != null).collect(Collectors.toList()); List<Result<Waveform>> results = loader.convertFiles(multipleFiles.get(0)).doOnError(error -> Assertions.fail(error.getMessage())).collectList().block(Duration.ofSeconds(10l)); for (Result<Waveform> res : results) { Assertions.assertTrue(res.isSuccess(), "Expect that waveform results should all complete successfully"); Assertions.assertTrue(res.getErrors().isEmpty(), "Expect that waveform results should have no error or warning messages"); Assertions.assertTrue(res.getResultPayload().isPresent(), "Expect that waveform results should have a Waveform payload"); } }
@Test public void testEventDepthPopulated() throws Exception { List<List<File>> multipleFiles = IntStream.range(0, 3).mapToObj(i -> { try (Stream<Path> stream = Files.walk(Paths.get("src/test/resources/sac/"))) { return stream.filter(path -> path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".sac")).map(path -> path.toFile()).collect(Collectors.toList()); } catch (IOException e) { e.printStackTrace(); return null; } }).filter(o -> o != null).collect(Collectors.toList()); List<Result<Waveform>> results = loader.convertFiles(multipleFiles.get(0)).doOnError(error -> Assertions.fail(error.getMessage())).collectList().block(Duration.ofSeconds(10l)); for (Result<Waveform> res : results) { Assertions.assertTrue(res.getResultPayload().get().getEvent().getDepth() != 0, "Expect that the waveform should have a populated event depth if the original file had it."); } }