Drools java.lang.NullPointerException at org.drools.reteoo.RuleTerminalNode any idea - jboss

As usual in these days I am working hard on drools. Honestly I have a lot of difficulties and I am a little bi discouraged. Now I have this problem.
My application has to monitor when a magnetic contact is activated and when it is contact released event has to be retracted. And viceversa. Here is my rule and the big null pointer I have. Any helps will be very appreciated! Thank you a lot!!
rule "contact activated vs contact released" salience 0 no-loop true
when
$contact_activated : Event(type == EventType.CONTACT_ACTIVATED) ||
$contact_released : Event(type == EventType.CONTACT_RELEASED)
then
if($contact_activated!= null) {
retract($contact_activated);
} else {
retract($contact_released);
}
end
and
I have
java.lang.NullPointerException
at org.drools.reteoo.RuleTerminalNode$SortDeclarations.compare(RuleTerminalNode.java:477)
at org.drools.reteoo.RuleTerminalNode$SortDeclarations.compare(RuleTerminalNode.java:473)
at java.util.Arrays.mergeSort(Arrays.java:1270)
at java.util.Arrays.sort(Arrays.java:1210)
at org.drools.reteoo.RuleTerminalNode.<init>(RuleTerminalNode.java:119)
at org.drools.RuleActivationListenerFactory.createActivationListener(RuleActivationListenerFactory.java:21)
at org.drools.reteoo.builder.ReteooRuleBuilder.addSubRule(ReteooRuleBuilder.java:157)
at org.drools.reteoo.builder.ReteooRuleBuilder.addRule(ReteooRuleBuilder.java:123)
at org.drools.reteoo.ReteooBuilder.addRule(ReteooBuilder.java:110)
at org.drools.reteoo.ReteooRuleBase.addRule(ReteooRuleBase.java:441)
at org.drools.common.AbstractRuleBase.addRule(AbstractRuleBase.java:821)
at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:555)
at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:458)
at org.drools.impl.KnowledgeBaseImpl.addKnowledgePackages(KnowledgeBaseImpl.java:150)
at it.ipiu.pch.sel.RuleTest.before(RuleTest.java:1272)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

This looks like a bug, I suggest you submit a JIRA to the project. Which version are you using?
At the same time, your rule is more complicated than it should. Every time you see an "if" in the consequence, it is a red flag something is not good. You can rewrite your rule as:
rule "contact activated vs contact released"
when
$contact : Event( type in ( EventType.CONTACT_ACTIVATED, EventType.CONTACT_RELEASED ) )
then
retract($contact);
end

Related

ProjectClassPathModifier and ProjectClassPathExtender

