Search in sources :

Example 1 with CreateAlertPolicyRequest

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

the class AlertPolicyServiceClientTest method createAlertPolicyTest.

@Test
public void createAlertPolicyTest() 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);
    FolderName name = FolderName.of("[FOLDER]");
    AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
    AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateAlertPolicyRequest(com.google.monitoring.v3.CreateAlertPolicyRequest) AlertPolicy(com.google.monitoring.v3.AlertPolicy) ArrayList(java.util.ArrayList) FolderName(com.google.monitoring.v3.FolderName) Test(org.junit.Test)

Example 2 with CreateAlertPolicyRequest

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

the class AlertPolicyServiceClientTest method createAlertPolicyTest3.

@Test
public void createAlertPolicyTest3() 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);
    ProjectName name = ProjectName.of("[PROJECT]");
    AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
    AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateAlertPolicyRequest(com.google.monitoring.v3.CreateAlertPolicyRequest) ProjectName(com.google.monitoring.v3.ProjectName) AlertPolicy(com.google.monitoring.v3.AlertPolicy) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with CreateAlertPolicyRequest

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

the class AlertPolicyServiceClientTest method createAlertPolicyTest4.

@Test
public void createAlertPolicyTest4() 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 alertPolicy = AlertPolicy.newBuilder().build();
    AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) CreateAlertPolicyRequest(com.google.monitoring.v3.CreateAlertPolicyRequest) AlertPolicy(com.google.monitoring.v3.AlertPolicy) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 4 with CreateAlertPolicyRequest

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

the class AlertPolicyServiceClientTest method createAlertPolicyTest2.

@Test
public void createAlertPolicyTest2() 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);
    OrganizationName name = OrganizationName.of("[ORGANIZATION]");
    AlertPolicy alertPolicy = AlertPolicy.newBuilder().build();
    AlertPolicy actualResponse = client.createAlertPolicy(name, alertPolicy);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockAlertPolicyService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateAlertPolicyRequest actualRequest = ((CreateAlertPolicyRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertEquals(alertPolicy, actualRequest.getAlertPolicy());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.monitoring.v3.OrganizationName) AbstractMessage(com.google.protobuf.AbstractMessage) CreateAlertPolicyRequest(com.google.monitoring.v3.CreateAlertPolicyRequest) AlertPolicy(com.google.monitoring.v3.AlertPolicy) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

AlertPolicy (com.google.monitoring.v3.AlertPolicy)4 CreateAlertPolicyRequest (com.google.monitoring.v3.CreateAlertPolicyRequest)4 AbstractMessage (com.google.protobuf.AbstractMessage)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 FolderName (com.google.monitoring.v3.FolderName)1 OrganizationName (com.google.monitoring.v3.OrganizationName)1 ProjectName (com.google.monitoring.v3.ProjectName)1