Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure empty filters are serialized as null #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/test/java/org/janelia/saalfeldlab/n5/zarr/N5ZarrTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ public void testReadZarrNestedPython() throws IOException, InterruptedException
@Test
public void testRawCompressorNullInZarray() throws IOException, ParseException, URISyntaxException {

// GsonBuilder's default value for serializeNulls is false
final ZarrKeyValueWriter n5 = (ZarrKeyValueWriter) createTempN5Writer();
n5.createDataset(
testZarrDatasetName,
Expand All @@ -704,6 +705,27 @@ public void testRawCompressorNullInZarray() throws IOException, ParseException,
}
}

@Test
public void testFiltersNullInZarray() throws IOException, ParseException, URISyntaxException {

// GsonBuilder's default value for serializeNulls is false
final ZarrKeyValueWriter n5 = (ZarrKeyValueWriter)createTempN5Writer();
n5.createDataset(
testZarrDatasetName,
new long[]{1, 2, 3},
new int[]{1, 2, 3},
DataType.UINT16,
new RawCompression());
final String zarrayLocation = n5.keyValueAccess.compose(n5.uri, testZarrDatasetName, ".zarray");
final LockedChannel zarrayChannel = n5.keyValueAccess.lockForReading(zarrayLocation);
final JSONParser jsonParser = new JSONParser();
try (Reader reader = zarrayChannel.newReader()) {
final JSONObject zarray = (JSONObject)jsonParser.parse(reader);
final JSONObject filters = (JSONObject)zarray.get("filters");
assertNull(filters);
}
}

@Test
@Override
public void testAttributes() {
Expand Down
Loading