From 6d90384051d333d80b8ef1bd4c3ab685e45bb8b0 Mon Sep 17 00:00:00 2001 From: Garrett Jones Date: Wed, 16 Mar 2016 16:25:15 -0700 Subject: [PATCH] Putting spi files under spi.v1 --- .../pubsub/spi/{ => v1}/PublisherApi.java | 2 +- .../pubsub/spi/v1}/PublisherSettings.java | 2 +- .../pubsub/spi/{ => v1}/SubscriberApi.java | 2 +- .../pubsub/spi/v1}/SubscriberSettings.java | 2 +- .../spi/testing/LocalPublisherImpl.java | 125 ------------------ .../pubsub/spi/{ => v1}/PublisherApi.java | 2 +- .../pubsub/spi/v1}/PublisherSettings.java | 2 +- .../pubsub/spi/{ => v1}/SubscriberApi.java | 2 +- .../pubsub/spi/v1}/SubscriberSettings.java | 2 +- .../pubsub/spi/{ => v1}/PublisherApiTest.java | 3 +- 10 files changed, 9 insertions(+), 135 deletions(-) rename gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApi.java (99%) rename gcloud-java-pubsub/{src/main/java/com/google/gcloud/pubsub/spi => baseline/src/main/java/com/google/gcloud/pubsub/spi/v1}/PublisherSettings.java (99%) rename gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/SubscriberApi.java (99%) rename gcloud-java-pubsub/{src/main/java/com/google/gcloud/pubsub/spi => baseline/src/main/java/com/google/gcloud/pubsub/spi/v1}/SubscriberSettings.java (99%) delete mode 100644 gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java rename gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApi.java (99%) rename gcloud-java-pubsub/{baseline/src/main/java/com/google/gcloud/pubsub/spi => src/main/java/com/google/gcloud/pubsub/spi/v1}/PublisherSettings.java (99%) rename gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/{ => v1}/SubscriberApi.java (99%) rename gcloud-java-pubsub/{baseline/src/main/java/com/google/gcloud/pubsub/spi => src/main/java/com/google/gcloud/pubsub/spi/v1}/SubscriberSettings.java (99%) rename gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/{ => v1}/PublisherApiTest.java (98%) diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 78ccc1f6e026..6ace2998698b 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 83ac11d19526..70b188735890 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 191c0006f12b..16e1435b8582 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java rename to gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 12242dc47005..2680d8429938 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java deleted file mode 100644 index 13aeb26cafe0..000000000000 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/testing/LocalPublisherImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2015 Google Inc. 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.gcloud.pubsub.spi.testing; - -import com.google.gcloud.pubsub.spi.PublisherApi; -import com.google.protobuf.Empty; -import com.google.pubsub.v1.DeleteTopicRequest; -import com.google.pubsub.v1.GetTopicRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsRequest; -import com.google.pubsub.v1.ListTopicSubscriptionsResponse; -import com.google.pubsub.v1.ListTopicsRequest; -import com.google.pubsub.v1.ListTopicsResponse; -import com.google.pubsub.v1.PublishRequest; -import com.google.pubsub.v1.PublishResponse; -import com.google.pubsub.v1.PublisherGrpc.Publisher; -import com.google.pubsub.v1.PubsubMessage; -import com.google.pubsub.v1.Topic; - -import io.grpc.stub.StreamObserver; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class LocalPublisherImpl implements Publisher { - - private Map> topics = new HashMap<>(); - - @Override - public void createTopic(Topic request, StreamObserver responseObserver) { - topics.put(request.getName(), new ArrayList()); - - Topic response = Topic.newBuilder().setName(request.getName()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void publish(PublishRequest request, StreamObserver responseObserver) { - List topicMessages = topics.get(request.getTopic()); - List ids = new ArrayList<>(); - int index = 0; - for (PubsubMessage msg : request.getMessagesList()) { - topicMessages.add(msg); - ids.add(new Integer(index).toString()); - } - responseObserver.onNext(PublishResponse.newBuilder().addAllMessageIds(ids).build()); - responseObserver.onCompleted(); - } - - @Override - public void getTopic(GetTopicRequest request, StreamObserver responseObserver) { - if (topics.get(request.getTopic()) == null) { - throw new IllegalArgumentException("topic doesn't exist: " + request.getTopic()); - } - Topic response = Topic.newBuilder().setName(request.getTopic()).build(); - responseObserver.onNext(response); - responseObserver.onCompleted(); - } - - @Override - public void listTopics( - ListTopicsRequest request, StreamObserver responseObserver) { - List responseTopics = new ArrayList<>(); - for (String topicName : topics.keySet()) { - String projectOfTopic = PublisherApi.ResourceNames.parseProjectFromTopicPath(topicName); - String projectOfRequest = PublisherApi.ResourceNames.parseProjectFromProjectPath(request.getProject()); - if (projectOfTopic.equals(projectOfRequest)) { - Topic topicObj = Topic.newBuilder().setName(topicName).build(); - responseTopics.add(topicObj); - } - } - Collections.sort( - responseTopics, - new Comparator() { - @Override - public int compare(Topic o1, Topic o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - ListTopicsResponse.Builder response = ListTopicsResponse.newBuilder(); - response.setNextPageToken(""); - response.addAllTopics(responseTopics); - responseObserver.onNext(response.build()); - responseObserver.onCompleted(); - } - - @Override - public void listTopicSubscriptions( - ListTopicSubscriptionsRequest request, - StreamObserver responseObserver) { - responseObserver.onNext(ListTopicSubscriptionsResponse.getDefaultInstance()); - responseObserver.onCompleted(); - } - - @Override - public void deleteTopic(DeleteTopicRequest request, StreamObserver responseObserver) { - topics.remove(request.getTopic()); - responseObserver.onNext(Empty.getDefaultInstance()); - responseObserver.onCompleted(); - } - - public Map> getTopics() { - return topics; - } - - public void reset() { - topics = new HashMap<>(); - } -} diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java index 78ccc1f6e026..6ace2998698b 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/PublisherApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java index 83ac11d19526..70b188735890 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/PublisherSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/PublisherSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java similarity index 99% rename from gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java index 191c0006f12b..16e1435b8582 100644 --- a/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/SubscriberApi.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberApi.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.grpc.ApiCallSettings; import com.google.api.gax.grpc.ApiCallable; diff --git a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java similarity index 99% rename from gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java rename to gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java index 12242dc47005..2680d8429938 100644 --- a/gcloud-java-pubsub/baseline/src/main/java/com/google/gcloud/pubsub/spi/SubscriberSettings.java +++ b/gcloud-java-pubsub/src/main/java/com/google/gcloud/pubsub/spi/v1/SubscriberSettings.java @@ -31,7 +31,7 @@ * Happy editing! */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.ConnectionSettings; diff --git a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java similarity index 98% rename from gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java rename to gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java index 4330c590a182..aaf292ff917d 100644 --- a/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/PublisherApiTest.java +++ b/gcloud-java-pubsub/src/test/java/com/google/gcloud/pubsub/spi/v1/PublisherApiTest.java @@ -12,11 +12,10 @@ * the License. */ -package com.google.gcloud.pubsub.spi; +package com.google.gcloud.pubsub.spi.v1; import com.google.api.gax.core.BackoffParams; import com.google.api.gax.core.RetryParams; -import com.google.api.gax.grpc.ApiCallSettings; import com.google.gcloud.pubsub.testing.LocalPubsubHelper; import com.google.protobuf.ByteString; import com.google.pubsub.v1.PubsubMessage;