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:
Justine Tunney 2016-05-13 18:55:08 -04:00
parent a41677aea1
commit 5012893c1d
2396 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,128 @@
// 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.index;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.index.DomainApplicationIndex.createUpdatedInstance;
import static com.google.domain.registry.model.index.DomainApplicationIndex.createWithSpecifiedReferences;
import static com.google.domain.registry.model.index.DomainApplicationIndex.loadActiveApplicationsByDomainName;
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.persistResource;
import static com.google.domain.registry.testing.DatastoreHelper.persistSimpleGlobalResource;
import com.google.common.collect.ImmutableSet;
import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.domain.DomainApplication;
import com.google.domain.registry.testing.ExceptionRule;
import com.googlecode.objectify.Ref;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
/** Unit tests for {@link DomainApplicationIndex}. */
public class DomainApplicationIndexTest extends EntityTestCase {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Before
public void init() throws Exception {
createTld("com");
}
@Test
public void testFailure_create_nullReferences() {
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
DomainApplicationIndex.createWithSpecifiedReferences("blah.com", null);
}
@Test
public void testFailure_create_emptyReferences() {
thrown.expect(IllegalArgumentException.class, "References must not be null or empty.");
createWithSpecifiedReferences("blah.com", ImmutableSet.<Ref<DomainApplication>>of());
}
@Test
public void testSuccess_singleApplication() {
DomainApplication application =
persistSimpleGlobalResource(newDomainApplication("example.com"));
persistResource(createUpdatedInstance(application));
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
assertThat(savedIndex).isNotNull();
assertThat(savedIndex.getReferences()).containsExactly(Ref.create(application));
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
.containsExactly(application);
}
@Test
public void testSuccess_noApplications() {
assertThat(DomainApplicationIndex.load("example.com")).isNull();
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now())).isEmpty();
}
@Test
public void testSuccess_multipleApplications() {
DomainApplication application1 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
DomainApplication application2 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
DomainApplication application3 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
persistResource(createUpdatedInstance(application1));
persistResource(createUpdatedInstance(application2));
persistResource(createUpdatedInstance(application3));
DomainApplicationIndex savedIndex = DomainApplicationIndex.load("example.com");
assertThat(savedIndex).isNotNull();
assertThat(savedIndex.getReferences()).containsExactly(
Ref.create(application1), Ref.create(application2), Ref.create(application3));
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
.containsExactly(application1, application2, application3);
}
@Test
public void testSuccess_doesntStoreSameApplicationMultipleTimes() {
DomainApplication application1 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
DomainApplication application2 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
persistResource(createUpdatedInstance(application1));
persistResource(createUpdatedInstance(application2));
persistResource(createUpdatedInstance(application1));
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
.containsExactly(application1, application2);
}
@Test
public void testSuccess_doesntIncludePastApplications() {
DomainApplication application1 =
persistSimpleGlobalResource(newDomainApplication("example.com"));
DomainApplication application2 = persistSimpleGlobalResource(
newDomainApplication("example.com")
.asBuilder()
.setDeletionTime(DateTime.now().minusDays(30))
.build());
persistResource(createUpdatedInstance(application1));
persistResource(createUpdatedInstance(application2));
DomainApplicationIndex savedIndex =
DomainApplicationIndex.load(application1.getFullyQualifiedDomainName());
assertThat(savedIndex.getReferences()).hasSize(2);
assertThat(loadActiveApplicationsByDomainName("example.com", DateTime.now()))
.containsExactly(application1);
}
}

View file

