Skip to content

Commit 163b3b7

Browse files
committed
ModuleServiceTest: test that our map hack works
See 225d4ba.
1 parent efd4216 commit 163b3b7

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/test/java/org/scijava/module/ModuleServiceTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,30 @@ public void testRunModuleMap() throws ModuleException, InterruptedException,
109109
assertEquals(expectedResult(), m.getOutput("result"));
110110
}
111111

112+
/**
113+
* Tests that {@link ModuleService#run(ModuleInfo, boolean, Object...)} and
114+
* {@link ModuleService#run(Module, boolean, Object...)} intelligently handle
115+
* a single-element {@link Object} array consisting of a {@code Map<String,
116+
* Object>}.
117+
* <p>
118+
* This situation can happen e.g. due to Jython choosing the wrong overloaded
119+
* {@code run} method. We correct for the issue on our side, for convenience.
120+
* </p>
121+
*/
122+
@Test
123+
public void testRunMapHack() throws ModuleException, InterruptedException,
124+
ExecutionException
125+
{
126+
final ModuleInfo info = new FooModuleInfo();
127+
final Object[] inputs = new Object[] { createInputMap() };
128+
final Module m = moduleService.run(info, false, inputs).get();
129+
assertEquals(expectedResult(), m.getOutput("result"));
130+
131+
final Module module = info.createModule();
132+
final Module m2 = moduleService.run(module, false, inputs).get();
133+
assertEquals(expectedResult(), m2.getOutput("result"));
134+
}
135+
112136
@Test
113137
public void testGetSingleInput() throws ModuleException {
114138
final ModuleInfo info = new FooModuleInfo();

0 commit comments

Comments
 (0)