mirror of
https://github.com/google/nomulus.git
synced 2025-05-03 21:47:51 +02:00
This means that, when writing new tests that are failing, you get much more useful logs that show the actual XML in a more comprehensible format that is suitable for pasting back into the golden file in the test (if the change was intended). This requires outputting the standalone parameter in the XML transformer, and some minor changes to some tests as a result that were relying on it being stripped out. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=204513690
85 lines
2.9 KiB
Java
85 lines
2.9 KiB
Java
// 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.tools;
|
|
|
|
import static google.registry.testing.DatastoreHelper.createTld;
|
|
import static google.registry.testing.DatastoreHelper.persistActiveDomain;
|
|
import static google.registry.testing.DatastoreHelper.persistResource;
|
|
import static google.registry.testing.FullFieldsTestEntityHelper.makeHistoryEntry;
|
|
|
|
import google.registry.model.domain.DomainResource;
|
|
import google.registry.model.domain.Period;
|
|
import google.registry.model.reporting.HistoryEntry;
|
|
import google.registry.testing.FakeClock;
|
|
import org.joda.time.DateTime;
|
|
import org.junit.Before;
|
|
import org.junit.Test;
|
|
|
|
/** Unit tests for {@link GetClaimsListCommand}. */
|
|
public class GetHistoryEntriesCommandTest extends CommandTestCase<GetHistoryEntriesCommand> {
|
|
|
|
private final FakeClock clock = new FakeClock(DateTime.parse("2000-01-01T00:00:00Z"));
|
|
|
|
private DomainResource domain;
|
|
|
|
@Before
|
|
public void setup() {
|
|
createTld("tld");
|
|
domain = persistActiveDomain("example.tld");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_works() throws Exception {
|
|
persistResource(
|
|
makeHistoryEntry(
|
|
domain,
|
|
HistoryEntry.Type.DOMAIN_CREATE,
|
|
Period.create(1, Period.Unit.YEARS),
|
|
"created",
|
|
clock.nowUtc()));
|
|
runCommand("--id=example.tld", "--type=DOMAIN");
|
|
assertStdoutIs(
|
|
"Client: foo\n"
|
|
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
|
+ "Client TRID: ABC-123\n"
|
|
+ "Server TRID: server-trid\n"
|
|
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
|
+ "<xml/>\n"
|
|
+ "\n");
|
|
}
|
|
|
|
@Test
|
|
public void testSuccess_noTrid() throws Exception {
|
|
persistResource(
|
|
makeHistoryEntry(
|
|
domain,
|
|
HistoryEntry.Type.DOMAIN_CREATE,
|
|
Period.create(1, Period.Unit.YEARS),
|
|
"created",
|
|
clock.nowUtc())
|
|
.asBuilder()
|
|
.setTrid(null)
|
|
.build());
|
|
runCommand("--id=example.tld", "--type=DOMAIN");
|
|
assertStdoutIs(
|
|
"Client: foo\n"
|
|
+ "Time: 2000-01-01T00:00:00.000Z\n"
|
|
+ "Client TRID: null\n"
|
|
+ "Server TRID: null\n"
|
|
+ "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
|
+ "<xml/>\n"
|
|
+ "\n");
|
|
}
|
|
}
|