Skip to content

Commit 8c78030

Browse files
committed
Add second test OpifyOp
Since aliases are no longer returned in help text, many of these tests require two separate classes to be registered in a bare op environment.
1 parent 0712541 commit 8c78030

1 file changed

Lines changed: 23 additions & 17 deletions

File tree

scijava-ops-engine/src/test/java/org/scijava/ops/engine/OpEnvironmentTest.java

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,29 +47,29 @@ public class OpEnvironmentTest extends AbstractTestEnvironment {
4747

4848
@Test
4949
public void testClassOpification() {
50-
OpInfo opifyOpInfo = ops.opify(OpifyOp.class, OpifyOp.class.getName());
51-
Assertions.assertEquals(OpifyOp.class.getName(), opifyOpInfo.implementationName());
50+
OpInfo opifyOpInfo = ops.opify(OpifyOp1.class, OpifyOp1.class.getName());
51+
Assertions.assertEquals(OpifyOp1.class.getName(), opifyOpInfo.implementationName());
5252
// assert default priority
5353
Assertions.assertEquals(Priority.NORMAL, opifyOpInfo.priority(), 0.);
5454
}
5555

5656
@Test
5757
public void testClassOpificationWithPriority() {
58-
OpInfo opifyOpInfo = ops.opify(OpifyOp.class, Priority.HIGH, OpifyOp.class.getName());
59-
Assertions.assertEquals(OpifyOp.class.getName(), opifyOpInfo.implementationName());
58+
OpInfo opifyOpInfo = ops.opify(OpifyOp1.class, Priority.HIGH, OpifyOp1.class.getName());
59+
Assertions.assertEquals(OpifyOp1.class.getName(), opifyOpInfo.implementationName());
6060
// assert default priority
6161
Assertions.assertEquals(Priority.HIGH, opifyOpInfo.priority(), 0.);
6262
}
6363

6464
@Test
6565
public void testRegister() {
6666
String opName = "test.opifyOp";
67-
OpInfo opifyOpInfo = ops.opify(OpifyOp.class, Priority.HIGH, opName);
67+
OpInfo opifyOpInfo = ops.opify(OpifyOp1.class, Priority.HIGH, opName);
6868
ops.register(opifyOpInfo);
6969

7070
String actual = ops.op(opName).arity0().outType(String.class).create();
7171

72-
String expected = new OpifyOp().getString();
72+
String expected = new OpifyOp1().getString();
7373
Assertions.assertEquals(expected, actual);
7474
}
7575

@@ -99,7 +99,7 @@ public void testHelpVerboseOp() {
9999

100100
// Get the Op matching the description
101101
String descriptions = helpEnv.helpVerbose("help.verbose1");
102-
String expected = "help.verbose1:\n\t- org.scijava.ops.engine.OpifyOp\n\t\tReturns : java.lang.String\nKey: *=container, ^=mutable";
102+
String expected = "help.verbose1:\n\t- org.scijava.ops.engine.OpifyOp1\n\t\tReturns : java.lang.String\nKey: *=container, ^=mutable";
103103
Assertions.assertEquals(expected, descriptions);
104104
}
105105

@@ -125,26 +125,24 @@ public void testInternalNamespaceHelp() {
125125
Assertions.assertEquals(expected, actual);
126126
}
127127

128-
private OpEnvironment makeHelpEnv(String... names) {
128+
private OpEnvironment makeHelpEnv(String n1, String n2) {
129129
// NB We use a new OpEnvironment here for a clean list of Ops.
130130
OpEnvironment helpEnv = barebonesEnvironment();
131131
// Register an Op under an "internal" namespace and an "external" namespace
132132
helpEnv.register( //
133-
helpEnv.opify(OpifyOp.class, Priority.HIGH, names) //
133+
helpEnv.opify(OpifyOp1.class, Priority.HIGH, n1) //
134+
);
135+
helpEnv.register( //
136+
helpEnv.opify(OpifyOp2.class, Priority.HIGH, n2) //
134137
);
135138
return helpEnv;
136139
}
137140

138141
}
139142

140-
/**
141-
* Test class to be opified (and added to the {@link OpEnvironment})
142-
*
143-
* TODO: remove @Parameter annotation when it is no longer necessary
144-
*
145-
* @author Gabriel Selzer
146-
*/
147-
class OpifyOp implements Producer<String> {
143+
// -- Test classes to be registered --
144+
145+
class OpifyOp1 implements Producer<String> {
148146

149147
@Override
150148
public String create() {
@@ -156,3 +154,11 @@ public String getString() {
156154
}
157155

158156
}
157+
158+
class OpifyOp2 implements Producer<String> {
159+
160+
@Override
161+
public String create() { return getString(); }
162+
163+
public String getString() { return "This Op tests opify!"; }
164+
}

0 commit comments

Comments
 (0)