Rename Java packages to use the .google TLD

The dark lord Gosling designed the Java package naming system so that
ownership flows from the DNS system. Since we own the domain name
registry.google, it seems only appropriate that we should use
google.registry as our package name.
This commit is contained in:
Michael Muller 2016-04-26 11:05:00 -04:00 committed by Justine Tunney
parent 5012893c1d
commit c458c05801
1309 changed files with 10981 additions and 10378 deletions

View file

@ -12,46 +12,92 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.domain.registry.tools.server;
package google.registry.tools.server;
import static com.google.domain.registry.model.EntityClasses.CLASS_TO_KIND_FUNCTION;
import static com.google.common.base.Predicates.instanceOf;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.model.ofy.ObjectifyService.ofy;
import static google.registry.testing.DatastoreHelper.createTld;
import static google.registry.testing.DatastoreHelper.newContactResource;
import static google.registry.testing.DatastoreHelper.persistResource;
import static google.registry.testing.DatastoreHelper.persistResourceWithCommitLog;
import static google.registry.util.DateTimeUtils.START_OF_TIME;
import static java.util.Arrays.asList;
import com.google.appengine.api.datastore.Entity;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.domain.registry.mapreduce.MapreduceAction;
import com.google.domain.registry.mapreduce.MapreduceRunner;
import com.google.domain.registry.model.ofy.CommitLogBucket;
import com.google.domain.registry.model.ofy.CommitLogCheckpoint;
import com.google.domain.registry.model.ofy.CommitLogCheckpointRoot;
import com.google.domain.registry.model.ofy.CommitLogManifest;
import com.google.domain.registry.model.ofy.CommitLogMutation;
import com.google.domain.registry.testing.FakeResponse;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import google.registry.mapreduce.MapreduceRunner;
import google.registry.model.ImmutableObject;
import google.registry.model.ofy.CommitLogBucket;
import google.registry.model.ofy.CommitLogCheckpoint;
import google.registry.model.ofy.CommitLogCheckpointRoot;
import google.registry.model.ofy.CommitLogManifest;
import google.registry.model.ofy.CommitLogMutation;
import google.registry.testing.FakeResponse;
import google.registry.testing.mapreduce.MapreduceTestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.util.List;
/** Tests for {@link KillAllCommitLogsAction}.*/
@RunWith(JUnit4.class)
public class KillAllCommitLogsActionTest extends KillAllActionTestCase<KillAllCommitLogsAction> {
public class KillAllCommitLogsActionTest extends MapreduceTestCase<KillAllCommitLogsAction> {
public KillAllCommitLogsActionTest() {
super(FluentIterable
.from(asList(
CommitLogBucket.class,
CommitLogCheckpoint.class,
CommitLogCheckpointRoot.class,
CommitLogMutation.class,
CommitLogManifest.class))
.transform(CLASS_TO_KIND_FUNCTION)
.toSet());
}
static final List<Class<? extends ImmutableObject>> AFFECTED_TYPES = ImmutableList.of(
CommitLogBucket.class,
CommitLogCheckpoint.class,
CommitLogCheckpointRoot.class,
CommitLogMutation.class,
CommitLogManifest.class);
@Override
MapreduceAction createAction() {
private void runMapreduce() throws Exception {
action = new KillAllCommitLogsAction();
action.mrRunner = new MapreduceRunner(Optional.<Integer>absent(), Optional.<Integer>absent());
action.response = new FakeResponse();
return action;
action.run();
executeTasksUntilEmpty("mapreduce");
}
@Test
public void testKill() throws Exception {
int nextContactId = 5432;
for (String tld : asList("tld1", "tld2")) {
createTld(tld);
persistResourceWithCommitLog(
newContactResource(String.format("abc%d", nextContactId++)));
}
persistResource(CommitLogCheckpointRoot.create(START_OF_TIME.plusDays(1)));
persistResource(
CommitLogCheckpoint.create(
START_OF_TIME.plusDays(1),
ImmutableMap.of(1, START_OF_TIME.plusDays(2))));
for (Class<?> clazz : AFFECTED_TYPES) {
assertThat(ofy().load().type(clazz)).named("entities of type " + clazz).isNotEmpty();
}
ImmutableList<?> otherStuff = FluentIterable.from(ofy().load())
.filter(new Predicate<Object>() {
@Override
public boolean apply(Object obj) {
return !AFFECTED_TYPES.contains(obj.getClass());
}})
.toList();
assertThat(otherStuff).isNotEmpty();
runMapreduce();
for (Class<?> clazz : AFFECTED_TYPES) {
assertThat(ofy().load().type(clazz)).named("entities of type " + clazz).isEmpty();
}
// Filter out raw Entity objects created by the mapreduce.
assertThat(filter(ofy().load(), not(instanceOf(Entity.class))))
.containsExactlyElementsIn(otherStuff);
}
}