Skip to content

Commit 82a9c5f

Browse files
committed
InputsTest: add tests which where commented out
1 parent f4ce547 commit 82a9c5f

File tree

1 file changed

+42
-45
lines changed

1 file changed

+42
-45
lines changed

src/test/java/org/scijava/command/InputsTest.java

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -88,48 +88,48 @@ public void testSingleInput() {
8888
assertEquals(3.9f, sigma, 0);
8989
}
9090

91-
// /** Tests two inputs, no configuration. */
92-
// @Test
93-
// public void testTwoInputs() {
94-
// setExpected(new HashMap<String, Object>() {{
95-
// put("name", "Caesar");
96-
// put("age", 55);
97-
// }});
98-
// Inputs inputs = new Inputs(context);
99-
// inputs.getInfo().setName("testTwoInputs");//TEMP
100-
// inputs.addInput("name", String.class);
101-
// inputs.addInput("age", Integer.class);
102-
// Map<String, Object> values = inputs.harvest();
103-
// String name = (String) values.get("name");
104-
// int age = (Integer) values.get("age");
105-
// assertEquals("Chuckles", name);
106-
// assertEquals(37, age);
107-
// }
108-
//
109-
// /** Tests inputs with configuration. */
110-
// @Test
111-
// public void testWithConfiguration() {
112-
// setExpected(new HashMap<String, Object>() {{
113-
// put("word", "brown");
114-
// put("opacity", 0.8);
115-
// }});
116-
// Inputs inputs = new Inputs(context);
117-
// inputs.getInfo().setName("testWithConfiguration");//TEMP
118-
// MutableModuleItem<String> wordInput = inputs.addInput("word", String.class);
119-
// wordInput.setLabel("Favorite word");
120-
// wordInput.setChoices(Arrays.asList("quick", "brown", "fox"));
121-
// wordInput.setDefaultValue("fox");
122-
// MutableModuleItem<Double> opacityInput = inputs.addInput("opacity", Double.class);
123-
// opacityInput.setMinimumValue(0.0);
124-
// opacityInput.setMaximumValue(1.0);
125-
// opacityInput.setDefaultValue(0.5);
126-
// opacityInput.setWidgetStyle(NumberWidget.SCROLL_BAR_STYLE);
127-
// inputs.harvest();
128-
// String word = wordInput.getValue(inputs);
129-
// double opacity = opacityInput.getValue(inputs);
130-
// assertEquals("brown", word);
131-
// assertEquals(0.8, opacity, 0);
132-
// }
91+
/** Tests two inputs, no configuration. */
92+
@Test
93+
public void testTwoInputs() {
94+
setExpected(new HashMap<String, Object>() {{
95+
put("name", "Chuckles");
96+
put("age", 37);
97+
}});
98+
Inputs inputs = new Inputs(context);
99+
inputs.getInfo().setName("testTwoInputs");//TEMP
100+
inputs.addInput("name", String.class);
101+
inputs.addInput("age", Integer.class);
102+
Map<String, Object> values = inputs.harvest();
103+
String name = (String) values.get("name");
104+
int age = (Integer) values.get("age");
105+
assertEquals("Chuckles", name);
106+
assertEquals(37, age);
107+
}
108+
109+
/** Tests inputs with configuration. */
110+
@Test
111+
public void testWithConfiguration() {
112+
setExpected(new HashMap<String, Object>() {{
113+
put("word", "brown");
114+
put("opacity", 0.8);
115+
}});
116+
Inputs inputs = new Inputs(context);
117+
inputs.getInfo().setName("testWithConfiguration");//TEMP
118+
MutableModuleItem<String> wordInput = inputs.addInput("word", String.class);
119+
wordInput.setLabel("Favorite word");
120+
wordInput.setChoices(Arrays.asList("quick", "brown", "fox"));
121+
wordInput.setDefaultValue("fox");
122+
MutableModuleItem<Double> opacityInput = inputs.addInput("opacity", Double.class);
123+
opacityInput.setMinimumValue(0.0);
124+
opacityInput.setMaximumValue(1.0);
125+
opacityInput.setDefaultValue(0.5);
126+
opacityInput.setWidgetStyle(NumberWidget.SCROLL_BAR_STYLE);
127+
inputs.harvest();
128+
String word = wordInput.getValue(inputs);
129+
double opacity = opacityInput.getValue(inputs);
130+
assertEquals("brown", word);
131+
assertEquals(0.8, opacity, 0);
132+
}
133133

134134
public void setExpected(final Map<String, Object> expected) {
135135
final PluginInfo<PreprocessorPlugin> info =
@@ -139,7 +139,6 @@ public void setExpected(final Map<String, Object> expected) {
139139
@Override
140140
public PreprocessorPlugin createInstance() throws InstantiableException {
141141
final PreprocessorPlugin pp = super.createInstance();
142-
System.out.println(pp + ": injecting " + expected);
143142
((MockInputHarvester) pp).setExpected(expected);
144143
return pp;
145144
}
@@ -151,13 +150,11 @@ public PreprocessorPlugin createInstance() throws InstantiableException {
151150
public static class MockInputHarvester extends AbstractPreprocessorPlugin {
152151
private Map<String, Object> expected;
153152
public void setExpected(final Map<String, Object> expected) {
154-
System.out.println(this + ": setExpected: " + expected);
155153
this.expected = expected;
156154
}
157155

158156
@Override
159157
public void process(final Module module) {
160-
System.out.println("----> " + this + ": processing module: " + module.getInfo().getName());
161158
for (final ModuleItem<?> input : module.getInfo().inputs()) {
162159
if (module.isInputResolved(input.getName())) continue;
163160
final String name = input.getName();

0 commit comments

Comments
 (0)