Skip to content

Commit

Permalink
Add new FileOutputTypes for file compression; bump aggregator version (
Browse files Browse the repository at this point in the history
  • Loading branch information
bennavapbc authored Jan 13, 2025
1 parent b2917cc commit a88824e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package gov.cms.ab2d.aggregator;

import java.io.File;
import java.util.stream.Stream;

/**
* Taken from AB2D. Describes the different file endings for the data and error files created by the aggregator
*/
public enum FileOutputType {
DATA(".ndjson"),
DATA_COMPRESSED(".ndjson.gz"),
ERROR("_error.ndjson"),
ERROR_COMPRESSED("_error.ndjson.gz"),
UNKNOWN("");

private final String suffix;
Expand All @@ -28,12 +31,10 @@ public static FileOutputType getFileType(String file) {
if (file == null) {
return UNKNOWN;
}
if (file.endsWith(DATA.getSuffix())) {
if (file.endsWith(ERROR.getSuffix())) {
return ERROR;
}
return DATA;
}
return UNKNOWN;

return Stream.of(ERROR, ERROR_COMPRESSED, DATA, DATA_COMPRESSED)
.filter(type -> file.endsWith(type.suffix))
.findFirst()
.orElse(UNKNOWN);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import org.junit.jupiter.api.Test;

import static gov.cms.ab2d.aggregator.FileOutputType.DATA;
import static gov.cms.ab2d.aggregator.FileOutputType.DATA_COMPRESSED;
import static gov.cms.ab2d.aggregator.FileOutputType.ERROR;
import static gov.cms.ab2d.aggregator.FileOutputType.ERROR_COMPRESSED;
import static gov.cms.ab2d.aggregator.FileOutputType.UNKNOWN;
import static org.junit.jupiter.api.Assertions.assertEquals;

Expand All @@ -15,8 +17,12 @@ class FileOutputTypeTest {
void isErrorFile() {
String file1 = "abc." + ERROR.getSuffix();
String file2 = "abc." + DATA.getSuffix();
String file3 = "abc." + ERROR_COMPRESSED.getSuffix();
String file4 = "abc." + DATA_COMPRESSED.getSuffix();
assertEquals(ERROR, FileOutputType.getFileType(file1));
assertEquals(DATA, FileOutputType.getFileType(file2));
assertEquals(ERROR_COMPRESSED, FileOutputType.getFileType(file3));
assertEquals(DATA_COMPRESSED, FileOutputType.getFileType(file4));
assertEquals(UNKNOWN, FileOutputType.getFileType("bogus.txt"));
assertEquals(UNKNOWN, FileOutputType.getFileType((String) null));
}
Expand All @@ -25,7 +31,11 @@ void isErrorFile() {
void testActualFile() {
File file1 = new File("abc." + ERROR.getSuffix());
File file2 = new File("abc." + DATA.getSuffix());
File file3 = new File("abc." + ERROR_COMPRESSED.getSuffix());
File file4 = new File("abc." + DATA_COMPRESSED.getSuffix());
assertEquals(ERROR, FileOutputType.getFileType(file1));
assertEquals(DATA, FileOutputType.getFileType(file2));
assertEquals(ERROR_COMPRESSED, FileOutputType.getFileType(file3));
assertEquals(DATA_COMPRESSED, FileOutputType.getFileType(file4));
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ext {
// AB2D libraries
fhirVersion='2.1.0'
bfdVersion='3.2.0'
aggregatorVersion='2.0.0'
aggregatorVersion='2.0.1'
filtersVersion='2.1.0'
eventClientVersion='3.2.1'
propertiesClientVersion='2.0.0'
Expand Down

0 comments on commit a88824e

Please sign in to comment.