Skip to content

Commit

Permalink
Fixed Sonar violations with missing generic signatures.
Browse files Browse the repository at this point in the history
  • Loading branch information
sskorol committed Jul 18, 2020
1 parent b784d47 commit 3ba5b9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ private DataSupplierMetaData getMetaData(final ITestContext context, final ITest
}

@SuppressWarnings("FinalLocalVariable")
private void assignCustomDataSupplier(final IDataProvidable annotation, final Method testMethod,
final Class testClass) {
private <T> void assignCustomDataSupplier(final IDataProvidable annotation, final Method testMethod,
final Class<T> testClass) {
var dataSupplierClass = getDataSupplierClass(annotation, testClass, testMethod);
var dataSupplierAnnotation = getDataSupplierAnnotation(dataSupplierClass, annotation.getDataProvider());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
*/
public interface IAnnotationTransformerInterceptor {

default void transform(final ITestAnnotation annotation, final Class testClass,
final Constructor testConstructor, final Method testMethod) {
default <T> void transform(final ITestAnnotation annotation, final Class<T> testClass,
final Constructor<T> testConstructor, final Method testMethod) {
// not implemented
}

default void transform(final IFactoryAnnotation annotation, final Method testMethod) {
// not implemented
}

default void transform(final IConfigurationAnnotation annotation, final Class testClass,
final Constructor testConstructor, final Method testMethod) {
default <T> void transform(final IConfigurationAnnotation annotation, final Class<T> testClass,
final Constructor<T> testConstructor, final Method testMethod) {
// not implemented
}

default void transform(final IDataProviderAnnotation annotation, final Method method) {
// not implemented
}

default void transform(final IListenersAnnotation annotation, final Class testClass) {
default <T> void transform(final IListenersAnnotation annotation, final Class<T> testClass) {
// not implemented
}
}
10 changes: 6 additions & 4 deletions src/main/java/io/github/sskorol/utils/ReflectionUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
@UtilityClass
public class ReflectionUtils {

public static Class<?> getDataSupplierClass(final IDataProvidable annotation, final Class testClass,
final Method testMethod) {
@SuppressWarnings("unchecked")
public static <T> Class<T> getDataSupplierClass(final IDataProvidable annotation, final Class<T> testClass,
final Method testMethod) {
return ofNullable(annotation.getDataProviderClass())
.map(dataProviderClass -> (Class) dataProviderClass)
.orElseGet(() -> findParentDataSupplierClass(testMethod, testClass));
Expand Down Expand Up @@ -148,8 +149,9 @@ private static Tuple2<Class<?>, String> getFactoryAnnotationMetaData(final ITest
return Tuple.of(dataProviderClass, dataProviderMethod);
}

private static Class<?> findParentDataSupplierClass(final Method testMethod, final Class testClass) {
return ofNullable(testMethod)
@SuppressWarnings("unchecked")
private static <T> Class<T> findParentDataSupplierClass(final Method testMethod, final Class<T> testClass) {
return (Class<T>) ofNullable(testMethod)
.map(m -> Tuple.of(m, new Reflections(m.getDeclaringClass().getPackage().getName())))
.map(findParentDataSupplierClass())
.orElse(testClass);
Expand Down

0 comments on commit 3ba5b9d

Please sign in to comment.