import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Range;
import java.io.File;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.WildcardType;
import java.math.BigDecimal;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
*/
public class CompilationTest extends BaseCompilationTest {
+ /*
+ * Java 8 allows JaCoCo to hook onto interfaces, as well as
+ * generating a default implementation. We only want to check
+ * abstract methods.
+ */
+ private static Collection<Method> abstractMethods(final Class<?> clazz) {
+ // Filter out
+ return Collections2.filter(Arrays.asList(clazz.getDeclaredMethods()), new Predicate<Method>() {
+ @Override
+ public boolean apply(final Method input) {
+ return Modifier.isAbstract(input.getModifiers());
+ }
+ });
+ }
+
@Test
public void testListGeneration() throws Exception {
final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "list-gen");
// Test generated 'grouping key-args'
assertTrue(keyArgsClass.isInterface());
- assertEquals(2, keyArgsClass.getDeclaredMethods().length);
assertContainsMethod(keyArgsClass, String.class, "getName");
assertContainsMethod(keyArgsClass, Integer.class, "getSize");
+ assertEquals(2, abstractMethods(keyArgsClass).size());
// Test generated 'list links'
assertTrue(linksClass.isInterface());
- // TODO: anyxml
- assertEquals(6, linksClass.getDeclaredMethods().length);
assertImplementsIfc(linksClass, keyArgsClass);
+ // TODO: anyxml
+ assertEquals(6, abstractMethods(linksClass).size());
// Test list key constructor arguments ordering
assertContainsConstructor(linksKeyClass, Byte.class, String.class, Integer.class);