@Override public IterableWithMarker<Alarm> apply(Object input) { return alarmApi.listAt(input.toString()); }
@Override public IterableWithMarker<AlarmHistoryItem> apply(Object input) { return alarmApi.listHistoryAt(input.toString()); }
@Test protected void testAlarmCRUD() throws Exception { api().save(new SaveAlarmOptions() .actionsEnabled(true) .alarmDescription("This is a test alarm for jclouds.") api().setState(alarmName, "Updating the state.", null, Alarm.State.OK); api().disable(ImmutableSet.of(alarmName)); api().enable(ImmutableSet.of(alarmName)); api().delete(ImmutableSet.of(alarmName));
public boolean apply(Void arg) { for (IterableWithMarker<Alarm> page : api().list()) { for (Alarm alarm : page) { if (alarm.getAlarmName().equals(alarmName)) { return true; } } } return false; } }, 5, 1, MINUTES).apply(null);
public boolean apply(Void arg) { for (IterableWithMarker<AlarmHistoryItem> page : api().listHistory()) { for (AlarmHistoryItem alarmHistoryItem : page) { if (alarmHistoryItem.getAlarmName().equals(alarmName)) { JsonObject historyData = new JsonParser().parse(alarmHistoryItem.getHistoryData()) .getAsJsonObject(); if (historyData.has("newState") && historyData.getAsJsonObject("newState").has("stateReason") && historyData.getAsJsonObject("newState").get("stateReason").getAsString() .equals("Updating the state.")) { return true; } } } } return false; } }, 5, 1, MINUTES).apply(null);
@Test(expectedExceptions = ResourceNotFoundException.class) public void testDeleteAlarmsIs404() throws Exception { CloudWatchApi cloudWatchApi = requestSendsResponse(deleteAlarmsRequest, HttpResponse.builder().statusCode(404).build()); // Ensure a ResourceNotFoundException is thrown cloudWatchApi.getAlarmApiForRegion(null).delete(ImmutableSet.of( "TestAlarmName1", "TestAlarmName2" )); }
@Test(expectedExceptions = InsufficientResourcesException.class) public void testPutMetricAlarmIs400() throws Exception { Payload payload = payloadFromResourceWithContentType("/LimitExceededResponse.xml", "text/xml"); CloudWatchApi cloudWatchApi = requestSendsResponse(putMetricAlarmRequest, HttpResponse.builder() .payload(payload) .statusCode(400) .build()); // Ensure an InsufficientResourcesException is thrown cloudWatchApi.getAlarmApiForRegion(null).save(saveAlarmOptions); }
public boolean apply(ListAlarmsForMetric options) { for (Alarm alarm : api().listForMetric(options)) { if (alarm.getAlarmName().equals(alarmName)) { return true; } } return false; } }, 5, 1, MINUTES).apply(dafmo);
@Test(expectedExceptions = IllegalArgumentException.class) public void testSetAlarmStateIs400() throws Exception { Payload payload = payloadFromResourceWithContentType("/InvalidFormatResponse.xml", "text/xml"); CloudWatchApi cloudWatchApi = requestSendsResponse(setAlarmStateRequest, HttpResponse.builder() .payload(payload) .statusCode(400) .build()); // Ensure an IllegalArgumentException is thrown cloudWatchApi.getAlarmApiForRegion(null).setState("TestAlarmName", "TestStateReason", "{\"reason\": \"Some reason\"}", Alarm.State.OK); }
public void testEnableAlarmActions() throws Exception { CloudWatchApi cloudWatchApi = requestSendsResponse(alarmRequest(ImmutableMap.of( "Action", "EnableAlarmActions", "AlarmNames.member.1", "TestAlarmName1", "AlarmNames.member.2", "TestAlarmName2", "Signature", "Q1VemnXpc57PKMs9NVCX6R%2B/TSDgsGzQwpOHQ70aJuU%3D" )), HttpResponse.builder() .statusCode(200) .payload(payloadFromResourceWithContentType("/VoidResponse.xml", "text/xml")) .build()); // Ensure there is no error returned cloudWatchApi.getAlarmApiForRegion(null).enable(ImmutableSet.of( "TestAlarmName1", "TestAlarmName2" )); }
public void testDisableAlarmActions() throws Exception { CloudWatchApi cloudWatchApi = requestSendsResponse(alarmRequest(ImmutableMap.of( "Action", "DisableAlarmActions", "AlarmNames.member.1", "TestAlarmName1", "AlarmNames.member.2", "TestAlarmName2", "Signature", "tvSfJ%2BgcrHowwUECSniV0TQP2OObpWCuba0S5dd723Y%3D" )), HttpResponse.builder() .statusCode(200) .payload(payloadFromResourceWithContentType("/VoidResponse.xml", "text/xml")) .build()); // Ensure there is no error returned cloudWatchApi.getAlarmApiForRegion(null).disable(ImmutableSet.of( "TestAlarmName1", "TestAlarmName2" )); }
@Test protected void testAlarmCRUD() throws Exception { api().save(new SaveAlarmOptions() .actionsEnabled(true) .alarmDescription("This is a test alarm for jclouds.") api().setState(alarmName, "Updating the state.", null, Alarm.State.OK); api().disable(ImmutableSet.of(alarmName)); api().enable(ImmutableSet.of(alarmName)); api().delete(ImmutableSet.of(alarmName));
public boolean apply(Void arg) { for (IterableWithMarker<Alarm> page : api().list()) { for (Alarm alarm : page) { if (alarm.getAlarmName().equals(alarmName)) { return true; } } } return false; } }, 5, 1, MINUTES).apply(null);
public boolean apply(ListAlarmHistoryOptions options) { for (IterableWithMarker<AlarmHistoryItem> page : api().listHistory(options)) { for (AlarmHistoryItem alarmHistoryItem : page) { if (alarmHistoryItem.getAlarmName().equals(alarmName)) { JsonObject historyData = new JsonParser().parse(alarmHistoryItem.getHistoryData()) .getAsJsonObject(); if (historyData.has("newState") && historyData.getAsJsonObject("newState").has("stateReason") && historyData.getAsJsonObject("newState").get("stateReason").getAsString() .equals("Updating the state.")) { return true; } } } } return false; } }, 5, 1, MINUTES).apply(daho);
@Test(expectedExceptions = ResourceNotFoundException.class) public void testDeleteAlarmsIs404() throws Exception { CloudWatchApi cloudWatchApi = requestSendsResponse(deleteAlarmsRequest, HttpResponse.builder().statusCode(404).build()); // Ensure a ResourceNotFoundException is thrown cloudWatchApi.getAlarmApiForRegion(null).delete(ImmutableSet.of( "TestAlarmName1", "TestAlarmName2" )); }
@Test(expectedExceptions = InsufficientResourcesException.class) public void testPutMetricAlarmIs400() throws Exception { Payload payload = payloadFromResourceWithContentType("/LimitExceededResponse.xml", "text/xml"); CloudWatchApi cloudWatchApi = requestSendsResponse(putMetricAlarmRequest, HttpResponse.builder() .payload(payload) .statusCode(400) .build()); // Ensure an InsufficientResourcesException is thrown cloudWatchApi.getAlarmApiForRegion(null).save(saveAlarmOptions); }
public boolean apply(ListAlarmsForMetric options) { for (Alarm alarm : api().listForMetric(options)) { if (alarm.getAlarmName().equals(alarmName)) { return true; } } return false; } }, 5, 1, MINUTES).apply(dafmo);
@Test(expectedExceptions = IllegalArgumentException.class) public void testSetAlarmStateIs400() throws Exception { Payload payload = payloadFromResourceWithContentType("/InvalidFormatResponse.xml", "text/xml"); CloudWatchApi cloudWatchApi = requestSendsResponse(setAlarmStateRequest, HttpResponse.builder() .payload(payload) .statusCode(400) .build()); // Ensure an IllegalArgumentException is thrown cloudWatchApi.getAlarmApiForRegion(null).setState("TestAlarmName", "TestStateReason", "{\"reason\": \"Some reason\"}", Alarm.State.OK); }