use of com.google.pubsub.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ReportErrorsServiceClientTest method reportErrorEventExceptionTest.
@Test
@SuppressWarnings("all")
public void reportErrorEventExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockReportErrorsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
ReportedErrorEvent event = ReportedErrorEvent.newBuilder().build();
client.reportErrorEvent(projectName, event);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.pubsub.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupTest.
@Test
@SuppressWarnings("all")
public void createGroupTest() {
GroupName name2 = GroupName.create("[PROJECT]", "[GROUP]");
String displayName = "displayName1615086568";
GroupName parentName = GroupName.create("[PROJECT]", "[GROUP]");
String filter = "filter-1274492040";
boolean isCluster = false;
Group expectedResponse = Group.newBuilder().setNameWithGroupName(name2).setDisplayName(displayName).setParentNameWithGroupName(parentName).setFilter(filter).setIsCluster(isCluster).build();
mockGroupService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
Group actualResponse = client.createGroup(name, group);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(group, actualRequest.getGroup());
}
use of com.google.pubsub.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class GroupServiceClientTest method createGroupExceptionTest.
@Test
@SuppressWarnings("all")
public void createGroupExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGroupService.addException(exception);
try {
ProjectName name = ProjectName.create("[PROJECT]");
Group group = Group.newBuilder().build();
client.createGroup(name, group);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.pubsub.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class MetricServiceClientTest method listTimeSeriesTest.
@Test
@SuppressWarnings("all")
public void listTimeSeriesTest() {
String nextPageToken = "";
TimeSeries timeSeriesElement = TimeSeries.newBuilder().build();
List<TimeSeries> timeSeries = Arrays.asList(timeSeriesElement);
ListTimeSeriesResponse expectedResponse = ListTimeSeriesResponse.newBuilder().setNextPageToken(nextPageToken).addAllTimeSeries(timeSeries).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.create("[PROJECT]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.FULL;
ListTimeSeriesPagedResponse pagedListResponse = client.listTimeSeries(name, filter, interval, view);
List<TimeSeries> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getTimeSeriesList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListTimeSeriesRequest actualRequest = (ListTimeSeriesRequest) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsProjectName());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertEquals(interval, actualRequest.getInterval());
Assert.assertEquals(view, actualRequest.getView());
}
use of com.google.pubsub.v1.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method deleteEventsExceptionTest.
@Test
@SuppressWarnings("all")
public void deleteEventsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockErrorStatsService.addException(exception);
try {
ProjectName projectName = ProjectName.create("[PROJECT]");
client.deleteEvents(projectName);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
Aggregations