4040import org .junit .Test ;
4141import org .scijava .Context ;
4242import org .scijava .InstantiableException ;
43- import org .scijava .log .LogLevel ;
44- import org .scijava .log .LogService ;
4543import org .scijava .module .Module ;
4644import org .scijava .module .ModuleItem ;
4745import org .scijava .module .MutableModuleItem ;
@@ -81,7 +79,7 @@ public void testSingleInput() {
8179 }});
8280 Inputs inputs = new Inputs (context );
8381 inputs .getInfo ().setName ("testSingleInput" );//TEMP
84- inputs . addInput ( "sigma" , Float .class );
82+ addTempInput ( inputs , "sigma" , Float .class );
8583 float sigma = (Float ) inputs .harvest ().get ("sigma" );
8684 assertEquals (3.9f , sigma , 0 );
8785 }
@@ -95,8 +93,8 @@ public void testTwoInputs() {
9593 }});
9694 Inputs inputs = new Inputs (context );
9795 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 );
10098 Map <String , Object > values = inputs .harvest ();
10199 String name = (String ) values .get ("name" );
102100 int age = (Integer ) values .get ("age" );
@@ -113,11 +111,13 @@ public void testWithConfiguration() {
113111 }});
114112 Inputs inputs = new Inputs (context );
115113 inputs .getInfo ().setName ("testWithConfiguration" );//TEMP
116- MutableModuleItem <String > wordInput = inputs .addInput ("word" , String .class );
114+ MutableModuleItem <String > wordInput = addTempInput (inputs , "word" ,
115+ String .class );
117116 wordInput .setLabel ("Favorite word" );
118117 wordInput .setChoices (Arrays .asList ("quick" , "brown" , "fox" ));
119118 wordInput .setDefaultValue ("fox" );
120- MutableModuleItem <Double > opacityInput = inputs .addInput ("opacity" , Double .class );
119+ MutableModuleItem <Double > opacityInput = addTempInput (inputs , "opacity" ,
120+ Double .class );
121121 opacityInput .setMinimumValue (0.0 );
122122 opacityInput .setMaximumValue (1.0 );
123123 opacityInput .setDefaultValue (0.5 );
@@ -145,6 +145,18 @@ public PreprocessorPlugin createInstance() throws InstantiableException {
145145 context .service (PluginService .class ).addPlugin (info );
146146 }
147147
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+
148160 public static class MockInputHarvester extends AbstractPreprocessorPlugin {
149161 private Map <String , Object > expected ;
150162 public void setExpected (final Map <String , Object > expected ) {
0 commit comments