Skip to content

Commit

Permalink
Add test for options resetting
Browse files Browse the repository at this point in the history
  • Loading branch information
melissalinkert committed Oct 20, 2023
1 parent 5a99e2b commit b532b77
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ public void resetResolutions() {
/**
*/
public void resetSeriesList() {
seriesList.clear();
seriesList = new ArrayList<Integer>();
}

/**
Expand Down Expand Up @@ -927,7 +927,7 @@ public void resetCompression() {
/**
*/
public void resetCompressionProperties() {
compressionProperties.clear();
compressionProperties = new HashMap<String, Object>();
}

/**
Expand Down Expand Up @@ -1003,7 +1003,7 @@ public void resetFillValue() {
/**
*/
public void resetReaderOptions() {
readerOptions.clear();
readerOptions = new ArrayList<String>();
}

/**
Expand Down Expand Up @@ -1048,7 +1048,7 @@ public void resetDimensionOrder() {
* @return path to input data
*/
public String getInputPath() {
return inputPath.toString();
return inputPath == null ? null : inputPath.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1983,6 +1983,40 @@ public void testOptionsAPI() throws Exception {
}
}

/**
* Check that setting and resetting options via API will reset options to
* their default values.
*/
@Test
public void testResetOptions() throws Exception {
input = fake("series", "2", "sizeX", "4096", "sizeY", "4096");

Converter apiConverter = new Converter();
apiConverter.setInputPath(input.toString());
apiConverter.setOutputPath(output.toString());
apiConverter.setSeriesList(Collections.singletonList(1));
apiConverter.setTileWidth(128);
apiConverter.setTileHeight(128);

assertEquals(apiConverter.getInputPath(), input.toString());
assertEquals(apiConverter.getOutputPath(), output.toString());
assertEquals(apiConverter.getSeriesList(), Collections.singletonList(1));
assertEquals(apiConverter.getTileWidth(), 128);
assertEquals(apiConverter.getTileHeight(), 128);

apiConverter.resetInputPath();
assertEquals(apiConverter.getInputPath(), null);

apiConverter.setInputPath(input.toString());

apiConverter.resetOptions();
assertEquals(apiConverter.getInputPath(), null);
assertEquals(apiConverter.getOutputPath(), null);
assertEquals(apiConverter.getSeriesList().size(), 0);
assertEquals(apiConverter.getTileWidth(), 1024);
assertEquals(apiConverter.getTileHeight(), 1024);
}

/**
* @param root dataset root path
* @param rowCount total rows the plate could contain
Expand Down

0 comments on commit b532b77

Please sign in to comment.