Skip to content
Permalink
Browse files
minor refactor: fix style warnings
  • Loading branch information
paulk-asert committed Apr 17, 2022
1 parent d0fd024 commit 1d4c8fc25a26be944e661485c44b5f0cfd7be3f1
Showing 3 changed files with 14 additions and 9 deletions.
@@ -264,7 +264,7 @@ public MetaClassRegistry getRegistry() {
* @see MetaObjectProtocol#respondsTo(Object, String, Object[])
*/
@Override
public List respondsTo(final Object obj, final String name, final Object[] argTypes) {
public List<MetaMethod> respondsTo(final Object obj, final String name, final Object[] argTypes) {
Class[] classes = castArgumentsToClassArray(argTypes);
MetaMethod m = getMetaMethod(name, classes);
if (m != null) {
@@ -277,12 +277,12 @@ public List respondsTo(final Object obj, final String name, final Object[] argTy
* @see MetaObjectProtocol#respondsTo(Object, String)
*/
@Override
public List respondsTo(final Object obj, final String name) {
public List<MetaMethod> respondsTo(final Object obj, final String name) {
final Object o = getMethods(getTheClass(), name, false);
if (o instanceof FastArray) {
return ((FastArray) o).toList();
}
return Collections.singletonList(o);
return Collections.<MetaMethod>singletonList((MetaMethod) o);
}

/**
@@ -295,7 +295,7 @@ public static Throwable shouldFail(GroovyShell shell, String script) {
* @return the test case method
* @throws RuntimeException if no method could be found.
*/
private static Method findRunningJUnitTestMethod(Class caller) {
private static Method findRunningJUnitTestMethod(Class<?> caller) {
final Class<?>[] args = new Class<?>[]{};

// search the initial junit test
@@ -78,17 +78,22 @@ public void loadTestSuite() throws Exception {
throw new RuntimeException("No filename given in the 'test' system property so cannot run a Groovy unit test");
}
System.out.println("Compiling: " + fileName);
Class<? extends TestCase> type = compile(fileName);
Class<?> type = compile(fileName);
String[] args = {};
if (!Test.class.isAssignableFrom(type) && Script.class.isAssignableFrom(type)) {
if (TestCase.class.isAssignableFrom(type)) {
addToTestSuite(type);
} else if (Script.class.isAssignableFrom(type)) {
// let's treat the script as a Test
addTest(new ScriptTestAdapter(type, args));
} else {
addTestSuite(type);
}
}

public Class<? extends TestCase> compile(String fileName) throws Exception {
@SuppressWarnings("unchecked")
private void addToTestSuite(Class<?> type) {
addTestSuite((Class<? extends TestCase>) type);
}

public Class<?> compile(String fileName) throws Exception {
return loader.parseClass(new File(fileName));
}
}

0 comments on commit 1d4c8fc

Please sign in to comment.