use of com.google.protobuf.GeneratedMessageV3 in project core-java by SpineEventEngine.
the class FailureThrowableShould method convert_to_failure_message.
@Test
public void convert_to_failure_message() {
final StringValue failure = Wrapper.forString(newUuid());
final Failure failureWrapper = new TestFailure(Tests.<GeneratedMessageV3>nullRef(), Tests.<CommandContext>nullRef(), failure).toFailure(command);
assertEquals(failure, AnyPacker.unpack(failureWrapper.getMessage()));
assertFalse(failureWrapper.getContext().getStacktrace().isEmpty());
assertTrue(Timestamps.isValid(failureWrapper.getContext().getTimestamp()));
final Command wrappedCommand = failureWrapper.getContext().getCommand();
assertEquals(command, wrappedCommand);
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listMetricDescriptorsTest.
@Test
@SuppressWarnings("all")
public void listMetricDescriptorsTest() {
String nextPageToken = "";
MetricDescriptor metricDescriptorsElement = MetricDescriptor.newBuilder().build();
List<MetricDescriptor> metricDescriptors = Arrays.asList(metricDescriptorsElement);
ListMetricDescriptorsResponse expectedResponse = ListMetricDescriptorsResponse.newBuilder().setNextPageToken(nextPageToken).addAllMetricDescriptors(metricDescriptors).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
ListMetricDescriptorsPagedResponse pagedListResponse = client.listMetricDescriptors(name);
List<MetricDescriptor> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getMetricDescriptorsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListMetricDescriptorsRequest actualRequest = (ListMetricDescriptorsRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listMonitoredResourceDescriptorsTest.
@Test
@SuppressWarnings("all")
public void listMonitoredResourceDescriptorsTest() {
String nextPageToken = "";
MonitoredResourceDescriptor resourceDescriptorsElement = MonitoredResourceDescriptor.newBuilder().build();
List<MonitoredResourceDescriptor> resourceDescriptors = Arrays.asList(resourceDescriptorsElement);
ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder().setNextPageToken(nextPageToken).addAllResourceDescriptors(resourceDescriptors).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
ListMonitoredResourceDescriptorsPagedResponse pagedListResponse = client.listMonitoredResourceDescriptors(name);
List<MonitoredResourceDescriptor> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getResourceDescriptorsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListMonitoredResourceDescriptorsRequest actualRequest = (ListMonitoredResourceDescriptorsRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method pullTest.
@Test
@SuppressWarnings("all")
public void pullTest() {
PullResponse expectedResponse = PullResponse.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
boolean returnImmediately = false;
int maxMessages = 496131527;
PullResponse actualResponse = client.pull(subscription, returnImmediately, maxMessages);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
PullRequest actualRequest = (PullRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
Assert.assertEquals(returnImmediately, actualRequest.getReturnImmediately());
Assert.assertEquals(maxMessages, actualRequest.getMaxMessages());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method testIamPermissionsTest.
@Test
@SuppressWarnings("all")
public void testIamPermissionsTest() {
TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build();
mockIAMPolicy.addResponse(expectedResponse);
String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
List<String> permissions = new ArrayList<>();
TestIamPermissionsResponse actualResponse = client.testIamPermissions(formattedResource, permissions);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
Assert.assertEquals(permissions, actualRequest.getPermissionsList());
}
Aggregations