3939import org .scijava .Context ;
4040import org .scijava .command .CommandInfo ;
4141import org .scijava .command .ContextCommand ;
42+ import org .scijava .command .InteractiveCommand ;
4243import org .scijava .module .Module ;
4344import org .scijava .module .ModuleItem ;
4445import org .scijava .module .ModuleService ;
@@ -67,7 +68,7 @@ public void tearDown() {
6768 }
6869
6970 @ Test
70- public void testObjects () {
71+ public void testObjectsCommand () {
7172 Thing a = new Thing ();
7273 Thing b = new Thing ();
7374
@@ -93,6 +94,33 @@ public void testObjects() {
9394 assertTrue (choicesWidget instanceof SwingObjectWidget );
9495 }
9596
97+ @ Test
98+ public void testObjectsInteractiveCommand () {
99+ Thing a = new Thing ();
100+ Thing b = new Thing ();
101+
102+ CommandInfo commandInfo = new CommandInfo (MyInteractiveCommand .class );
103+ Module module = moduleService .createModule (commandInfo );
104+ InputPanel <?,?> panel = new SwingInputPanel ();
105+
106+ ModuleItem <Thing > thingInput = moduleService .getSingleInput (module , Thing .class );
107+ ModuleItem <Nothing > nothingInput = moduleService .getSingleInput (module , Nothing .class );
108+ ModuleItem <Choices > choicesInput = moduleService .getSingleInput (module , Choices .class );
109+
110+ WidgetModel thingModel = widgetService .createModel (panel , module , thingInput , Arrays .asList (a , b ));
111+ WidgetModel nothingModel = widgetService .createModel (panel , module , nothingInput , null );
112+ WidgetModel choicesModel = widgetService .createModel (panel , module , choicesInput , null );
113+
114+ InputWidget <?, ?> thingWidget = widgetService .create (thingModel );
115+ assertTrue (thingWidget instanceof SwingObjectWidget );
116+
117+ InputWidget <?, ?> nothingWidget = widgetService .create (nothingModel );
118+ assertFalse (nothingWidget instanceof SwingObjectWidget );
119+
120+ InputWidget <?, ?> choicesWidget = widgetService .create (choicesModel );
121+ assertTrue (choicesWidget instanceof SwingObjectWidget );
122+ }
123+
96124 private class Thing {
97125 // dummy class
98126 }
@@ -121,4 +149,22 @@ public void run() {
121149 }
122150
123151 }
152+
153+ public static class MyInteractiveCommand extends InteractiveCommand {
154+ @ Parameter
155+ private Thing thing ;
156+
157+ @ Parameter
158+ private Nothing nothing ;
159+
160+ @ Parameter
161+ private Choices choices ;
162+
163+ @ Override
164+ public void run () {
165+ // nothing to do
166+ }
167+
168+ }
169+
124170}
0 commit comments