mirror of
https://github.com/google/nomulus
synced 2026-09-04 15:17:13 +00:00
Replace FailureStrategy with FailureMetadata in gtld's Subjects
Also changed truth.SubjectFactory to truth.Subject.Factory (plain renaming) and use method reference instead of anonymous class to create the factory when applicable. FailureMetadata, an opaque object to its users, is introduced to replace FailureStrategy in in custom Subject in order to resolve some existing flaws of FailureStrategy as well as enable new features to be added to Truth. New API is available in Truth-0.36, if there is a build/pom.xml, it's also updated to use this version. More information: See [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=176110788
This commit is contained in:
@@ -17,30 +17,20 @@ package google.registry.testing;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.truth.Truth.assertAbout;
|
||||
|
||||
import com.google.common.truth.FailureStrategy;
|
||||
import com.google.common.truth.FailureMetadata;
|
||||
import com.google.common.truth.SimpleSubjectBuilder;
|
||||
import com.google.common.truth.SubjectFactory;
|
||||
import google.registry.model.EppResource;
|
||||
|
||||
/** Truth subject for asserting things about {@link EppResource} instances. */
|
||||
public final class GenericEppResourceSubject
|
||||
extends AbstractEppResourceSubject<EppResource, GenericEppResourceSubject> {
|
||||
|
||||
/** A factory for instances of this subject. */
|
||||
private static class GenericEppResourceSubjectFactory
|
||||
extends SubjectFactory<GenericEppResourceSubject, EppResource> {
|
||||
@Override
|
||||
public GenericEppResourceSubject getSubject(FailureStrategy strategy, EppResource subject) {
|
||||
return new GenericEppResourceSubject(strategy, subject);
|
||||
}
|
||||
}
|
||||
|
||||
public GenericEppResourceSubject(FailureStrategy strategy, EppResource subject) {
|
||||
super(strategy, checkNotNull(subject));
|
||||
public GenericEppResourceSubject(FailureMetadata failureMetadata, EppResource subject) {
|
||||
super(failureMetadata, checkNotNull(subject));
|
||||
}
|
||||
|
||||
public static SimpleSubjectBuilder<GenericEppResourceSubject, EppResource>
|
||||
assertAboutEppResources() {
|
||||
return assertAbout(new GenericEppResourceSubjectFactory());
|
||||
return assertAbout(GenericEppResourceSubject::new);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user