Repository: corona-warn-app/cwa-server
File: services/distribution/src/test/java/app/coronawarn/server/services/distribution/assembly/component/TraceTimeIntervalWarningsStructureProviderTest.java (Java)

Code before:
              oldestHour + hourlyPackage, "index.checksum");
      expectedHourlyPackagesPaths.addAll(Set.of(hourDirectory, hourIndexDirectory, hourIndexChecksumDirectory));
    });

    Set<String> expectedPaths = Stream.of(
        PARENT_TEST_FOLDER,
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "index"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "index.checksum"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour", "index"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour", "index.checksum")).collect(
        Collectors.toSet());
    expectedPaths.addAll(expectedHourlyPackagesPaths);

    Set<String> actualFiles =
        getSubFoldersPaths(testOutputFolder.getRoot().getAbsolutePath(), PARENT_TEST_FOLDER).stream()
            .filter(this::isDsStore).collect(
            Collectors.toSet());
    actualFiles.addAll(getFilePaths(testOutputFolder.getRoot(), testOutputFolder.getRoot().getAbsolutePath()));
    actualFiles.forEach(actual -> assertTrue(expectedPaths.contains(actual)));
  }

  private boolean isDsStore(String it) {
    return !it.endsWith(DS_STORE);
  }

  private void writeDirectories(List<TraceTimeIntervalWarning> traceWarnings) throws IOException {
    when(traceTimeWarningService.getTraceTimeIntervalWarning()).thenReturn(traceWarnings);
    Directory<WritableOnDisk> outputDirectory = this.outputDirectoryProvider.getDirectory();
    TraceTimeIntervalWarningsStructureProvider distributionStructureProvider =
        new TraceTimeIntervalWarningsStructureProvider(traceTimeWarningService, bundler,
            cryptoProvider, distributionServiceConfig);
    outputDirectory.addWritable(distributionStructureProvider.getTraceWarningsDirectory());
    outputDirectoryProvider.clear();
    outputDirectory.prepare(new ImmutableStack<>());
    outputDirectory.write();
  }
}


Review comment (suggestion):
```suggestion
  private boolean isNotDsStore(String it) {
```

Code after:
              oldestHour + hourlyPackage, "index.checksum");
      expectedHourlyPackagesPaths.addAll(Set.of(hourDirectory, hourIndexDirectory, hourIndexChecksumDirectory));
    });

    Set<String> expectedPaths = Stream.of(
        PARENT_TEST_FOLDER,
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "index"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "index.checksum"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour", "index"),
        StringUtils.joinWith(SEPARATOR, PARENT_TEST_FOLDER, "twp", "country", "DE", "hour", "index.checksum")).collect(
        Collectors.toSet());
    expectedPaths.addAll(expectedHourlyPackagesPaths);

    Set<String> actualFiles =
        getSubFoldersPaths(testOutputFolder.getRoot().getAbsolutePath(), PARENT_TEST_FOLDER).stream()
            .filter(this::isNotDsStore).collect(
            Collectors.toSet());
    actualFiles.addAll(getFilePaths(testOutputFolder.getRoot(), testOutputFolder.getRoot().getAbsolutePath()));
    actualFiles.forEach(actual -> assertTrue(expectedPaths.contains(actual)));
  }

  private boolean isNotDsStore(String it) {
    return !it.endsWith(DS_STORE);
  }

  private void writeDirectories(List<TraceTimeIntervalWarning> traceWarnings) throws IOException {
    when(traceTimeWarningService.getTraceTimeIntervalWarning()).thenReturn(traceWarnings);
    Directory<WritableOnDisk> outputDirectory = this.outputDirectoryProvider.getDirectory();
    TraceTimeIntervalWarningsStructureProvider distributionStructureProvider =
        new TraceTimeIntervalWarningsStructureProvider(traceTimeWarningService, bundler,
            cryptoProvider, distributionServiceConfig);
    outputDirectory.addWritable(distributionStructureProvider.getTraceWarningsDirectory());
    outputDirectoryProvider.clear();
    outputDirectory.prepare(new ImmutableStack<>());
    outputDirectory.write();
  }
}