mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
105 lines
3.8 KiB
Java
105 lines
3.8 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 com.google.domain.registry.tools;
|
|
|
|
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.newDomainApplication;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveDomainApplication;
|
|
import static com.google.domain.registry.testing.DatastoreHelper.persistDeletedDomainApplication;
|
|
import static com.google.domain.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("DomainApplication '2-TLD' does not exist or is deleted");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_deletedApplication() throws Exception {
|
|
persistDeletedDomainApplication("example.tld", now);
|
|
runCommand("2-TLD");
|
|
assertInStdout("DomainApplication '2-TLD' does not exist or is deleted");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_applicationDoesNotExist() throws Exception {
|
|
runCommand("42-TLD");
|
|
assertInStdout("DomainApplication '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("DomainApplication '55-TLD' does not exist or is deleted");
|
|
}
|
|
}
|