use of com.google.cloud.datalabeling.v1beta1.ProjectName in project java-datalabeling by googleapis.
the class DataLabelingServiceClientTest method listEvaluationJobsTest.
@Test
public void listEvaluationJobsTest() throws Exception {
EvaluationJob responsesElement = EvaluationJob.newBuilder().build();
ListEvaluationJobsResponse expectedResponse = ListEvaluationJobsResponse.newBuilder().setNextPageToken("").addAllEvaluationJobs(Arrays.asList(responsesElement)).build();
mockDataLabelingService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
ListEvaluationJobsPagedResponse pagedListResponse = client.listEvaluationJobs(parent, filter);
List<EvaluationJob> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getEvaluationJobsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockDataLabelingService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListEvaluationJobsRequest actualRequest = ((ListEvaluationJobsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project java-talent by googleapis.
the class JobSearchCreateTenant method createTenant.
// Create Tenant for scoping resources, e.g. companies and jobs.
public static void createTenant(String projectId, String externalId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) {
ProjectName parent = ProjectName.of(projectId);
Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build();
CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(parent.toString()).setTenant(tenant).build();
Tenant response = tenantServiceClient.createTenant(request);
System.out.println("Created Tenant");
System.out.format("Name: %s%n", response.getName());
System.out.format("External ID: %s%n", response.getExternalId());
}
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project java-monitoring by googleapis.
the class GroupServiceClientTest method createGroupTest3.
@Test
public void createGroupTest3() throws Exception {
Group expectedResponse = Group.newBuilder().setName(GroupName.ofProjectGroupName("[PROJECT]", "[GROUP]").toString()).setDisplayName("displayName1714148973").setParentName("parentName-244870571").setFilter("filter-1274492040").setIsCluster(true).build();
mockGroupService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
Group group = Group.newBuilder().build();
Group actualResponse = client.createGroup(name, group);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockGroupService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateGroupRequest actualRequest = ((CreateGroupRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(group, actualRequest.getGroup());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project java-monitoring by googleapis.
the class MetricServiceClientTest method listMonitoredResourceDescriptorsTest3.
@Test
public void listMonitoredResourceDescriptorsTest3() throws Exception {
MonitoredResourceDescriptor responsesElement = MonitoredResourceDescriptor.newBuilder().build();
ListMonitoredResourceDescriptorsResponse expectedResponse = ListMonitoredResourceDescriptorsResponse.newBuilder().setNextPageToken("").addAllResourceDescriptors(Arrays.asList(responsesElement)).build();
mockMetricService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[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<AbstractMessage> actualRequests = mockMetricService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListMonitoredResourceDescriptorsRequest actualRequest = ((ListMonitoredResourceDescriptorsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.datalabeling.v1beta1.ProjectName in project java-monitoring by googleapis.
the class MetricServiceClientTest method createTimeSeriesExceptionTest.
@Test
public void createTimeSeriesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
List<TimeSeries> timeSeries = new ArrayList<>();
client.createTimeSeries(name, timeSeries);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations