mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 02:06:00 +02:00
mv com/google/domain/registry google/registry
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.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
178
javatests/google/registry/model/contact/ContactCommandTest.java
Normal file
178
javatests/google/registry/model/contact/ContactCommandTest.java
Normal file
|
@ -0,0 +1,178 @@
|
|||
// 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.model.contact;
|
||||
|
||||
import static com.google.domain.registry.flows.EppXmlTransformer.marshalInput;
|
||||
import static com.google.domain.registry.flows.EppXmlTransformer.validateInput;
|
||||
import static com.google.domain.registry.testing.ContactResourceSubject.assertAboutContacts;
|
||||
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
|
||||
import static com.google.domain.registry.xml.ValidationMode.LENIENT;
|
||||
import static com.google.domain.registry.xml.XmlTestUtils.assertXmlEquals;
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.domain.registry.model.contact.PostalInfo.Type;
|
||||
import com.google.domain.registry.testing.AppEngineRule;
|
||||
import com.google.domain.registry.testing.EppLoader;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Test xml roundtripping of commands. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class ContactCommandTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore()
|
||||
.build();
|
||||
|
||||
private void doXmlRoundtripTest(String inputFilename) throws Exception {
|
||||
EppLoader eppLoader = new EppLoader(this, inputFilename);
|
||||
// JAXB can unmarshal a "name" or an "id" into the "targetId" field, but when marshaling it
|
||||
// chooses "name" always since it is last on the list of @XmlElement choices on that field. This
|
||||
// is fine because we never marshal an input command... except for this test which verifies
|
||||
// roundtripping, so we hack the output here. Since the marshal step won't validate, we use
|
||||
// the non-validating lenient marshal, do the change, and then do the validate afterwards.
|
||||
String marshaled = new String(marshalInput(eppLoader.getEpp(), LENIENT), UTF_8).replaceAll(
|
||||
"<contact:name>(sh8013|sah8013|8013sah)</contact:name>",
|
||||
"<contact:id>$1</contact:id>");
|
||||
validateInput(marshaled);
|
||||
assertXmlEquals(eppLoader.getEppXml(), marshaled);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate() throws Exception {
|
||||
doXmlRoundtripTest("contact_create.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDelete() throws Exception {
|
||||
doXmlRoundtripTest("contact_delete.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdate() throws Exception {
|
||||
doXmlRoundtripTest("contact_update.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInfo() throws Exception {
|
||||
doXmlRoundtripTest("contact_info.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheck() throws Exception {
|
||||
doXmlRoundtripTest("contact_check.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferApprove() throws Exception {
|
||||
doXmlRoundtripTest("contact_transfer_approve.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferReject() throws Exception {
|
||||
doXmlRoundtripTest("contact_transfer_reject.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferCancel() throws Exception {
|
||||
doXmlRoundtripTest("contact_transfer_cancel.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferQuery() throws Exception {
|
||||
doXmlRoundtripTest("contact_transfer_query.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferRequest() throws Exception {
|
||||
doXmlRoundtripTest("contact_transfer_request.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPostalInfoOverlay() {
|
||||
createTld("foo");
|
||||
|
||||
ContactResource contact = new ContactResource.Builder()
|
||||
.setLocalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.LOCALIZED)
|
||||
.setName("loc name")
|
||||
.build())
|
||||
.setInternationalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.INTERNATIONALIZED)
|
||||
.setName("int name")
|
||||
.build())
|
||||
.build();
|
||||
ContactCommand.Update.Change change = new ContactCommand.Update.Change();
|
||||
|
||||
// Updating one field of the loc should delete the int and leave the loc otherwise untouched.
|
||||
change.postalInfo = ImmutableList.of(new PostalInfo.Builder()
|
||||
.setType(Type.LOCALIZED)
|
||||
.setOrg("org")
|
||||
.build());
|
||||
ContactResource.Builder builder = contact.asBuilder();
|
||||
change.applyTo(builder);
|
||||
ContactResource changed = builder.build();
|
||||
assertAboutContacts().that(changed)
|
||||
.hasNullInternationalizedPostalInfo().and()
|
||||
.hasLocalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.LOCALIZED)
|
||||
.setName("loc name")
|
||||
.setOrg("org")
|
||||
.build());
|
||||
|
||||
// Updating one field of the int should delete the loc and leave the int otherwise untouched.
|
||||
change.postalInfo = ImmutableList.of(new PostalInfo.Builder()
|
||||
.setType(Type.INTERNATIONALIZED)
|
||||
.setOrg("org")
|
||||
.build());
|
||||
builder = contact.asBuilder();
|
||||
change.applyTo(builder);
|
||||
changed = builder.build();
|
||||
assertAboutContacts().that(changed)
|
||||
.hasNullLocalizedPostalInfo().and()
|
||||
.hasInternationalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.INTERNATIONALIZED)
|
||||
.setName("int name")
|
||||
.setOrg("org")
|
||||
.build());
|
||||
|
||||
// Updating one field of the int and touching the loc with no changes should preserve both.
|
||||
change.postalInfo = ImmutableList.of(
|
||||
new PostalInfo.Builder()
|
||||
.setType(Type.INTERNATIONALIZED)
|
||||
.setName("new int name")
|
||||
.build(),
|
||||
new PostalInfo.Builder()
|
||||
.setType(Type.LOCALIZED)
|
||||
.build());
|
||||
builder = contact.asBuilder();
|
||||
change.applyTo(builder);
|
||||
changed = builder.build();
|
||||
assertAboutContacts().that(changed)
|
||||
.hasLocalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.LOCALIZED)
|
||||
.setName("loc name")
|
||||
.build()).and()
|
||||
.hasInternationalizedPostalInfo(new PostalInfo.Builder()
|
||||
.setType(Type.INTERNATIONALIZED)
|
||||
.setName("new int name")
|
||||
.build());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue