mirror of
https://github.com/google/nomulus.git
synced 2025-05-01 04:27:51 +02:00
This refactors the GetEppResourceCommand hierarchy a bit so that instead of using the type param on the class to do implicit loading (which doesn't work that well any more for domain applications anyway), we just do the loading in each child class and rely on the parent class only for printing and setting common flags. I did this to make it possible for loadByForeignKey() to have strong typing (in a future CL), but I think this changes stands on its own merits for making the logic here more straightforward and actually somewhat shorter. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=134115072
104 lines
3.7 KiB
Java
104 lines
3.7 KiB
Java
// Copyright 2016 The Domain Registry 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.tools;
|
|
|
|
import static google.registry.testing.DatastoreHelper.createTld;
|
|
import static google.registry.testing.DatastoreHelper.newDomainApplication;
|
|
import static google.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
|
import static google.registry.testing.DatastoreHelper.persistDeletedDomainApplication;
|
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
|
import static org.joda.time.DateTimeZone.UTC;
|
|
|
|
import com.beust.jcommander.ParameterException;
|
|
import org.joda.time.DateTime;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
/** Unit tests for {@link GetApplicationCommand}. */
|
|
public class GetApplicationCommandTest extends CommandTestCase<GetApplicationCommand> {
|
|
|
|
DateTime now = DateTime.now(UTC);
|
|
|
|
@Before
|
|
public void initialize() {
|
|
createTld("tld");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess() throws Exception {
|
|
persistActiveDomainApplication("example.tld");
|
|
runCommand("2-TLD");
|
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
|
assertInStdout("contactId=ReferenceUnion");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_expand() throws Exception {
|
|
persistActiveDomainApplication("example.tld");
|
|
runCommand("2-TLD", "--expand");
|
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
|
assertInStdout("contactId=contact1234");
|
|
assertNotInStdout("ReferenceUnion");
|
|
assertNotInStdout("LiveRef");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_multipleArguments() throws Exception {
|
|
persistActiveDomainApplication("example.tld");
|
|
persistActiveDomainApplication("example2.tld");
|
|
persistActiveDomainApplication("example3.tld");
|
|
runCommand("2-TLD", "4-TLD", "6-TLD");
|
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
|
assertInStdout("fullyQualifiedDomainName=example2.tld");
|
|
assertInStdout("fullyQualifiedDomainName=example3.tld");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_applicationDeletedInFuture() throws Exception {
|
|
persistResource(
|
|
newDomainApplication("example.tld").asBuilder().setDeletionTime(now.plusDays(1)).build());
|
|
runCommand("--read_timestamp=" + now.plusMonths(1), "2-TLD");
|
|
assertInStdout("Application '2-TLD' does not exist or is deleted");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_deletedApplication() throws Exception {
|
|
persistDeletedDomainApplication("example.tld", now);
|
|
runCommand("2-TLD");
|
|
assertInStdout("Application '2-TLD' does not exist or is deleted");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_applicationDoesNotExist() throws Exception {
|
|
runCommand("42-TLD");
|
|
assertInStdout("Application '42-TLD' does not exist or is deleted");
|
|
}
|
|
|
|
@Test
|
|
public void testFailure_noApplicationId() throws Exception {
|
|
thrown.expect(ParameterException.class);
|
|
runCommand();
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_oneApplicationDoesNotExist() throws Exception {
|
|
persistActiveDomainApplication("example.tld");
|
|
persistActiveDomainApplication("example2.tld");
|
|
runCommand("2-TLD", "4-TLD", "55-TLD");
|
|
assertInStdout("fullyQualifiedDomainName=example.tld");
|
|
assertInStdout("fullyQualifiedDomainName=example2.tld");
|
|
assertInStdout("Application '55-TLD' does not exist or is deleted");
|
|
}
|
|
}
|