Skip to content

Commit 0712541

Browse files
committed
Separate out verbose output tests
1 parent 22e932a commit 0712541

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

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

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,43 +74,48 @@ public void testRegister() {
7474
}
7575

7676
@Test
77-
public void testHelpVerbose() {
78-
// NB We use a new OpEnvironment here for a clean list of Ops.
79-
OpEnvironment helpEnv = barebonesEnvironment();
80-
helpEnv.register( //
81-
helpEnv.opify(OpifyOp.class, Priority.HIGH, "help.verbose1", "help.verbose2") //
82-
);
77+
public void testHelpVerboseNoNS() {
78+
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");
8379

84-
// Test that helpEnv.help() returns just "test"
80+
// Test that our namespace is found
8581
String descriptions = helpEnv.helpVerbose();
8682
String expected = "Namespaces:\n\t> help";
8783
Assertions.assertEquals(expected, descriptions);
84+
}
85+
86+
@Test
87+
public void testHelpVerboseNS() {
88+
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");
8889

89-
// Test that helpEnv.help("test") returns both of our namespaces
90-
descriptions = helpEnv.helpVerbose("help");
91-
expected = "Names:\n\t> help.verbose1\n\t> help.verbose2";
90+
// Test that both of our ops are found in the namespace
91+
String descriptions = helpEnv.helpVerbose("help");
92+
String expected = "Names:\n\t> help.verbose1\n\t> help.verbose2";
9293
Assertions.assertEquals(expected, descriptions);
94+
}
95+
96+
@Test
97+
public void testHelpVerboseOp() {
98+
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");
9399

94100
// Get the Op matching the description
95-
descriptions = helpEnv.helpVerbose("help.verbose1");
96-
expected = "help.verbose1:\n\t- org.scijava.ops.engine.OpifyOp\n\t\tReturns : java.lang.String\nKey: *=container, ^=mutable";
101+
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";
97103
Assertions.assertEquals(expected, descriptions);
104+
}
98105

106+
@Test
107+
public void testHelpVerboseNotFound() {
108+
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");
99109
// Finally assert a message is thrown when no Ops match
100-
descriptions = helpEnv.unary("help.verbose1").helpVerbose();
101-
expected = "No Ops found matching this request.";
110+
String descriptions = helpEnv.unary("help.verbose1").helpVerbose();
111+
String expected = "No Ops found matching this request.";
102112
Assertions.assertEquals(expected, descriptions);
103113
}
104114

105115
@Test
106116
public void testInternalNamespaceHelp() {
107-
// NB We use a new OpEnvironment here for a clean list of Ops.
108-
OpEnvironment helpEnv = barebonesEnvironment();
109-
// Register an Op under an "internal" namespace and an "external" namespace
110-
helpEnv.register( //
111-
helpEnv.opify(OpifyOp.class, Priority.HIGH, "engine.adapt", "help.verbose1") //
112-
);
113117
// Make sure that only the "external" namespaces are visible
118+
OpEnvironment helpEnv = makeHelpEnv("engine.adapt", "help.verbose1");
114119
var actual = helpEnv.help();
115120
String expected = "Namespaces:\n\t> help";
116121
Assertions.assertEquals(expected, actual);
@@ -120,6 +125,16 @@ public void testInternalNamespaceHelp() {
120125
Assertions.assertEquals(expected, actual);
121126
}
122127

128+
private OpEnvironment makeHelpEnv(String... names) {
129+
// NB We use a new OpEnvironment here for a clean list of Ops.
130+
OpEnvironment helpEnv = barebonesEnvironment();
131+
// Register an Op under an "internal" namespace and an "external" namespace
132+
helpEnv.register( //
133+
helpEnv.opify(OpifyOp.class, Priority.HIGH, names) //
134+
);
135+
return helpEnv;
136+
}
137+
123138
}
124139

125140
/**

0 commit comments

Comments
 (0)