From 6ce74ff61b36dc0f0fa5ea0fac740bbbc5be5f2a Mon Sep 17 00:00:00 2001 From: gbrodman Date: Thu, 16 May 2019 08:14:35 -0700 Subject: [PATCH] Delete the AbstractDomainBaseSubject It only had one subclass and it unnecessarily complicates things. It originally existed because DomainBase was abstract and could have multiple implementations but that is no longer the case. This will also help with [] ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=248529389 --- .../testing/AbstractDomainBaseSubject.java | 69 ------------------- .../registry/testing/DomainBaseSubject.java | 53 +++++++++++--- 2 files changed, 45 insertions(+), 77 deletions(-) delete mode 100644 javatests/google/registry/testing/AbstractDomainBaseSubject.java diff --git a/javatests/google/registry/testing/AbstractDomainBaseSubject.java b/javatests/google/registry/testing/AbstractDomainBaseSubject.java deleted file mode 100644 index b96abc56a..000000000 --- a/javatests/google/registry/testing/AbstractDomainBaseSubject.java +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2017 The Nomulus Authors. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package google.registry.testing; - -import com.google.common.collect.ImmutableSet; -import com.google.common.truth.FailureMetadata; -import google.registry.model.domain.DomainBase; -import google.registry.model.domain.launch.LaunchNotice; -import google.registry.model.domain.secdns.DelegationSignerData; -import google.registry.model.eppcommon.AuthInfo; -import google.registry.testing.TruthChainer.And; -import java.util.Set; - -/** Truth subject for asserting things about {@link DomainBase} instances. */ -public abstract class AbstractDomainBaseSubject - > - extends AbstractEppResourceSubject { - - private final T actual; - - public AbstractDomainBaseSubject(FailureMetadata failureMetadata, T subject) { - super(failureMetadata, subject); - this.actual = subject; - } - - public And hasFullyQualifiedDomainName(String fullyQualifiedDomainName) { - return hasValue( - fullyQualifiedDomainName, - actual.getFullyQualifiedDomainName(), - "has fullyQualifiedDomainName"); - } - - public And hasExactlyDsData(DelegationSignerData... dsData) { - return hasExactlyDsData(ImmutableSet.copyOf(dsData)); - } - - public And hasExactlyDsData(Set dsData) { - return hasValue(dsData, actual.getDsData(), "has dsData"); - } - - public And hasNumDsData(int num) { - return hasValue(num, actual.getDsData().size(), "has num dsData"); - } - - public And hasLaunchNotice(LaunchNotice launchNotice) { - return hasValue(launchNotice, actual.getLaunchNotice(), "has launchNotice"); - } - - public And hasAuthInfoPwd(String pw) { - AuthInfo authInfo = actual.getAuthInfo(); - return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw"); - } - - public And hasCurrentSponsorClientId(String clientId) { - return hasValue(clientId, actual.getCurrentSponsorClientId(), "has currentSponsorClientId"); - } -} diff --git a/javatests/google/registry/testing/DomainBaseSubject.java b/javatests/google/registry/testing/DomainBaseSubject.java index 65da1470c..a2c7ab21a 100644 --- a/javatests/google/registry/testing/DomainBaseSubject.java +++ b/javatests/google/registry/testing/DomainBaseSubject.java @@ -18,16 +18,60 @@ import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.truth.Fact.simpleFact; import static com.google.common.truth.Truth.assertAbout; +import com.google.common.collect.ImmutableSet; import com.google.common.truth.FailureMetadata; import com.google.common.truth.SimpleSubjectBuilder; import google.registry.model.domain.DomainBase; +import google.registry.model.domain.launch.LaunchNotice; +import google.registry.model.domain.secdns.DelegationSignerData; +import google.registry.model.eppcommon.AuthInfo; import google.registry.testing.TruthChainer.And; import java.util.Objects; +import java.util.Set; import org.joda.time.DateTime; /** Truth subject for asserting things about {@link DomainBase} instances. */ public final class DomainBaseSubject - extends AbstractDomainBaseSubject { + extends AbstractEppResourceSubject { + + private final DomainBase actual; + + public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) { + super(failureMetadata, checkNotNull(subject)); + this.actual = subject; + } + + public And hasFullyQualifiedDomainName(String fullyQualifiedDomainName) { + return hasValue( + fullyQualifiedDomainName, + actual.getFullyQualifiedDomainName(), + "has fullyQualifiedDomainName"); + } + + public And hasExactlyDsData(DelegationSignerData... dsData) { + return hasExactlyDsData(ImmutableSet.copyOf(dsData)); + } + + public And hasExactlyDsData(Set dsData) { + return hasValue(dsData, actual.getDsData(), "has dsData"); + } + + public And hasNumDsData(int num) { + return hasValue(num, actual.getDsData().size(), "has num dsData"); + } + + public And hasLaunchNotice(LaunchNotice launchNotice) { + return hasValue(launchNotice, actual.getLaunchNotice(), "has launchNotice"); + } + + public And hasAuthInfoPwd(String pw) { + AuthInfo authInfo = actual.getAuthInfo(); + return hasValue(pw, authInfo == null ? null : authInfo.getPw().getValue(), "has auth info pw"); + } + + public And hasCurrentSponsorClientId(String clientId) { + return hasValue(clientId, actual.getCurrentSponsorClientId(), "has currentSponsorClientId"); + } public And hasRegistrationExpirationTime(DateTime expiration) { if (!Objects.equals(actual.getRegistrationExpirationTime(), expiration)) { @@ -63,13 +107,6 @@ public final class DomainBaseSubject return hasValue(smdId, actual.getSmdId(), "has smdId"); } - private final DomainBase actual; - - public DomainBaseSubject(FailureMetadata failureMetadata, DomainBase subject) { - super(failureMetadata, checkNotNull(subject)); - this.actual = subject; - } - public static SimpleSubjectBuilder assertAboutDomains() { return assertAbout(DomainBaseSubject::new); }