@ -0,0 +1,77 @@
// 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.index;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.model.ofy.ObjectifyService.ofy;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveContact;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
import com.google.domain.registry.config.RegistryEnvironment;
import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.contact.ContactResource;
import com.googlecode.objectify.Key;
import org.junit.Before;
import org.junit.Test;
/** Unit tests for {@link EppResourceIndex}. */
public class EppResourceIndexTest extends EntityTestCase {
ContactResource contact;
@Before
public void setUp() throws Exception {
createTld("tld");
// The DatastoreHelper here creates the EppResourceIndex for us.
contact = persistActiveContact("abcd1357");
}
@Test
public void testPersistence() throws Exception {
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
assertThat(loadedIndex.reference.get()).isEqualTo(contact);
}
@Test
public void testIndexing() throws Exception {
verifyIndexing(Iterables.getOnlyElement(getEppResourceIndexObjects()), "kind");
}
@Test
public void testIdempotentOnUpdate() throws Exception {
contact = persistResource(contact.asBuilder().setEmailAddress("abc@def.fake").build());
EppResourceIndex loadedIndex = Iterables.getOnlyElement(getEppResourceIndexObjects());
assertThat(loadedIndex.reference.get()).isEqualTo(contact);
}
/**
* Returns all EppResourceIndex objects across all buckets.
*/
private ImmutableList<EppResourceIndex> getEppResourceIndexObjects() {
int numBuckets = RegistryEnvironment.get().config().getEppResourceIndexBucketCount();
ImmutableList.Builder<EppResourceIndex> indexEntities = ImmutableList.builder();
for (int i = 0; i < numBuckets; i++) {
indexEntities.addAll(ofy().load()
.type(EppResourceIndex.class)
.ancestor(Key.create(EppResourceIndexBucket.class, i + 1)));
}
return indexEntities.build();
}
}

View file

@ -0,0 +1,110 @@
// 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.index;
import static com.google.common.truth.Truth.assertThat;
import static com.google.domain.registry.testing.DatastoreHelper.createTld;
import static com.google.domain.registry.testing.DatastoreHelper.persistActiveHost;
import static com.google.domain.registry.testing.DatastoreHelper.persistResource;
import static com.google.domain.registry.util.DateTimeUtils.END_OF_TIME;
import com.google.common.collect.ImmutableList;
import com.google.domain.registry.model.EntityTestCase;
import com.google.domain.registry.model.host.HostResource;
import com.google.domain.registry.model.index.ForeignKeyIndex.ForeignKeyHostIndex;
import com.google.domain.registry.testing.ExceptionRule;
import com.googlecode.objectify.Ref;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
/** Unit tests for {@link ForeignKeyIndex}. */
public class ForeignKeyIndexTest extends EntityTestCase {
@Rule
public final ExceptionRule thrown = new ExceptionRule();
@Before
public void setUp() throws Exception {
createTld("com");
}
@Test
public void testPersistence() throws Exception {
// Persist a host and implicitly persist a ForeignKeyIndex for it.
HostResource host = persistActiveHost("ns1.example.com");
ForeignKeyIndex<HostResource> fki =
ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc());
assertThat(fki.getReference().get()).isEqualTo(host);
assertThat(fki.getDeletionTime()).isEqualTo(END_OF_TIME);
}
@Test
public void testIndexing() throws Exception {
// Persist a host and implicitly persist a ForeignKeyIndex for it.
persistActiveHost("ns1.example.com");
verifyIndexing(
ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc()),
"deletionTime");
}
@Test
public void testLoadForNonexistentForeignKey_returnsNull() {
assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc()))
.isNull();
}
@Test
public void testLoadForDeletedForeignKey_returnsNull() {
HostResource host = persistActiveHost("ns1.example.com");
persistResource(ForeignKeyIndex.create(host, clock.nowUtc().minusDays(1)));
assertThat(ForeignKeyIndex.load(HostResource.class, "ns1.example.com", clock.nowUtc()))
.isNull();
}
@Test
public void testLoad_newerKeyHasBeenSoftDeleted() throws Exception {
HostResource host1 = persistActiveHost("ns1.example.com");
clock.advanceOneMilli();
ForeignKeyHostIndex fki = new ForeignKeyHostIndex();
fki.foreignKey = "ns1.example.com";
fki.topReference = Ref.create(host1);
fki.deletionTime = clock.nowUtc();
persistResource(fki);
assertThat(ForeignKeyIndex.load(
HostResource.class, "ns1.example.com", clock.nowUtc())).isNull();
}
@Test
public void testBatchLoad_skipsDeletedAndNonexistent() {
persistActiveHost("ns1.example.com");
HostResource host = persistActiveHost("ns2.example.com");
persistResource(ForeignKeyIndex.create(host, clock.nowUtc().minusDays(1)));
assertThat(ForeignKeyIndex.load(
HostResource.class,
ImmutableList.of("ns1.example.com", "ns2.example.com", "ns3.example.com"),
clock.nowUtc()).keySet())
.containsExactly("ns1.example.com");
}
@Test
public void testDeadCodeThatDeletedScrapCommandsReference() throws Exception {
persistActiveHost("omg");
assertThat(ForeignKeyIndex.load(HostResource.class, "omg", clock.nowUtc()).getForeignKey())
.isEqualTo("omg");
}
}