I am trying to contribute a fix to a Netbeans 8 plugin which is currently broken. The plugin includes an "add support" menu item which is supposed to, amongst other things, add an entry to the project class path if the project is an ANT project. Currently it does this by manually rewriting the project properties file. This fails in certain cases, e.g. if the project has a dedicated library folder.
I have managed to code a fix which uses the ProjectClassExtender API class to add the library to the class, but this is a deprecated API. I've tried a couple of approaches to working via the replacement ProjectClassPathModifier, but I cannot get the right combination of parameters - I always get an Unsupported Operation exception or similar. Can someone please help here?
The code below condenses the three approaches I've tried:
FileObject projectRoot = project.getProjectDirectory();
Sources sources = ProjectUtils.getSources(project);
SourceGroup sourceGroup = sources.getSourceGroups(Sources.TYPE_GENERIC)[0];
FileObject sgRoot = sourceGroup.getRootFolder();
Library lib = libraryManager.getLibrary(LIB_NAME);
ProjectClassPathModifier pcpm = projectLookup.lookup(ProjectClassPathModifier.class);
ProjectClassPathExtender pcpe = pcpm.extenderForModifier(project);
pcpe.addLibrary(lib); // Works but deprecated
pcpm.addLibraries(new Library[]{lib}, projectRoot, ClassPath.COMPILE); // Fails regardless
pcpm.addLibraries(new Library[]{lib}, sgRoot, ClassPath.COMPILE); // Fails regardless
The call using projectRoot gives this error:
Java.lang.UnsupportedOperationException: Project in C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16 of class org.netbeans.modules.java.j2seproject.J2SEProject has a ProjectClassPathModifierImplementation but it will not handle classpath/compile for C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16 extensible source groups: C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication16\src
at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.findExtensible(ProjectClassPathModifier.java:388)
at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.addLibraries(ProjectClassPathModifier.java:93)
at org.nemesis.antlr.v4.netbeans.v8.project.AntBasedProject.addPropertiesToProject(AntBasedProject.java:615)
at org.nemesis.antlr.v4.netbeans.v8.project.AntBasedProject.addANTLRSupport(AntBasedProject.java:122)
at org.nemesis.antlr.v4.netbeans.v8.project.action.AddANTLRSupport.actionPerformed(AddANTLRSupport.java:134)
[catch] at org.openide.awt.InjectorExactlyOne.actionPerformed(InjectorExactlyOne.java:78)
at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)
at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
The call using sgRoot gives this very similar error:
java.lang.UnsupportedOperationException: Project in C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication17 of class org.netbeans.modules.java.j2seproject.J2SEProject has a ProjectClassPathModifierImplementation but it will not handle classpath/compile for C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication17 extensible source groups: C:\Users\sparry\ownCloud\development\NetbeansProjects\JavaApplication17\src
at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.findExtensible(ProjectClassPathModifier.java:388)
at org.netbeans.api.java.project.classpath.ProjectClassPathModifier.addLibraries(ProjectClassPathModifier.java:93)
at org.nemesis.antlr.v4.netbeans.v8.project.AntBasedProject.addPropertiesToProject(AntBasedProject.java:616)
at org.nemesis.antlr.v4.netbeans.v8.project.AntBasedProject.addANTLRSupport(AntBasedProject.java:122)
at org.nemesis.antlr.v4.netbeans.v8.project.action.AddANTLRSupport.actionPerformed(AddANTLRSupport.java:134)
[catch] at org.openide.awt.InjectorExactlyOne.actionPerformed(InjectorExactlyOne.java:78)
at org.openide.awt.ContextAction$Performer.actionPerformed(ContextAction.java:226)
at org.openide.awt.ContextManager.actionPerformed(ContextManager.java:260)
at org.openide.awt.ContextAction.actionPerformed(ContextAction.java:109)
at org.openide.util.actions.ActionInvoker$1.run(ActionInvoker.java:93)
at org.openide.util.actions.ActionInvoker.doPerformAction(ActionInvoker.java:116)
at org.openide.util.actions.ActionInvoker.invokeAction(ActionInvoker.java:99)
at org.openide.awt.GeneralAction$BaseDelAction.actionPerformed(GeneralAction.java:234)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I think I have worked out the problem and a solution myself:
Sources sources = ProjectUtils.getSources(project);
SourceGroup sourceGroup = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)[0];
FileObject sgRoot = sourceGroup.getRootFolder();
Library lib = libraryManager.getLibrary(LIB_NAME);
ProjectClassPathModifier pcpm = projectLookup.lookup(ProjectClassPathModifier.class);
pcpm.addLibraries(new Library[]{lib}, sgRoot, ClassPath.COMPILE); // works!
The key is using the JavaProjectConstants.SOURCES_TYPE_JAVA source type, not Sources.TYPE_GENERIC. Generic returns the project main folder and the addLibraries call needs a java source folder. In most projects, that's the src folder.

I have to write JUnit test case for service layer which uses ListIterator and returns list

