@Test public void isACollection_true() { final Helper helper = new Helper(elementUtils, typeUtils); when(typeUtils.isAssignable(any(TypeMirror.class), any(TypeMirror.class))).thenReturn(true); ASSERT.that(helper.isACollection(mock(TypeMirror.class))).isTrue(); }
public boolean isACollection(TypeMirror typeMirror) { TypeMirror collectionType = typeUtils.getDeclaredType( elementUtils.getTypeElement(Collection.class.getCanonicalName()), typeUtils.getWildcardType(null, null) ); final TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); final String qualifiedName = typeElement.getQualifiedName().toString(); final TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType(); return typeUtils.isAssignable(copy, collectionType); }
Helper { public boolean isACollection(TypeMirror typeMirror) { TypeMirror collectionType = typeUtils.getDeclaredType( elementUtils.getTypeElement(Collection.class.getCanonicalName()), typeUtils.getWildcardType(null, null) ); final TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); final String qualifiedName = typeElement.getQualifiedName().toString(); final TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType(); return typeUtils.isAssignable(copy, collectionType); } }
Helper { public boolean isACollection(TypeMirror typeMirror) { TypeMirror collectionType = typeUtils.getDeclaredType( elementUtils.getTypeElement(Collection.class.getCanonicalName()), typeUtils.getWildcardType(null, null) ); final TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); final String qualifiedName = typeElement.getQualifiedName().toString(); final TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType(); return typeUtils.isAssignable(copy, collectionType); } Helper(Elements elementUtils, Types typeUtils); }
Helper { public boolean isACollection(TypeMirror typeMirror) { TypeMirror collectionType = typeUtils.getDeclaredType( elementUtils.getTypeElement(Collection.class.getCanonicalName()), typeUtils.getWildcardType(null, null) ); final TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); final String qualifiedName = typeElement.getQualifiedName().toString(); final TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType(); return typeUtils.isAssignable(copy, collectionType); } Helper(Elements elementUtils, Types typeUtils); boolean isACollection(TypeMirror typeMirror); }
Helper { public boolean isACollection(TypeMirror typeMirror) { TypeMirror collectionType = typeUtils.getDeclaredType( elementUtils.getTypeElement(Collection.class.getCanonicalName()), typeUtils.getWildcardType(null, null) ); final TypeElement typeElement = (TypeElement) typeUtils.asElement(typeMirror); final String qualifiedName = typeElement.getQualifiedName().toString(); final TypeMirror copy = elementUtils.getTypeElement(qualifiedName).asType(); return typeUtils.isAssignable(copy, collectionType); } Helper(Elements elementUtils, Types typeUtils); boolean isACollection(TypeMirror typeMirror);  }