1+
12package org .scijava .ops .matcher ;
23
34import java .util .function .Function ;
1617
1718@ Plugin (type = OpCollection .class )
1819public class DefaultMatchingErrorTest extends AbstractTestEnvironment {
19-
20+
2021 @ OpField (names = "test.duplicateOp" )
2122 public final Function <Double , Double > duplicateA = (in ) -> in ;
2223
2324 @ OpField (names = "test.duplicateOp" )
2425 public final Function <Double , Double > duplicateB = (in ) -> in ;
25-
26+
27+ /**
28+ * Assert a relevant (i.e. informational) message is thrown when multiple Ops
29+ * conflict for a given OpRef.
30+ */
2631 @ Test
2732 public void duplicateErrorRegressionTest () {
2833 try {
@@ -37,7 +42,10 @@ public void duplicateErrorRegressionTest() {
3742 "ops of priority 0.0:" ));
3843 }
3944 }
40-
45+
46+ /**
47+ * Assert that a relevant error is thrown when a dependency is missing
48+ */
4149 @ Test
4250 public void missingDependencyRegressionTest () {
4351 try {
@@ -52,9 +60,10 @@ public void missingDependencyRegressionTest() {
5260 Assert .assertTrue (message .contains ("Name: \" test.nonexistingOp\" " ));
5361 }
5462 }
55-
63+
5664 /**
57- * Assert the DependencyMatchingException contains both dependencies in the chain
65+ * Assert the DependencyMatchingException contains both dependencies in the
66+ * chain
5867 */
5968 @ Test
6069 public void missingNestedDependencyRegressionTest () {
@@ -70,95 +79,99 @@ public void missingNestedDependencyRegressionTest() {
7079 Assert .assertTrue (message .contains ("Name: \" test.nonexistingOp\" " ));
7180 }
7281 }
73-
82+
83+ /**
84+ * Assert that DependencyMatchingExceptions do not omit relevant information
85+ * when an adaptation is involved.
86+ */
7487 @ Test
7588 public void missingDependencyViaAdaptationTest () {
7689 Double [] d = new Double [0 ];
7790 try {
7891 ops .op ("test.adaptMissingDep" ).input (d ).outType (Double [].class ).apply ();
7992 Assert .fail ("Expected DependencyMatchingException" );
80- } catch (IllegalArgumentException e ) {
93+ }
94+ catch (IllegalArgumentException e ) {
8195 Throwable cause = e .getCause ();
8296 Assert .assertTrue (cause instanceof DependencyMatchingException );
8397 String message = cause .getMessage ();
8498 Assert .assertTrue (message .contains ("adapted" ));
8599 Assert .assertTrue (message .contains ("Name: \" test.nonexistingOp\" " ));
86-
100+
87101 }
88102 }
89-
103+
90104}
91105
92106@ Plugin (type = Op .class , name = "test.furtherOutsideOp" )
93107@ Parameter (key = "in" )
94108@ Parameter (key = "out" , itemIO = ItemIO .OUTPUT )
95109class FurtherDependentOp implements Function <Double , Double > {
96-
110+
97111 @ OpDependency (name = "test.outsideOp" )
98112 private Function <Double , Double > op ;
99113
100114 @ Override
101115 public Double apply (Double t ) {
102116 return op .apply (t );
103117 }
104-
118+
105119}
106120
107121@ Plugin (type = Op .class , name = "test.outsideOp" )
108122@ Parameter (key = "in" )
109123@ Parameter (key = "out" , itemIO = ItemIO .OUTPUT )
110124class DependentOp implements Function <Double , Double > {
111-
125+
112126 @ OpDependency (name = "test.missingDependencyOp" )
113127 private Function <Double , Double > op ;
114128
115129 @ Override
116130 public Double apply (Double t ) {
117131 return op .apply (t );
118132 }
119-
133+
120134}
121135
122136@ Plugin (type = Op .class , name = "test.missingDependencyOp" )
123137@ Parameter (key = "in" )
124138@ Parameter (key = "out" , itemIO = ItemIO .OUTPUT )
125139class MissingDependencyOp implements Function <Double , Double > {
126-
140+
127141 @ OpDependency (name = "test.nonexistingOp" )
128142 private Function <Double , Double > op ;
129143
130144 @ Override
131145 public Double apply (Double t ) {
132146 return op .apply (t );
133147 }
134-
148+
135149}
136150
137151@ Plugin (type = Op .class , name = "test.adaptMissingDep" )
138152@ Parameter (key = "in" )
139153@ Parameter (key = "out" , itemIO = ItemIO .OUTPUT )
140154class MissingDependencyOpArr1 implements Computers .Arity1 <Double [], Double []> {
141-
155+
142156 @ OpDependency (name = "test.nonexistingOp" )
143157 private Function <Double , Double > op ;
144158
145159 @ Override
146- public void compute (Double [] t , Double [] out ) {
147- }
148-
160+ public void compute (Double [] t , Double [] out ) {}
161+
149162}
150163
151164@ Plugin (type = Op .class , name = "test.adaptMissingDep" )
152165@ Parameter (key = "in" )
153166@ Parameter (key = "out" , itemIO = ItemIO .OUTPUT )
154167class MissingDependencyOpArr2 implements Function <Double , Double > {
155-
168+
156169 @ OpDependency (name = "test.nonexistingOp" )
157170 private Function <Double , Double > op ;
158171
159172 @ Override
160173 public Double apply (Double t ) {
161174 return op .apply (t );
162175 }
163-
164- }
176+
177+ }
0 commit comments