Skip to content

Commit

Permalink
[FLINK-29846][build] Upgrade ArchUnit to 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
snuyanzin committed Dec 12, 2022
1 parent 72a7031 commit ba6c0c7
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static <T extends HasName> ArchCondition<T> fulfill(DescribedPredicate<T>
return new ArchCondition<T>(predicate.getDescription()) {
@Override
public void check(T item, ConditionEvents events) {
if (!predicate.apply(item)) {
if (!predicate.test(item)) {
final String message =
String.format(
"%s does not satisfy: %s",
Expand Down Expand Up @@ -89,7 +89,7 @@ public void check(JavaMethod method, ConditionEvents events) {
continue;
}

if (!typePredicate.apply(leafType)) {
if (!typePredicate.test(leafType)) {
final String message =
String.format(
"%s: Returned leaf type %s does not satisfy: %s",
Expand Down Expand Up @@ -125,7 +125,7 @@ public void check(JavaMethod method, ConditionEvents events) {
continue;
}

if (!typePredicate.apply(leafType)) {
if (!typePredicate.test(leafType)) {
final String message =
String.format(
"%s: Argument leaf type %s does not satisfy: %s",
Expand Down Expand Up @@ -161,7 +161,7 @@ public void check(JavaMethod method, ConditionEvents events) {
continue;
}

if (!typePredicate.apply(leafType)) {
if (!typePredicate.test(leafType)) {
final String message =
String.format(
"%s: Exception leaf type %s does not satisfy: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

package org.apache.flink.architecture.common;

import com.tngtech.archunit.base.ChainableFunction;
import com.tngtech.archunit.base.DescribedPredicate;
import com.tngtech.archunit.base.Function;
import com.tngtech.archunit.core.domain.JavaClass;
import com.tngtech.archunit.core.domain.JavaField;
import com.tngtech.archunit.core.domain.JavaModifier;
Expand All @@ -29,6 +27,7 @@
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.tngtech.archunit.lang.conditions.ArchPredicates.is;
Expand All @@ -48,7 +47,7 @@ public static DescribedPredicate<JavaClass> areDirectlyAnnotatedWithAtLeastOneOf
Class<? extends Annotation>... annotations) {
return Arrays.stream(annotations)
.map(CanBeAnnotated.Predicates::annotatedWith)
.reduce(DescribedPredicate::or)
.reduce((p, pOther) -> p.or(pOther))
.orElseThrow(IllegalArgumentException::new)
.forSubtype();
}
Expand All @@ -59,16 +58,7 @@ public static DescribedPredicate<JavaClass> areDirectlyAnnotatedWithAtLeastOneOf
*/
public static DescribedPredicate<JavaClass> containAnyFieldsInClassHierarchyThat(
DescribedPredicate<? super JavaField> predicate) {
return new ContainAnyFieldsThatPredicate<>(
"fields",
new ChainableFunction<JavaClass, Set<JavaField>>() {
@Override
public Set<JavaField> apply(JavaClass input) {
// need to get all fields with the inheritance hierarchy
return input.getAllFields();
}
},
predicate);
return new ContainAnyFieldsThatPredicate<>("fields", JavaClass::getAllFields, predicate);
}

/**
Expand Down Expand Up @@ -164,10 +154,7 @@ public static <T> DescribedPredicate<T> exactlyOneOf(
+ Arrays.stream(other)
.map(dp -> "* " + dp + "\n")
.collect(Collectors.joining()),
t ->
Arrays.stream(other)
.map(dp -> dp.apply(t))
.reduce(false, Boolean::logicalXor));
t -> Arrays.stream(other).map(dp -> dp.test(t)).reduce(false, Boolean::logicalXor));
}

private Predicates() {}
Expand All @@ -191,9 +178,9 @@ private static class ContainAnyFieldsThatPredicate<T extends JavaField>
}

@Override
public boolean apply(JavaClass input) {
public boolean test(JavaClass input) {
for (T member : getFields.apply(input)) {
if (predicate.apply(member)) {
if (predicate.test(member)) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class SourcePredicates {
public static DescribedPredicate<JavaClass> areJavaClasses() {
return new DescribedPredicate<JavaClass>("are Java classes") {
@Override
public boolean apply(JavaClass clazz) {
public boolean test(JavaClass clazz) {
return isJavaClass(clazz);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,4 @@ org.apache.flink.streaming.runtime.operators.windowing.TimestampedValue.getStrea
org.apache.flink.streaming.runtime.streamrecord.LatencyMarker.getOperatorId(): Returned leaf type org.apache.flink.runtime.jobgraph.OperatorID does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.streaming.runtime.tasks.ProcessingTimeServiceAware.setProcessingTimeService(org.apache.flink.streaming.runtime.tasks.ProcessingTimeService): Argument leaf type org.apache.flink.streaming.runtime.tasks.ProcessingTimeService does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.table.operations.QueryOperation.accept(org.apache.flink.table.operations.QueryOperationVisitor): Argument leaf type org.apache.flink.table.operations.QueryOperationVisitor does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.types.parser.FieldParser.getErrorState(): Returned leaf type org.apache.flink.types.parser.FieldParser$ParseErrorState does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
org.apache.flink.types.parser.FieldParser.getErrorState(): Returned leaf type org.apache.flink.types.parser.FieldParser$ParseErrorState does not satisfy: reside outside of package 'org.apache.flink..' or reside in any package ['..shaded..'] or annotated with @Public or annotated with @PublicEvolving or annotated with @Deprecated
Loading

0 comments on commit ba6c0c7

Please sign in to comment.