Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in AMI.execute without subcommand #56

Open
petermr opened this issue May 25, 2020 · 4 comments
Open

NPE in AMI.execute without subcommand #56

petermr opened this issue May 25, 2020 · 4 comments

Comments

@petermr
Copy link
Owner

petermr commented May 25, 2020

No description provided.

@petermr
Copy link
Owner Author

petermr commented May 25, 2020

`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");

remkop added a commit to petermr/ami3 that referenced this issue May 25, 2020
@remkop
Copy link

remkop commented May 25, 2020

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

@petermr
Copy link
Owner Author

petermr commented May 25, 2020 via email

@remkop
Copy link

remkop commented May 26, 2020

I don't have privileges to close this ticket, but is there any work still outstanding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants