Search in sources :

Example 1 with GetAlertPolicyRequest

use of com.google.monitoring.v3.GetAlertPolicyRequest in project java-monitoring by googleapis.

the class AlertPolicyServiceClientTest method getAlertPolicyTest2.

@Test
public void getAlertPolicyTest2() throws Exception {
    AlertPolicy expectedResponse = AlertPolicy.newBuilder().setName(AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()).setDisplayName("displayName1714148973").setDocumentation(AlertPolicy.Documentation.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).addAllConditions(new ArrayList<AlertPolicy.Condition>()).setEnabled(BoolValue.newBuilder().build()).setValidity(Status.newBuilder().build()).addAllNotificationChannels(new ArrayList<String>()).setCreationRecord(MutationRecord.newBuilder().build()).setMutationRecord(MutationRecord.newBuilder().build()).setAlertStrategy(AlertPolicy.AlertStrategy.newBuilder().build()).build();
    mockAlertPolicyService.addResponse(expectedResponse);
    String name = "name3373707";
    AlertPolicy actualResponse = client.getAlertPolicy(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetAlertPolicyRequest actualRequest = ((GetAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AlertPolicy(com.google.monitoring.v3.AlertPolicy) ArrayList(java.util.ArrayList) GetAlertPolicyRequest(com.google.monitoring.v3.GetAlertPolicyRequest) Test(org.junit.Test)

Example 2 with GetAlertPolicyRequest

use of com.google.monitoring.v3.GetAlertPolicyRequest in project java-monitoring by googleapis.

the class AlertPolicyServiceClientTest method getAlertPolicyTest.

@Test
public void getAlertPolicyTest() throws Exception {
    AlertPolicy expectedResponse = AlertPolicy.newBuilder().setName(AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]").toString()).setDisplayName("displayName1714148973").setDocumentation(AlertPolicy.Documentation.newBuilder().build()).putAllUserLabels(new HashMap<String, String>()).addAllConditions(new ArrayList<AlertPolicy.Condition>()).setEnabled(BoolValue.newBuilder().build()).setValidity(Status.newBuilder().build()).addAllNotificationChannels(new ArrayList<String>()).setCreationRecord(MutationRecord.newBuilder().build()).setMutationRecord(MutationRecord.newBuilder().build()).setAlertStrategy(AlertPolicy.AlertStrategy.newBuilder().build()).build();
    mockAlertPolicyService.addResponse(expectedResponse);
    AlertPolicyName name = AlertPolicyName.ofProjectAlertPolicyName("[PROJECT]", "[ALERT_POLICY]");
    AlertPolicy actualResponse = client.getAlertPolicy(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetAlertPolicyRequest actualRequest = ((GetAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) AlertPolicy(com.google.monitoring.v3.AlertPolicy) AlertPolicyName(com.google.monitoring.v3.AlertPolicyName) ArrayList(java.util.ArrayList) GetAlertPolicyRequest(com.google.monitoring.v3.GetAlertPolicyRequest) Test(org.junit.Test)

Aggregations

AlertPolicy (com.google.monitoring.v3.AlertPolicy)2 GetAlertPolicyRequest (com.google.monitoring.v3.GetAlertPolicyRequest)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 AlertPolicyName (com.google.monitoring.v3.AlertPolicyName)1