Problem:
I have service method which returns list of objects in reverse order.
It is fetching list of objects from MongoDB using MongoTemplate,Query and uses ListIterator for reversing the list.
Now, I have to write JUnit test case for the above.
My present code where I am Mocking mongotemplate
MongoTemplate mongoTemplate = Mockito.mock(MongoTemplate.class);
Query query = Mockito.mock(Query.class);
CRDetails crDetails = new CRDetails();
CertificateGuidelines certG1 = new CertificateGuidelines("certG1", Constants.CERTIFICATION_TEAM, Constants.DOC_DEVELOPER_STATUS, 1);
CertificateGuidelines certG2 = new CertificateGuidelines("certG2", Constants.DOCDEVELOPER, Constants.CERT_TEAM_STATUS, 2);
CertificateGuidelines certG3 = new CertificateGuidelines("certG3", Constants.CERTIFICATION_TEAM, Constants.DOC_DEVELOPER_STATUS, 3);
List<CertificateGuidelines> newHistoryList = new ArrayList<CertificateGuidelines>();
newHistoryList.add(certG1);
newHistoryList.add(certG2);
newHistoryList.add(certG3);
Mockito.when(mongoTemplate.findOne((org.springframework.data.mongodb.core.query.Query) Matchers.any(Query.class), Matchers.any(Class.class))).thenReturn(crDetails);
CRService service = new CRService();
service.setCertMongoTemplate(mongoTemplate);
assertEquals(historyList, newHistoryList);
My service method:
public List<CertificateGuidelines> getHistoryForCertGuidelines(String crNum) {
Query query = new Query(Criteria.where("cr").is(crNum));
CRDetails details = certMongoTemplate.findOne(query, CRDetails.class,
Constants.COLLECTION_NAME);
logger.debug("in history");
if (details != null) {
logger.debug("Certification Guidelines has " + details.getCertGuidelinesList().size() + "previous updates");
}
List<CertificateGuidelines> historyList = new ArrayList<CertificateGuidelines>();
// Add objects to list.
// Generate an iterator. Start just after the last CG object.
ListIterator<CertificateGuidelines> listItr = details.getCertGuidelinesList().listIterator(
details.getCertGuidelinesList().size());
// Iterate in reverse.
while (listItr.hasPrevious()) {
historyList.add((CertificateGuidelines) listItr.previous());
}
return historyList;
}
I know I am doing some mistake in writing test case. Not clear on how to approach. Please Guide.
Error Trace
java.lang.AssertionError: expected:<historyList> but was:<[com.cerner.docworks.domain.CertificateGuidelines#13805618, com.cerner.docworks.domain.CertificateGuidelines#56ef9176, com.cerner.docworks.domain.CertificateGuidelines#4566e5bd]>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:743)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:144)
at com.cerner.docworks.service.test.CRServiceTest.testServiceHistoryDB(CRServiceTest.java:113)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.mockito.internal.runners.JUnit45AndHigherRunnerImpl.run(JUnit45AndHigherRunnerImpl.java:37)
at org.mockito.runners.MockitoJUnitRunner.run(MockitoJUnitRunner.java:62)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Thanks in advance
I believe that you are testing the equality of two lists, when what you really want to do is check that the lists contain the same elements.
The easiest way to do this is to use Hamcrest, which has the added advantage that it will show a better message in the event of failure.
Assert.assertThat(historyList,IsIterableContainingOrder.contains(newHistoryList.toArray()));

Scala Compiler Error: assertion failed: scala.<none>

Has anyone seen this before? The error below happens when I build my Scala/Play project in Intellij. As you can see none of my code is part of the call-stack.
Error:scalac: Error: assertion failed: scala.<none>
java.lang.AssertionError: assertion failed: scala.<none>
at scala.reflect.internal.Trees$AppliedTypeTree.<init>(Trees.scala:579)
at scala.reflect.internal.TreeGen.mkTupleType(TreeGen.scala:293)
at scala.tools.nsc.ast.parser.TreeBuilder.makeTupleType(TreeBuilder.scala:44)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.scala$tools$nsc$ast$parser$Parsers$Parser$PatternContextSensitive$$tupleInfixType(Parsers.scala:877)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$typ$1.apply(Parsers.scala:910)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$typ$1.apply(Parsers.scala:907)
at scala.tools.nsc.ast.parser.Parsers$Parser.placeholderTypeBoundary(Parsers.scala:487)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.typ(Parsers.scala:907)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.typ(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.argType(Parsers.scala:1996)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$types$1.apply(Parsers.scala:1042)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$types$1.apply(Parsers.scala:1042)
at scala.tools.nsc.ast.parser.Parsers$Parser.tokenSeparated(Parsers.scala:761)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.types(Parsers.scala:1042)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.types(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.typeArgs(Parsers.scala:924)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.typeArgs(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.simpleTypeRest(Parsers.scala:963)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.simpleTypeRest(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.simpleType(Parsers.scala:943)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.simpleType(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$annotType$1.apply(Parsers.scala:930)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$$anonfun$annotType$1.apply(Parsers.scala:930)
at scala.tools.nsc.ast.parser.Parsers$Parser.placeholderTypeBoundary(Parsers.scala:487)
at scala.tools.nsc.ast.parser.Parsers$Parser$PatternContextSensitive$class.annotType(Parsers.scala:930)
at scala.tools.nsc.ast.parser.Parsers$Parser$outPattern$.annotType(Parsers.scala:1995)
at scala.tools.nsc.ast.parser.Parsers$Parser.startAnnotType(Parsers.scala:2017)
at scala.tools.nsc.ast.parser.Parsers$Parser.readAppliedParent$1(Parsers.scala:2822)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateParents(Parsers.scala:2828)
at scala.tools.nsc.ast.parser.Parsers$Parser.template(Parsers.scala:2855)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateOpt(Parsers.scala:2886)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$classDef$1.apply(Parsers.scala:2753)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$classDef$1.apply(Parsers.scala:2733)
at scala.tools.nsc.ast.parser.Parsers$Parser.savingClassContextBounds(Parsers.scala:329)
at scala.tools.nsc.ast.parser.Parsers$Parser.classDef(Parsers.scala:2733)
at scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:2710)
at scala.tools.nsc.ast.parser.Parsers$Parser.defOrDcl(Parsers.scala:2467)
at scala.tools.nsc.ast.parser.Parsers$Parser.nonLocalDefOrDcl(Parsers.scala:2475)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStat$1$$anonfun$applyOrElse$3.apply(Parsers.scala:3032)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStat$1$$anonfun$applyOrElse$3.apply(Parsers.scala:3032)
at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:702)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStat$1.applyOrElse(Parsers.scala:3032)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStat$1.applyOrElse(Parsers.scala:3027)
at scala.tools.nsc.ast.parser.Parsers$Parser.statSeq(Parsers.scala:2959)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateStats(Parsers.scala:3026)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:3013)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$templateStatSeq$1.apply(Parsers.scala:2990)
at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:464)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateStatSeq(Parsers.scala:2990)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateBody(Parsers.scala:2919)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateBodyOpt(Parsers.scala:2926)
at scala.tools.nsc.ast.parser.Parsers$Parser.template(Parsers.scala:2856)
at scala.tools.nsc.ast.parser.Parsers$Parser.templateOpt(Parsers.scala:2886)
at scala.tools.nsc.ast.parser.Parsers$Parser.objectDef(Parsers.scala:2775)
at scala.tools.nsc.ast.parser.Parsers$Parser.tmplDef(Parsers.scala:2714)
at scala.tools.nsc.ast.parser.Parsers$Parser.topLevelTmplDef(Parsers.scala:2695)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStat$1$$anonfun$applyOrElse$2.apply(Parsers.scala:2982)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStat$1$$anonfun$applyOrElse$2.apply(Parsers.scala:2982)
at scala.tools.nsc.ast.parser.Parsers$Parser.joinComment(Parsers.scala:702)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStat$1.applyOrElse(Parsers.scala:2982)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$topStat$1.applyOrElse(Parsers.scala:2975)
at scala.tools.nsc.ast.parser.Parsers$Parser.statSeq(Parsers.scala:2959)
at scala.tools.nsc.ast.parser.Parsers$Parser.topStatSeq(Parsers.scala:2974)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.topstats$1(Parsers.scala:3172)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3178)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$compilationUnit$1.apply(Parsers.scala:3140)
at scala.tools.nsc.ast.parser.Parsers$Parser.checkNoEscapingPlaceholders(Parsers.scala:464)
at scala.tools.nsc.ast.parser.Parsers$Parser.compilationUnit(Parsers.scala:3140)
at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:146)
at scala.tools.nsc.ast.parser.Parsers$SourceFileParser$$anonfun$parseStartRule$1.apply(Parsers.scala:146)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$parse$1.apply(Parsers.scala:354)
at scala.tools.nsc.ast.parser.Parsers$Parser$$anonfun$parse$1.apply(Parsers.scala:354)
at scala.tools.nsc.ast.parser.Parsers$Parser.parseRule(Parsers.scala:347)
at scala.tools.nsc.ast.parser.Parsers$Parser.parse(Parsers.scala:354)
at scala.tools.nsc.ast.parser.Parsers$UnitParser.smartParse(Parsers.scala:243)
at scala.tools.nsc.ast.parser.SyntaxAnalyzer.scala$tools$nsc$ast$parser$SyntaxAnalyzer$$initialUnitBody(SyntaxAnalyzer.scala:87)
at scala.tools.nsc.ast.parser.SyntaxAnalyzer$ParserPhase.apply(SyntaxAnalyzer.scala:99)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:430)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:397)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:397)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1174)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:397)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1625)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1610)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1605)
at scala.tools.nsc.Global$Run.compile(Global.scala:1703)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:126)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:28)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:25)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:64)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:22)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
The build was working fine previously so I wonder if it's an environmental issue.
Based on this PasteBin I know I'm not the first person to see this issue: http://pastebin.com/VtFy12UJ
Have you tried compiling outside of Intellij to see if that fixed the issue?
It's probably because you have a tuple with more than 22 items. Relevant Scala ticket: https://issues.scala-lang.org/browse/SI-9572
Double check your code.

