40
40
import org .junit .Test ;
41
41
import org .scijava .Context ;
42
42
import org .scijava .InstantiableException ;
43
- import org .scijava .log .LogLevel ;
44
- import org .scijava .log .LogService ;
45
43
import org .scijava .module .Module ;
46
44
import org .scijava .module .ModuleItem ;
47
45
import org .scijava .module .MutableModuleItem ;
@@ -81,7 +79,7 @@ public void testSingleInput() {
81
79
}});
82
80
Inputs inputs = new Inputs (context );
83
81
inputs .getInfo ().setName ("testSingleInput" );//TEMP
84
- inputs . addInput ( "sigma" , Float .class );
82
+ addTempInput ( inputs , "sigma" , Float .class );
85
83
float sigma = (Float ) inputs .harvest ().get ("sigma" );
86
84
assertEquals (3.9f , sigma , 0 );
87
85
}
@@ -95,8 +93,8 @@ public void testTwoInputs() {
95
93
}});
96
94
Inputs inputs = new Inputs (context );
97
95
inputs .getInfo ().setName ("testTwoInputs" );//TEMP
98
- inputs . addInput ( "name" , String .class );
99
- inputs . addInput ( "age" , Integer .class );
96
+ addTempInput ( inputs , "name" , String .class );
97
+ addTempInput ( inputs , "age" , Integer .class );
100
98
Map <String , Object > values = inputs .harvest ();
101
99
String name = (String ) values .get ("name" );
102
100
int age = (Integer ) values .get ("age" );
@@ -113,11 +111,13 @@ public void testWithConfiguration() {
113
111
}});
114
112
Inputs inputs = new Inputs (context );
115
113
inputs .getInfo ().setName ("testWithConfiguration" );//TEMP
116
- MutableModuleItem <String > wordInput = inputs .addInput ("word" , String .class );
114
+ MutableModuleItem <String > wordInput = addTempInput (inputs , "word" ,
115
+ String .class );
117
116
wordInput .setLabel ("Favorite word" );
118
117
wordInput .setChoices (Arrays .asList ("quick" , "brown" , "fox" ));
119
118
wordInput .setDefaultValue ("fox" );
120
- MutableModuleItem <Double > opacityInput = inputs .addInput ("opacity" , Double .class );
119
+ MutableModuleItem <Double > opacityInput = addTempInput (inputs , "opacity" ,
120
+ Double .class );
121
121
opacityInput .setMinimumValue (0.0 );
122
122
opacityInput .setMaximumValue (1.0 );
123
123
opacityInput .setDefaultValue (0.5 );
@@ -145,6 +145,18 @@ public PreprocessorPlugin createInstance() throws InstantiableException {
145
145
context .service (PluginService .class ).addPlugin (info );
146
146
}
147
147
148
+ /**
149
+ * Add a non-persisted input to ensure we are testing with the mock input
150
+ * harvester.
151
+ */
152
+ private static <T > MutableModuleItem <T > addTempInput (Inputs inputs ,
153
+ String inputName , Class <T > inputType )
154
+ {
155
+ MutableModuleItem <T > input = inputs .addInput (inputName , inputType );
156
+ input .setPersisted (false );
157
+ return input ;
158
+ }
159
+
148
160
public static class MockInputHarvester extends AbstractPreprocessorPlugin {
149
161
private Map <String , Object > expected ;
150
162
public void setExpected (final Map <String , Object > expected ) {
0 commit comments