use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method listNotificationChannelsTest3.
@Test
public void listNotificationChannelsTest3() throws Exception {
NotificationChannel responsesElement = NotificationChannel.newBuilder().build();
ListNotificationChannelsResponse expectedResponse = ListNotificationChannelsResponse.newBuilder().setNextPageToken("").addAllNotificationChannels(Arrays.asList(responsesElement)).build();
mockNotificationChannelService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
ListNotificationChannelsPagedResponse pagedListResponse = client.listNotificationChannels(name);
List<NotificationChannel> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationChannelsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationChannelsRequest actualRequest = ((ListNotificationChannelsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class NotificationChannelServiceClientTest method createNotificationChannelTest3.
@Test
public void createNotificationChannelTest3() throws Exception {
NotificationChannel expectedResponse = NotificationChannel.newBuilder().setType("type3575610").setName(NotificationChannelName.ofProjectNotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").putAllLabels(new HashMap<String, String>()).putAllUserLabels(new HashMap<String, String>()).setEnabled(BoolValue.newBuilder().build()).setCreationRecord(MutationRecord.newBuilder().build()).addAllMutationRecords(new ArrayList<MutationRecord>()).build();
mockNotificationChannelService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
NotificationChannel notificationChannel = NotificationChannel.newBuilder().build();
NotificationChannel actualResponse = client.createNotificationChannel(name, notificationChannel);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockNotificationChannelService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateNotificationChannelRequest actualRequest = ((CreateNotificationChannelRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertEquals(notificationChannel, actualRequest.getNotificationChannel());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class MetricServiceClientTest method listTimeSeriesExceptionTest3.
@Test
public void listTimeSeriesExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
TimeInterval interval = TimeInterval.newBuilder().build();
ListTimeSeriesRequest.TimeSeriesView view = ListTimeSeriesRequest.TimeSeriesView.forNumber(0);
client.listTimeSeries(name, filter, interval, view);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class MetricServiceClientTest method listMetricDescriptorsExceptionTest3.
@Test
public void listMetricDescriptorsExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockMetricService.addException(exception);
try {
ProjectName name = ProjectName.of("[PROJECT]");
client.listMetricDescriptors(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.phishingprotection.v1beta1.ProjectName in project java-monitoring by googleapis.
the class AlertPolicyServiceClientTest method listAlertPoliciesTest3.
@Test
public void listAlertPoliciesTest3() throws Exception {
AlertPolicy responsesElement = AlertPolicy.newBuilder().build();
ListAlertPoliciesResponse expectedResponse = ListAlertPoliciesResponse.newBuilder().setNextPageToken("").addAllAlertPolicies(Arrays.asList(responsesElement)).build();
mockAlertPolicyService.addResponse(expectedResponse);
ProjectName name = ProjectName.of("[PROJECT]");
ListAlertPoliciesPagedResponse pagedListResponse = client.listAlertPolicies(name);
List<AlertPolicy> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getAlertPoliciesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListAlertPoliciesRequest actualRequest = ((ListAlertPoliciesRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations