1010import org .scijava .core .Priority ;
1111import org .scijava .ops .AbstractTestEnvironment ;
1212import org .scijava .ops .core .Op ;
13+ import org .scijava .ops .core .builder .OpBuilder ;
1314import org .scijava .ops .function .Computers ;
1415import org .scijava .ops .function .Producer ;
1516import org .scijava .param .Mutable ;
@@ -23,10 +24,10 @@ public class AnyTest extends AbstractTestEnvironment {
2324 public void testAny () {
2425
2526 NestedThing <String , Thing <String >> nthing = new NestedThing <>();
26- Double e = ( Double ) ops . run ( "test.nestedAny" , nthing );
27+ Double e = new OpBuilder ( ops , "test.nestedAny" ). input ( nthing ). outType ( Double . class ). apply ( );
2728
2829 Thing <Double > thing = new Thing <>();
29- Double d = ( Double ) ops . run ( "test.any" , thing );
30+ Double d = new OpBuilder ( ops , "test.any" ). input ( thing ). outType ( Double . class ). apply ( );
3031
3132 assert d == 5. ;
3233 assert e == 5. ;
@@ -42,7 +43,7 @@ public void testAny() {
4243 public void testExceptionalThing () {
4344
4445 ExceptionalThing <Double > ething = new ExceptionalThing <>(0.5 );
45- Double d = ( Double ) ops . run ( "test.exceptionalAny" , ething );
46+ Double d = new OpBuilder ( ops , "test.exceptionalAny" ). input ( ething ). outType ( Double . class ). apply ( );
4647
4748 }
4849
@@ -68,19 +69,20 @@ public Class<Thing<?>> getRawType() {
6869 // TODO: Note that this wouldn't work for Computer -> Function because here
6970 // LiftFunctionToArrayTransformer is the first transformer which is asked for
7071 // source refs. This transformer doesn't support Any and would fail.
72+ // TODO: can we remove this test?
7173 @ Test
7274 public void testRunAnyFunction1FromComputer2 () {
7375 final int in1 = 11 ;
7476 final long in2 = 31 ;
75- final Object out = ops .run ("test.integerAndLongAndNotAnyComputer" , in1 , in2 );
76- assert out instanceof MutableNotAny ;
77- assertEquals (Long .toString (in1 + in2 ), ((MutableNotAny ) out ).getValue ());
77+ final MutableNotAny out = new OpBuilder (ops , "test.integerAndLongAndNotAnyComputer" ).input (in1 , in2 ).outType (MutableNotAny .class ).apply ();
78+ assertEquals (Long .toString (in1 + in2 ), out .getValue ());
7879 }
7980
81+ @ SuppressWarnings ("cast" )
8082 @ Test
8183 public void testAnyInjectionIntoFunctionRaws () {
8284 final Function <Long , Long > func = (in ) -> in / 2 ;
83- final Long output = (Long ) ops . run ( "test.functionAndLongToLong" , func , 20l );
85+ final Long output = (Long ) new OpBuilder ( ops , "test.functionAndLongToLong" ). input ( func , 20l ). outType ( Long . class ). apply ( );
8486 assert (output == 10 );
8587 }
8688}
0 commit comments