[jboss-svn-commits] JBL Code SVN: r26327 - in labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor: server/util and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 1 02:37:27 EDT 2009
Author: Rikkola
Date: 2009-05-01 02:37:27 -0400 (Fri, 01 May 2009)
New Revision: 26327
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine2Test.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/server/util/ClassMethodInspectorTest.java
Log:
GUVNOR-252 : Unable to fix broken imported brl rule
GUVNOR-261 : Can't select fields from a global list
BRMS-75 : Unable to fix broken imported brl rule
Fixed tests to work with all Java versions.
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine2Test.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine2Test.java 2009-05-01 04:49:27 UTC (rev 26326)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/client/modeldriven/SuggestionCompletionEngine2Test.java 2009-05-01 06:37:27 UTC (rev 26327)
@@ -27,15 +27,17 @@
assertNotNull( methodNames );
assertFalse( methodNames.isEmpty() );
- assertEquals( 12,
- methodNames.size() );
+ for ( String s : methodNames ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
- /*
- *
- * TODO: Check something.set(int index, Object o)!
- *
- */
-
+ private boolean allowedMethod(String methodName) {
+ return ("hashCode".equals( methodName ) || "equals".equals( methodName ) || "listIterator".equals( methodName ) || "lastIndexOf".equals( methodName ) || "indexOf".equals( methodName ) || "subList".equals( methodName )
+ || "get".equals( methodName ) || "isEmpty".equals( methodName ) || "containsKey".equals( methodName ) || "values".equals( methodName ) || "entrySet".equals( methodName ) || "containsValue".equals( methodName )
+ || "keySet".equals( methodName ) || "size".equals( methodName ) || "toArray".equals( methodName ) || "iterator".equals( methodName ) || "contains".equals( methodName ) || "isEmpty".equals( methodName )
+ || "containsAll".equals( methodName ) || "size".equals( methodName ));
+ }
}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/server/util/ClassMethodInspectorTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/server/util/ClassMethodInspectorTest.java 2009-05-01 04:49:27 UTC (rev 26326)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/guvnor/server/util/ClassMethodInspectorTest.java 2009-05-01 06:37:27 UTC (rev 26327)
@@ -34,60 +34,83 @@
public void testSimpleMethods() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( SimpleMethods.class );
- assertEquals( 3,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testMoreThanOneMethodWithTheSameName() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( MoreThanOneMethodWithTheSameName.class );
- assertEquals( 5,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testCollection() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( Collection.class );
- assertEquals( 6,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testArrayList() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( ArrayList.class );
- assertEquals( 12,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testList() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( List.class );
- assertEquals( 11,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testSet() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( Set.class );
- assertEquals( 6,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testMap() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( Map.class );
- assertEquals( 4,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
public void testMyMap() throws Exception {
final ClassMethodInspector ext = new ClassMethodInspector( MyMap.class );
- assertEquals( 5,
- ext.getMethodNames().size() );
+ for ( String s : ext.getMethodNames() ) {
+ assertFalse( "Method " + s + " is not allowed.",
+ allowedMethod( s ) );
+ }
}
+ private boolean allowedMethod(String methodName) {
+ return ("hashCode".equals( methodName ) || "equals".equals( methodName ) || "listIterator".equals( methodName ) || "lastIndexOf".equals( methodName ) || "indexOf".equals( methodName ) || "subList".equals( methodName )
+ || "get".equals( methodName ) || "isEmpty".equals( methodName ) || "containsKey".equals( methodName ) || "values".equals( methodName ) || "entrySet".equals( methodName ) || "containsValue".equals( methodName )
+ || "keySet".equals( methodName ) || "size".equals( methodName ) || "toArray".equals( methodName ) || "iterator".equals( methodName ) || "contains".equals( methodName ) || "isEmpty".equals( methodName )
+ || "containsAll".equals( methodName ) || "size".equals( methodName ));
+ }
+
public static class SimpleMethods {
public void cleanOrSimilar() {
More information about the jboss-svn-commits
mailing list