Skip to content

Commit

Permalink
Add parseOmeroMetadata tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikl committed Dec 5, 2024
1 parent 3d1ccf5 commit 680d7ac
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions test/loci/formats/utests/ZarrReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,85 @@ public void testResolutionCount() {
assertEquals(3, reader.getSeriesCount());
}

@Test
public void testParseOmeroMetadataWithIntegerValues() {
Map<String, Object> omeroMetadata = new HashMap<>();
omeroMetadata.put("id", 1);
omeroMetadata.put("name", "Test Image");
omeroMetadata.put("version", "0.1");

ArrayList<Object> channels = new ArrayList<>();
Map<String, Object> channel = new HashMap<>();
channel.put("active", true);
channel.put("coefficient", 1);
channel.put("color", "FFFFFF");
channel.put("family", "linear");
channel.put("inverted", false);
channel.put("label", "Channel 1");

Map<String, Object> window = new HashMap<>();
window.put("start", 0);
window.put("end", 255);
window.put("min", 0);
window.put("max", 255);
channel.put("window", window);

channels.add(channel);
omeroMetadata.put("channels", channels);

Map<String, Object> rdefs = new HashMap<>();
rdefs.put("defaultT", 0);
rdefs.put("defaultZ", 0);
rdefs.put("model", "color");
omeroMetadata.put("rdefs", rdefs);

Map<String, Object> test = new HashMap<>();
test.put("omero", omeroMetadata);
try {
reader.parseOmeroMetadata(test);
} catch (IOException | FormatException e) {
fail("Unexpected exception while parsing Omero metadata with Integer values");
}
}

@Test
public void testParseOmeroMetadataWithDoubleValues() {
Map<String, Object> omeroMetadata = new HashMap<>();
omeroMetadata.put("id", 1);
omeroMetadata.put("name", "Test Image");
omeroMetadata.put("version", "0.1");

ArrayList<Object> channels = new ArrayList<>();
Map<String, Object> channel = new HashMap<>();
channel.put("active", true);
channel.put("coefficient", 1.0);
channel.put("color", "FFFFFF");
channel.put("family", "linear");
channel.put("inverted", false);
channel.put("label", "Channel 1");

Map<String, Object> window = new HashMap<>();
window.put("start", 0.0);
window.put("end", 255.0);
window.put("min", 0.0);
window.put("max", 255.0);
channel.put("window", window);

channels.add(channel);
omeroMetadata.put("channels", channels);

Map<String, Object> rdefs = new HashMap<>();
rdefs.put("defaultT", 0);
rdefs.put("defaultZ", 0);
rdefs.put("model", "color");
omeroMetadata.put("rdefs", rdefs);

Map<String, Object> test = new HashMap<>();
test.put("omero", omeroMetadata);
try {
reader.parseOmeroMetadata(test);
} catch (IOException | FormatException e) {
fail("Unexpected exception while parsing Omero metadata with Double values");
}
}
}

0 comments on commit 680d7ac

Please sign in to comment.