Unverified Commit 9854e210 authored by UnchartedBull's avatar UnchartedBull
Browse files

fix first test

parent 78318d4d
......@@ -48,7 +48,7 @@ public class DiagnosisKeysExportBatchDirectory extends IndexDirectoryOnDisk<Expo
public DiagnosisKeysExportBatchDirectory(Collection<Export> exports, CryptoProvider cryptoProvider,
DistributionServiceConfig distributionServiceConfig) {
// TODO: probably needs to be updated, i.e. daily for 24 hours
super(distributionServiceConfig.getApi().getHourPath(),
super(distributionServiceConfig.getApi().getDatePath(),
indices -> Set.copyOf(exports), exportFormatter -> exportFormatter.getBatch().getFromTimestamp().toString());
this.cryptoProvider = cryptoProvider;
this.distributionServiceConfig = distributionServiceConfig;
......
......@@ -67,8 +67,6 @@ public class ExportBatchDecorator extends IndexDirectoryDecorator<Export, Writab
@Override
public void prepare(ImmutableStack<Object> indices) {
// TODO: this needs to be improved, there will always be only a single directory here, since each assembly creates
// only a single file. Also directories with no diagnosis keys shouldn't be created ideally.
super.prepare(indices);
Set<Directory<WritableOnDisk>> exportDirectories = this.getWritables().stream()
.filter(writable -> writable instanceof DirectoryOnDisk)
......
......@@ -72,7 +72,8 @@ class DiagnosisKeysDirectoryTest {
private File outputFile;
private Directory<WritableOnDisk> parentDirectory;
Export export;
List<Export> exports;
ExportConfiguration exportConfiguration;
@BeforeEach
void setupAll() throws IOException {
......@@ -91,33 +92,36 @@ class DiagnosisKeysDirectoryTest {
currentHour -> buildDiagnosisKeyForSubmissionTimestamp(startTimestamp + currentHour))
.collect(Collectors.toList());
ExportConfiguration exportConfiguration = buildSampleExportConfiguration(1, Instant.now()
exportConfiguration = buildSampleExportConfiguration(1, Instant.now()
.minus(2, ChronoUnit.DAYS), Instant.now().plus(2, ChronoUnit.DAYS));
ExportBatch exportBatch = new ExportBatch(exportConfiguration.getFromTimestamp(),
exportConfiguration.getThruTimestamp(), ExportBatchStatus.OPEN, exportConfiguration);
export = new Export(new HashSet<>(diagnosisKeys), exportBatch);
exports = new ArrayList<>();
exports.add(new Export(new HashSet<>(diagnosisKeys), exportBatch));
}
// @Test
// void checkBuildsTheCorrectDirectoryStructureWhenNoKeys() {
// Directory<WritableOnDisk> directory = new DiagnosisKeysDirectory(export, cryptoProvider,
// distributionServiceConfig);
// parentDirectory.addWritable(directory);
// directory.prepare(new ImmutableStack<>());
// directory.write();
//
// String s = File.separator;
// Set<String> expectedFiles = Set.of(
// join(s, "diagnosis-keys", "country", "index"),
// join(s, "diagnosis-keys", "country", "DE", "date", "index")
// );
//
// Set<String> actualFiles = getActualFiles(outputFile);
//
// assertThat(actualFiles).isEqualTo(expectedFiles);
// }
@Test
void checkBuildsTheCorrectDirectoryStructureWhenNoKeys() {
exports = new ArrayList<>();
Directory<WritableOnDisk> directory = new DiagnosisKeysDirectory(exports, exportConfiguration, cryptoProvider,
distributionServiceConfig);
parentDirectory.addWritable(directory);
directory.prepare(new ImmutableStack<>());
directory.write();
String s = File.separator;
Set<String> expectedFiles = Set.of(
join(s, "diagnosis-keys", "country", "index"),
join(s, "diagnosis-keys", "country", "DE", "date", "index")
);
Set<String> actualFiles = getActualFiles(outputFile);
assertThat(actualFiles).isEqualTo(expectedFiles);
}
//
// @Test
// void checkBuildsTheCorrectDirectoryStructure() {
......
......@@ -50,7 +50,7 @@ public class Helpers {
public static ExportConfiguration buildSampleExportConfiguration(int period, Instant fromTimestamp,
Instant thruTimestamp) {
return new ExportConfiguration("mock", "mock", period, "DE", fromTimestamp, thruTimestamp,
"mock", "mock", "mock", "mock", "mock");
return new ExportConfiguration("mock", "diagnosis-keys", period, "DE", fromTimestamp,
thruTimestamp,"mock", "mock", "mock", "mock", "mock");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment