Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add test coverage for cloudpubsub folder. (#218)
* fix: Add a test for SinglePartitionPublisherBuilder. * fix: Add a test for Versions. * fix: Add a test for ChannelCache. * fix: Improve ConnectedSubscriberImpl coverage. * fix: Add a test for RoutingPublisher. * fix: Add a test for PublisherBuilder. * fix: Add test coverage for remaining builders. * fix: Add licence headers. * fix: Add test coverage for cloudpubsub folder. * fix: Add test coverage for cloudpubsub folder. * fix: Make PublisherSettingsTest actually instantiate a Publisher. * fix: Add license headers. * fix: Add AckSetTrackerImplTest * fix: Update clirr to add change 7006 and put two stars after blanket ignored folders.
- Loading branch information
1 parent
3a9909e
commit a70a60f
Showing
8 changed files
with
351 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...bsublite/src/test/java/com/google/cloud/pubsublite/cloudpubsub/PublisherSettingsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* 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.cloud.pubsublite.cloudpubsub; | ||
|
||
import static org.mockito.Mockito.RETURNS_SELF; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
import static org.mockito.MockitoAnnotations.initMocks; | ||
|
||
import com.google.cloud.pubsublite.CloudZone; | ||
import com.google.cloud.pubsublite.ProjectNumber; | ||
import com.google.cloud.pubsublite.PublishMetadata; | ||
import com.google.cloud.pubsublite.TopicName; | ||
import com.google.cloud.pubsublite.TopicPath; | ||
import com.google.cloud.pubsublite.TopicPaths; | ||
import com.google.cloud.pubsublite.internal.FakeApiService; | ||
import com.google.cloud.pubsublite.internal.Publisher; | ||
import com.google.cloud.pubsublite.internal.wire.SinglePartitionPublisherBuilder; | ||
import com.google.cloud.pubsublite.proto.PublisherServiceGrpc; | ||
import io.grpc.Channel; | ||
import io.grpc.StatusException; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
import org.mockito.Spy; | ||
|
||
@RunWith(JUnit4.class) | ||
public class PublisherSettingsTest { | ||
TopicPath getPath() throws StatusException { | ||
return TopicPaths.newBuilder() | ||
.setProjectNumber(ProjectNumber.of(56)) | ||
.setZone(CloudZone.parse("us-central1-a")) | ||
.setTopicName(TopicName.of("xyz")) | ||
.build(); | ||
} | ||
|
||
abstract static class FakePublisher extends FakeApiService | ||
implements Publisher<PublishMetadata> {} | ||
|
||
@Spy private FakePublisher underlying; | ||
|
||
@Test | ||
public void testSettings() throws StatusException { | ||
initMocks(this); | ||
Channel mockChannel = mock(Channel.class); | ||
SinglePartitionPublisherBuilder.Builder mockBuilder = | ||
mock(SinglePartitionPublisherBuilder.Builder.class, RETURNS_SELF); | ||
when(mockBuilder.build()).thenReturn(underlying); | ||
PublisherSettings.newBuilder() | ||
.setTopicPath(getPath()) | ||
.setStub(PublisherServiceGrpc.newStub(mockChannel)) | ||
.setUnderlyingBuilder(mockBuilder) | ||
.setNumPartitions(77) | ||
.build() | ||
.instantiate(); | ||
} | ||
} |
Oops, something went wrong.