use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method getMetricDescriptorTest.
@Test
@SuppressWarnings("all")
public void getMetricDescriptorTest() {
String name2 = "name2-1052831874";
String type = "type3575610";
String unit = "unit3594628";
String description = "description-1724546052";
String displayName = "displayName1615086568";
MetricDescriptor expectedResponse = MetricDescriptor.newBuilder().setName(name2).setType(type).setUnit(unit).setDescription(description).setDisplayName(displayName).build();
mockMetricService.addResponse(expectedResponse);
MetricDescriptorName name = MetricDescriptorName.create("[PROJECT]", "[METRIC_DESCRIPTOR]");
MetricDescriptor actualResponse = client.getMetricDescriptor(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetMetricDescriptorRequest actualRequest = (GetMetricDescriptorRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsMetricDescriptorName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method createSnapshotTest.
@Test
@SuppressWarnings("all")
public void createSnapshotTest() {
SnapshotName name2 = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
Snapshot expectedResponse = Snapshot.newBuilder().setNameWithSnapshotName(name2).setTopicWithTopicName(topic).build();
mockSubscriber.addResponse(expectedResponse);
SnapshotName name = SnapshotName.create("[PROJECT]", "[SNAPSHOT]");
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
Snapshot actualResponse = client.createSnapshot(name, subscription);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSnapshotRequest actualRequest = (CreateSnapshotRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsSnapshotName());
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
@SuppressWarnings("all")
public void listSnapshotsTest() {
String nextPageToken = "";
Snapshot snapshotsElement = Snapshot.newBuilder().build();
List<Snapshot> snapshots = Arrays.asList(snapshotsElement);
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSnapshots(snapshots).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = (ListSnapshotsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method modifyPushConfigTest.
@Test
@SuppressWarnings("all")
public void modifyPushConfigTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
PushConfig pushConfig = PushConfig.newBuilder().build();
client.modifyPushConfig(subscription, pushConfig);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ModifyPushConfigRequest actualRequest = (ModifyPushConfigRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
Assert.assertEquals(pushConfig, actualRequest.getPushConfig());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method listTopicsTest.
@Test
@SuppressWarnings("all")
public void listTopicsTest() {
String nextPageToken = "";
Topic topicsElement = Topic.newBuilder().build();
List<Topic> topics = Arrays.asList(topicsElement);
ListTopicsResponse expectedResponse = ListTopicsResponse.newBuilder().setNextPageToken(nextPageToken).addAllTopics(topics).build();
mockPublisher.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListTopicsPagedResponse pagedListResponse = client.listTopics(project);
List<Topic> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTopicsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockPublisher.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTopicsRequest actualRequest = (ListTopicsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
Aggregations