Skip to content

Commit baee2b5

Browse files
committed
Add invalid ns/op help string
1 parent 9293623 commit baee2b5

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

scijava-ops-engine/src/main/java/org/scijava/ops/engine/matcher/simplify/SimplifiedOpDescriptionGenerator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ private Optional<String> getNonOpString(OpEnvironment env, String name) {
114114
prefix = "Names:\n\t> ";
115115
}
116116
if (nsStream == null) return Optional.empty();
117-
return Optional.of(prefix + nsStream.collect(Collectors.joining("\n\t> ")));
117+
String suffix = nsStream.collect(Collectors.joining("\n\t> "));
118+
119+
if (Strings.isNullOrEmpty(suffix))
120+
return Optional.of("Not a valid Op name or namespace:\n\t> " + name);
121+
122+
return Optional.of(prefix + suffix);
118123
}
119124

120125
/**

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ public void testHelpVerboseNoNS() {
8383
Assertions.assertEquals(expected, descriptions);
8484
}
8585

86+
@Test
87+
public void testHelpVerboseInvalid() {
88+
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");
89+
90+
// Test that our namespace is found
91+
String descriptions = helpEnv.helpVerbose("ichneumon");
92+
String expected = "Not a valid Op name or namespace:\n\t> ichneumon";
93+
Assertions.assertEquals(expected, descriptions);
94+
}
95+
8696
@Test
8797
public void testHelpVerboseNS() {
8898
OpEnvironment helpEnv = makeHelpEnv("help.verbose1", "help.verbose2");

0 commit comments

Comments
 (0)