use of com.google.cloud.talent.v4.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ErrorStatsServiceClientTest method listGroupStatsTest.
@Test
@SuppressWarnings("all")
public void listGroupStatsTest() {
String nextPageToken = "";
ErrorGroupStats errorGroupStatsElement = ErrorGroupStats.newBuilder().build();
List<ErrorGroupStats> errorGroupStats = Arrays.asList(errorGroupStatsElement);
ListGroupStatsResponse expectedResponse = ListGroupStatsResponse.newBuilder().setNextPageToken(nextPageToken).addAllErrorGroupStats(errorGroupStats).build();
mockErrorStatsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
QueryTimeRange timeRange = QueryTimeRange.newBuilder().build();
ListGroupStatsPagedResponse pagedListResponse = client.listGroupStats(projectName, timeRange);
List<ErrorGroupStats> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getErrorGroupStatsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockErrorStatsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListGroupStatsRequest actualRequest = (ListGroupStatsRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(timeRange, actualRequest.getTimeRange());
}
use of com.google.cloud.talent.v4.ProjectName in project google-cloud-java by GoogleCloudPlatform.
the class ReportErrorsServiceClientTest method reportErrorEventTest.
@Test
@SuppressWarnings("all")
public void reportErrorEventTest() {
ReportErrorEventResponse expectedResponse = ReportErrorEventResponse.newBuilder().build();
mockReportErrorsService.addResponse(expectedResponse);
ProjectName projectName = ProjectName.create("[PROJECT]");
ReportedErrorEvent event = ReportedErrorEvent.newBuilder().build();
ReportErrorEventResponse actualResponse = client.reportErrorEvent(projectName, event);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockReportErrorsService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ReportErrorEventRequest actualRequest = (ReportErrorEventRequest) actualRequests.get(0);
Assert.assertEquals(projectName, actualRequest.getProjectNameAsProjectName());
Assert.assertEquals(event, actualRequest.getEvent());
}
use of com.google.cloud.talent.v4.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.cloud.talent.v4.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.cloud.talent.v4.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());
}
}
Aggregations