mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 07:13:34 +02: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:
parent
6083ef9ba0
commit
9ab68613a0
12 changed files with 44 additions and 127 deletions
|
@ -17,21 +17,19 @@ package google.registry.testing;
|
|||
import static com.google.common.truth.Truth.assertAbout;
|
||||
import static google.registry.util.PreconditionsUtils.checkArgumentNotNull;
|
||||
|
||||
import com.google.common.truth.FailureStrategy;
|
||||
import com.google.common.truth.FailureMetadata;
|
||||
import com.google.common.truth.Subject;
|
||||
import com.google.common.truth.SubjectFactory;
|
||||
import google.registry.model.eppoutput.Result.Code;
|
||||
import google.registry.monitoring.whitebox.EppMetric;
|
||||
import google.registry.testing.TruthChainer.And;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Utility methods for asserting things about {@link EppMetric} instances. */
|
||||
public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
||||
|
||||
public EppMetricSubject(FailureStrategy strategy, EppMetric subject) {
|
||||
super(strategy, subject);
|
||||
public EppMetricSubject(FailureMetadata failureMetadata, EppMetric subject) {
|
||||
super(failureMetadata, subject);
|
||||
}
|
||||
|
||||
public static EppMetricSubject assertThat(EppMetric subject) {
|
||||
|
@ -84,13 +82,7 @@ public class EppMetricSubject extends Subject<EppMetricSubject, EppMetric> {
|
|||
return new And<>(this);
|
||||
}
|
||||
|
||||
/** {@link SubjectFactory} for assertions about {@link EppMetric} objects. */
|
||||
private static final SubjectFactory<EppMetricSubject, EppMetric> SUBJECT_FACTORY =
|
||||
new SubjectFactory<EppMetricSubject, EppMetric>() {
|
||||
@Override
|
||||
public EppMetricSubject getSubject(
|
||||
FailureStrategy failureStrategy, @Nullable EppMetric target) {
|
||||
return new EppMetricSubject(failureStrategy, target);
|
||||
}
|
||||
};
|
||||
/** {@link Subject.Factory} for assertions about {@link EppMetric} objects. */
|
||||
private static final Subject.Factory<EppMetricSubject, EppMetric> SUBJECT_FACTORY =
|
||||
EppMetricSubject::new;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue