Repository: ambari
Updated Branches:
  refs/heads/trunk 5d06a3130 -> 9a9492d7a


AMBARI-10249 - Add a Log Appender for Alert State Change Events (part2) 
(jonathanhurley)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9a9492d7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9a9492d7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9a9492d7

Branch: refs/heads/trunk
Commit: 9a9492d7ae14851df919303c9d4fa859cb018b9d
Parents: 5d06a31
Author: Jonathan Hurley <jhur...@hortonworks.com>
Authored: Fri Mar 27 22:40:54 2015 -0400
Committer: Jonathan Hurley <jhur...@hortonworks.com>
Committed: Fri Mar 27 22:41:03 2015 -0400

----------------------------------------------------------------------
 .../alerts/AlertStateChangedEventTest.java      | 29 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9a9492d7/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
index 961157c..b64afed 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
@@ -36,6 +36,7 @@ import org.apache.ambari.server.orm.entities.AlertGroupEntity;
 import org.apache.ambari.server.orm.entities.AlertHistoryEntity;
 import org.apache.ambari.server.orm.entities.AlertNoticeEntity;
 import org.apache.ambari.server.orm.entities.AlertTargetEntity;
+import org.apache.ambari.server.state.Alert;
 import org.apache.ambari.server.state.AlertState;
 import org.easymock.EasyMock;
 import org.junit.After;
@@ -124,12 +125,24 @@ public class AlertStateChangedEventTest {
 
     EasyMock.replay(alertTarget, alertGroup, dispatchDao);
 
+    AlertDefinitionEntity definition = 
EasyMock.createNiceMock(AlertDefinitionEntity.class);
+    EasyMock.expect(definition.getDefinitionId()).andReturn(1L);
+    EasyMock.expect(definition.getServiceName()).andReturn("HDFS");
+    EasyMock.expect(definition.getLabel()).andReturn("hdfs-foo-alert");
+    EasyMock.expect(definition.getDescription()).andReturn("HDFS Foo Alert");
+
     AlertHistoryEntity history = 
EasyMock.createNiceMock(AlertHistoryEntity.class);
     AlertStateChangeEvent event = 
EasyMock.createNiceMock(AlertStateChangeEvent.class);
+    Alert alert = EasyMock.createNiceMock(Alert.class);
+
     
EasyMock.expect(history.getAlertState()).andReturn(AlertState.CRITICAL).atLeastOnce();
+    
EasyMock.expect(history.getAlertDefinition()).andReturn(definition).atLeastOnce();
+    EasyMock.expect(alert.getText()).andReturn("The HDFS Foo Alert Is Not 
Good").atLeastOnce();
+    
EasyMock.expect(alert.getState()).andReturn(AlertState.CRITICAL).atLeastOnce();
     
EasyMock.expect(event.getNewHistoricalEntry()).andReturn(history).atLeastOnce();
+    EasyMock.expect(event.getAlert()).andReturn(alert).atLeastOnce();
 
-    EasyMock.replay(history, event);
+    EasyMock.replay(definition, history, event, alert);
 
     // async publishing
     eventPublisher.publish(event);
@@ -164,15 +177,27 @@ public class AlertStateChangedEventTest {
     // that the create alert notice method was not called
     EasyMock.replay(alertTarget, alertGroup, dispatchDao);
 
+    AlertDefinitionEntity definition = 
EasyMock.createNiceMock(AlertDefinitionEntity.class);
+    EasyMock.expect(definition.getDefinitionId()).andReturn(1L);
+    EasyMock.expect(definition.getServiceName()).andReturn("HDFS");
+    EasyMock.expect(definition.getLabel()).andReturn("hdfs-foo-alert");
+    EasyMock.expect(definition.getDescription()).andReturn("HDFS Foo Alert");
+
     AlertHistoryEntity history = 
EasyMock.createNiceMock(AlertHistoryEntity.class);
     AlertStateChangeEvent event = 
EasyMock.createNiceMock(AlertStateChangeEvent.class);
+    Alert alert = EasyMock.createNiceMock(Alert.class);
 
     // use WARNING to ensure that the target (which only cares about OK/CRIT)
     // does not receive the alert notice
     
EasyMock.expect(history.getAlertState()).andReturn(AlertState.WARNING).atLeastOnce();
+
+    
EasyMock.expect(history.getAlertDefinition()).andReturn(definition).atLeastOnce();
+    EasyMock.expect(alert.getText()).andReturn("The HDFS Foo Alert Is Not 
Good").atLeastOnce();
+    
EasyMock.expect(alert.getState()).andReturn(AlertState.WARNING).atLeastOnce();
     
EasyMock.expect(event.getNewHistoricalEntry()).andReturn(history).atLeastOnce();
+    EasyMock.expect(event.getAlert()).andReturn(alert).atLeastOnce();
 
-    EasyMock.replay(history, event);
+    EasyMock.replay(definition, history, event, alert);
 
     // async publishing
     eventPublisher.publish(event);

Reply via email to