diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthDelegatedVerb.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java similarity index 70% rename from extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthDelegatedVerb.java rename to extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java index 7dc990052..4b1bee8f0 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruthDelegatedVerb.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoSubjectBuilder.java @@ -16,13 +16,11 @@ package com.google.common.truth.extensions.proto; -import static com.google.common.base.Preconditions.checkNotNull; - import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; -import com.google.common.truth.AbstractDelegatedVerb; -import com.google.common.truth.DelegatedVerbFactory; +import com.google.common.truth.CustomSubjectBuilder; +import com.google.common.truth.CustomSubjectBuilderFactory; import com.google.common.truth.FailureStrategy; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; @@ -30,68 +28,66 @@ import javax.annotation.Nullable; /** - * Custom {@link AbstractDelegatedVerb} which aggregates all Proto-related {@link + * {@link CustomSubjectBuilder} which aggregates all Proto-related {@link * com.google.common.truth.Subject} classes into a single place. * *

To obtain an instance, call {@code assertAbout(ProtoTruth.protos())}. */ -public final class ProtoTruthDelegatedVerb extends AbstractDelegatedVerb { +public final class ProtoSubjectBuilder extends CustomSubjectBuilder { - /** Factory for ProtoTruthDelegatedVerb. */ - private static class Factory implements DelegatedVerbFactory { + /** Factory for ProtoSubjectBuilder. */ + private static class Factory implements CustomSubjectBuilderFactory { private static final Factory INSTANCE = new Factory(); @Override - public ProtoTruthDelegatedVerb createVerb(FailureStrategy failureStrategy) { - return new ProtoTruthDelegatedVerb(failureStrategy); + public ProtoSubjectBuilder createSubjectBuilder(FailureStrategy failureStrategy) { + return new ProtoSubjectBuilder(failureStrategy); } } - static DelegatedVerbFactory factory() { + static CustomSubjectBuilderFactory factory() { return Factory.INSTANCE; } - private final FailureStrategy failureStrategy; - - private ProtoTruthDelegatedVerb(FailureStrategy failureStrategy) { - this.failureStrategy = checkNotNull(failureStrategy); + private ProtoSubjectBuilder(FailureStrategy failureStrategy) { + super(failureStrategy); } public LiteProtoSubject that(@Nullable MessageLite messageLite) { - return new LiteProtoSubject.MessageLiteSubject(failureStrategy, messageLite); + return new LiteProtoSubject.MessageLiteSubject(failureStrategy(), messageLite); } public ProtoSubject that(@Nullable Message message) { - return new ProtoSubject.MessageSubject(failureStrategy, message); + return new ProtoSubject.MessageSubject(failureStrategy(), message); } public IterableOfProtosSubject> that( @Nullable Iterable messages) { - return new IterableOfProtosSubject.IterableOfMessagesSubject(failureStrategy, messages); + return new IterableOfProtosSubject.IterableOfMessagesSubject(failureStrategy(), messages); } public MapWithProtoValuesSubject> that( @Nullable Map map) { - return new MapWithProtoValuesSubject.MapWithMessageValuesSubject(failureStrategy, map); + return new MapWithProtoValuesSubject.MapWithMessageValuesSubject(failureStrategy(), map); } public MultimapWithProtoValuesSubject> that( @Nullable Multimap map) { return new MultimapWithProtoValuesSubject.MultimapWithMessageValuesSubject( - failureStrategy, map); + failureStrategy(), map); } public ListMultimapWithProtoValuesSubject> that( @Nullable ListMultimap map) { return new ListMultimapWithProtoValuesSubject.ListMultimapWithMessageValuesSubject( - failureStrategy, map); + failureStrategy(), map); } public SetMultimapWithProtoValuesSubject> that( @Nullable SetMultimap map) { return new SetMultimapWithProtoValuesSubject.SetMultimapWithMessageValuesSubject( - failureStrategy, map); + failureStrategy(), map); } } diff --git a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java index 75323b4f4..9afc5beaa 100644 --- a/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java +++ b/extensions/proto/src/main/java/com/google/common/truth/extensions/proto/ProtoTruth.java @@ -21,12 +21,10 @@ import com.google.common.collect.ListMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.SetMultimap; -import com.google.common.truth.AbstractVerb; -import com.google.common.truth.DelegatedVerbFactory; +import com.google.common.truth.CustomSubjectBuilderFactory; import com.google.common.truth.IterableSubject; import com.google.common.truth.MapSubject; import com.google.common.truth.MultimapSubject; -import com.google.common.truth.SubjectFactory; import com.google.protobuf.Message; import com.google.protobuf.MessageLite; import java.util.Map; @@ -36,18 +34,18 @@ * A set of static methods to begin a Truth assertion chain for protocol buffers. * *

Note: Usage of different failure strategies such as assume and expect should - * rely on {@link AbstractVerb#about(SubjectFactory)} to begin a chain with those alternative - * behaviors. + * rely on {@link CustomSubjectBuilderFactory#about(CustomSubjectBuilderFactory)} to begin a chain + * with those alternative behaviors. */ public final class ProtoTruth { /** - * Returns a {@link DelegatedVerbFactory}, akin to a {@link + * Returns a {@link CustomSubjectBuilderFactory}, akin to a {@link * com.google.common.truth.SubjectFactory}, which can be used to assert on multiple types of * Protos and collections containing them. */ - public static DelegatedVerbFactory protos() { - return ProtoTruthDelegatedVerb.factory(); + public static CustomSubjectBuilderFactory protos() { + return ProtoSubjectBuilder.factory(); } /** Assert on a single {@link MessageLite} instance. */