2
2
3
3
import static org .junit .Assert .assertEquals ;
4
4
import static org .junit .Assert .assertNotNull ;
5
+ import static org .junit .Assert .assertTrue ;
5
6
6
7
import java .io .File ;
7
8
import java .io .StringReader ;
8
9
import java .util .HashMap ;
10
+ import java .util .List ;
9
11
import java .util .concurrent .ExecutionException ;
10
12
11
13
import net .imagej .table .Table ;
17
19
import org .scijava .command .CommandInfo ;
18
20
import org .scijava .command .CommandService ;
19
21
import org .scijava .module .Module ;
22
+ import org .scijava .module .ModuleItem ;
20
23
import org .scijava .module .ModuleService ;
21
24
import org .scijava .script .ScriptInfo ;
22
25
import org .scijava .service .SciJavaService ;
@@ -44,6 +47,37 @@ public void testContext() {
44
47
.getService (BatchService .class );
45
48
assertNotNull (batchService );
46
49
}
50
+
51
+ @ Test
52
+ public void testBatchableFileInputs () {
53
+ String script = "" //
54
+ + "#@ File fileInput\n " //
55
+ + "#@ String stringInput\n " //
56
+ + "#@ Integer integerInput\n " //
57
+ + "#@ Double doubleInput\n " //
58
+ + "" ;
59
+ ScriptInfo scriptInfo = createInfo (script );
60
+ BatchService batchService = context .getService (BatchService .class );
61
+ List <ModuleItem <?>> compatibleInputs = batchService .batchableInputs (
62
+ scriptInfo );
63
<
8000
code class="diff-text syntax-highlighted-line addition">+ assertEquals ("Wrong number of batchable inputs" , 1 , compatibleInputs
64
+ .size ());
65
+ }
66
+
67
+ @ Test
68
+ public void testNoCompatibleInputs () {
69
+ String script = "" //
70
+ + "#@ String stringInput\n " //
71
+ + "#@ Integer integerInput\n " //
72
+ + "#@ Double doubleInput\n " //
73
+ + "" ;
74
+ ScriptInfo scriptInfo = createInfo (script );
75
+ BatchService batchService = context .getService (BatchService .class );
76
+ List <ModuleItem <?>> compatibleInputs = batchService .batchableInputs (
77
+ scriptInfo );
78
+ assertTrue ("Wrong inputs found to be compatible" , compatibleInputs
79
+ .isEmpty ());
80
+ }
47
81
48
82
@ Test
49
83
public void testModuleBatchProcessor () {
@@ -52,9 +86,7 @@ public void testModuleBatchProcessor() {
52
86
+ "#@output result\n " //
53
87
+ "" //
54
88
+ "result = input" ;
55
- StringReader scriptReader = new StringReader (script );
56
- ScriptInfo scriptInfo = new ScriptInfo (context , "Foo.groovy" ,
57
- scriptReader );
89
+ ScriptInfo scriptInfo = createInfo (script );
58
90
59
91
assertEquals ("Wrong script language" , "Groovy" , scriptInfo
60
92
.getLanguage ().getLanguageName ());
@@ -90,4 +122,11 @@ public void testModuleBatchProcessor() {
90
122
outputs .getColumnHeader (0 ));
91
123
assertEquals ("Wrong file name" , "quo.txt" , outputs .getRowHeader (2 ));
92
124
}
125
+
126
+ /* --- Helper methods --- */
127
+
128
+ private ScriptInfo createInfo (String script ) {
129
+ StringReader scriptReader = new StringReader (script );
130
+ return new ScriptInfo (context , "Foo.groovy" , scriptReader );
131
+ }
93
132
}
0 commit comments