openVirus
openVirus copied to clipboard
NPE in `AMI.execute` without subcommand
`AMI.execute(class, cmd) is used to extract the abstractTool and read the options summary.
successful example
org.contentmine.ami.tools.AMIFilterTest.testFallback(), creates a testable Options value output:
@Test
public void testFallback() {
AMIFilterTool filterTool = AMI.execute(AMIFilterTool.class, "-vv filter --duplicate --monochrome");
Assert.assertEquals("options value", "" +
"--duplicate : m duplicate\n" +
"--maxheight : d 1000\n" +
"--maxwidth : d 1000\n" +
"--minheight : d 100\n" +
"--minwidth : d 100\n" +
"--monochrome : m monochrome\n" +
"--small : d null\n" +
"--help : d false\n" +
"--version : d false\n" +
"", filterTool.getOptionsValue());
}
## unsuccessful example
org.contentmine.ami.tools.AMIFilterTest.testGenericHelp()
with the subcommand omitted,
AbstractAMITool abstractTool;
abstractTool = AMI.execute(AMIFilterTool.class, "ami --help");
Assert.assertEquals(""
+ " assert Makes assertions about objects created by AMI.\n" +
...
" transform Runs XSLT transformation on XML (NYFI).\n" +
" words Analyzes word frequencies.\n" +
" help Displays help information about the specified command\n" +
" generate-completion Generate bash/zsh completion script for ami.",
abstractTool.getOptionsValue());
fails with
@Test
public void testGenericHelp() {
/** fails
* java.lang.NullPointerException
at org.contentmine.ami.tools.AMI.execute(AMI.java:138)
at org.contentmine.ami.tools.AMI.execute(AMI.java:133)
at org.contentmine.ami.tools.AMIFilterTest.testGenericHelp(AMIFilterTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
...
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
abstractTool = AMI.execute(AbstractAMITool.class, " --help");
Fixed in ami3 master.
FYI: You may be interested in https://stefanbirkner.github.io/system-rules/#SystemErrAndOutRule for asserting on tool's output to system.out/system.err
On Mon, May 25, 2020 at 11:59 AM Remko Popma [email protected] wrote:
Fixed in ami3 master.
FYI: You may be interested in https://stefanbirkner.github.io/system-rules/#SystemErrAndOutRule for asserting on tool's output to system.out/system.err
Thanks - useful. Probably cleaner than what I did...
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/petermr/openVirus/issues/56#issuecomment-633515184, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFTCSY7NCOQSWAWBXYHGCLRTJFSDANCNFSM4NJLQKBQ .
-- Peter Murray-Rust Founder ContentMine.org and Reader Emeritus in Molecular Informatics Dept. Of Chemistry, University of Cambridge, CB2 1EW, UK
I don't have privileges to close this ticket, but is there any work still outstanding?