How to mock builder.type().post() method in Jersey REST service

I need to mock builder.type(...).post(...) inorder to write test case for rest client.
But I'am getting null pointer exception when mocking it.
method to be mocked:
ClientResponse response = builder.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, credentials);
powermock-easymock code:
client_Response=new ClientResponse(201, null, null, null);
expect(builder.type(MediaType.APPLICATION_JSON).post(ClientResponse.class, credentials)).andReturn(clientResponse);
replay(builder);
java.lang.NullPointerException
at com.xx.xx.xx.xx.xx.xx.testServiceManagerImpl1(ServiceManagerImplTest.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:66)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:310)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:94)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:294)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:127)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:84)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:118)
at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:101)
at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53)
at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:53)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
you have to first mock type() and then mock post(). not sure about the api of builder and easy-mock, the possible code might be:
expect(builder.type(MediaType.APPLICATION_JSON)).andReturn(mockType)
expect(mockType.post(ClientResponse.class, credentials)).andReturn(clientResponse)

Why does adding a "pending" break my Scala test?

The commented line below breaks my testing
import org.scalatest.WordSpec
class LSESuite extends WordSpec {
"An LSE market" should {
"round values" in {
val lse = new LSE {
}
assert(lse.getMarketName === "LSE")
//"min tick size" is (pending)
}
}
}
I receive the following error "An it clause may not appear inside another it clause" but I'm not sure how to interpret. Edit stack trace:
org.scalatest.TestRegistrationClosedException: An it clause may not appear inside another it clause.
at org.scalatest.SuperEngine.registerTest(Engine.scala:406)
at org.scalatest.WordSpec$class.org$scalatest$WordSpec$$registerTestToRun(WordSpec.scala:1643)
at org.scalatest.WordSpec$WordSpecStringWrapper.is(WordSpec.scala:1823)
at org.scalatest.WordSpec$$anonfun$runTests$1.apply(WordSpec.scala:2232)
at org.scalatest.WordSpec$$anonfun$runTests$1.apply(WordSpec.scala:2232)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:226)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:215)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:215)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:231)
at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:215)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:215)
at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:282)
at org.scalatest.WordSpec$class.runTests(WordSpec.scala:2232)
at org.scalatest.Suite$class.run(Suite.scala:2286)
at org.scalatest.WordSpec$$anonfun$run$1.apply(WordSpec.scala:2279)
at org.scalatest.WordSpec$$anonfun$run$1.apply(WordSpec.scala:2279)
at org.scalatest.SuperEngine.runImpl(Engine.scala:318)
at org.scalatest.WordSpec$class.run(WordSpec.scala:2279)
at org.scalatest.tools.SuiteRunner.run(SuiteRunner.scala:59)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1517)
at org.scalatest.tools.Runner$$anonfun$doRunRunRunDaDoRunRun$3.apply(Runner.scala:1514)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1514)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:584)
at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:583)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1558)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:582)
at org.scalatest.tools.Runner$.run(Runner.scala:485)
at org.scalatest.tools.Runner.run(Runner.scala)
at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTest15Scala28Runner.main(ScalaTest15Scala28Runner.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Process finished with exit code 0
Your 'pending' seems to be in an odd location. So you might see the same problem as I saw here: http://groups.google.com/group/scalatest-users/browse_thread/thread/177bbc520edc8fbd