Repository: ambari
Updated Branches:
  refs/heads/trunk a4d5a31bb -> 711e64ac0


AMBARI-15445. Alerts: Allow alerts to emit a structured response.(vbrodetskyi)


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

Branch: refs/heads/trunk
Commit: 711e64ac0b01a134bd46f1527931827a030a9a2b
Parents: a4d5a31
Author: Vitaly Brodetskyi <vbrodets...@hortonworks.com>
Authored: Fri Mar 18 14:37:44 2016 +0200
Committer: Vitaly Brodetskyi <vbrodets...@hortonworks.com>
Committed: Fri Mar 18 14:37:44 2016 +0200

----------------------------------------------------------------------
 .../AlertDefinitionResourceProvider.java        |  9 +++
 .../orm/entities/AlertDefinitionEntity.java     | 23 ++++++-
 .../orm/entities/AlertDefinitionEntity_.java    |  1 +
 .../server/state/alert/AlertDefinition.java     | 27 +++++++-
 .../state/alert/AlertDefinitionFactory.java     |  2 +
 .../server/upgrade/UpgradeCatalog240.java       |  8 ++-
 .../main/resources/Ambari-DDL-Derby-CREATE.sql  |  1 +
 .../main/resources/Ambari-DDL-MySQL-CREATE.sql  |  1 +
 .../main/resources/Ambari-DDL-Oracle-CREATE.sql |  1 +
 .../resources/Ambari-DDL-Postgres-CREATE.sql    |  1 +
 .../Ambari-DDL-Postgres-EMBEDDED-CREATE.sql     |  1 +
 .../resources/Ambari-DDL-SQLAnywhere-CREATE.sql |  1 +
 .../resources/Ambari-DDL-SQLServer-CREATE.sql   |  1 +
 .../AlertDefinitionResourceProviderTest.java    | 12 +++-
 .../server/upgrade/UpgradeCatalog240Test.java   | 72 ++++++++++++--------
 15 files changed, 125 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
index 0f73ec6..08a708f 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProvider.java
@@ -79,6 +79,7 @@ public class AlertDefinitionResourceProvider extends 
AbstractControllerResourceP
   protected static final String ALERT_DEF_ID = "AlertDefinition/id";
   protected static final String ALERT_DEF_NAME = "AlertDefinition/name";
   protected static final String ALERT_DEF_LABEL = "AlertDefinition/label";
+  protected static final String ALERT_DEF_HELP_URL = 
"AlertDefinition/help_url";
   protected static final String ALERT_DEF_DESCRIPTION = 
"AlertDefinition/description";
   protected static final String ALERT_DEF_INTERVAL = 
"AlertDefinition/interval";
   protected static final String ALERT_DEF_SERVICE_NAME = 
"AlertDefinition/service_name";
@@ -144,6 +145,7 @@ public class AlertDefinitionResourceProvider extends 
AbstractControllerResourceP
     PROPERTY_IDS.add(ALERT_DEF_NAME);
     PROPERTY_IDS.add(ALERT_DEF_LABEL);
     PROPERTY_IDS.add(ALERT_DEF_DESCRIPTION);
+    PROPERTY_IDS.add(ALERT_DEF_HELP_URL);
     PROPERTY_IDS.add(ALERT_DEF_INTERVAL);
     PROPERTY_IDS.add(ALERT_DEF_ENABLED);
     PROPERTY_IDS.add(ALERT_DEF_SCOPE);
@@ -412,6 +414,7 @@ public class AlertDefinitionResourceProvider extends 
AbstractControllerResourceP
     String componentName = (String) requestMap.get(ALERT_DEF_COMPONENT_NAME);
     String type = (String) requestMap.get(ALERT_DEF_SOURCE_TYPE);
     String label = (String) requestMap.get(ALERT_DEF_LABEL);
+    String helpURL = (String) requestMap.get(ALERT_DEF_HELP_URL);
     String description = (String) requestMap.get(ALERT_DEF_DESCRIPTION);
     String desiredScope = (String) requestMap.get(ALERT_DEF_SCOPE);
 
@@ -555,6 +558,11 @@ public class AlertDefinitionResourceProvider extends 
AbstractControllerResourceP
       managed = true;
     }
 
+    if ((null != helpURL) && !helpURL.equals(entity.getHelpURL())) {
+      entity.setHelpURL(helpURL);
+      managed = true;
+    }
+
     if ((null != description) && !description.equals(entity.getDescription())) 
{
       entity.setDescription(description);
       managed = true;
@@ -688,6 +696,7 @@ public class AlertDefinitionResourceProvider extends 
AbstractControllerResourceP
     setResourceProperty(resource, ALERT_DEF_ENABLED, 
Boolean.valueOf(entity.getEnabled()), requestedIds);
     setResourceProperty(resource, ALERT_DEF_IGNORE_HOST, 
Boolean.valueOf(entity.isHostIgnored()), requestedIds);
     setResourceProperty(resource, ALERT_DEF_SCOPE, entity.getScope(), 
requestedIds);
+    setResourceProperty(resource, ALERT_DEF_HELP_URL, entity.getHelpURL(), 
requestedIds);
 
     boolean sourceTypeRequested = setResourceProperty(resource,
         ALERT_DEF_SOURCE_TYPE, entity.getSourceType(), requestedIds);

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
index 9e21bec..b08935c 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity.java
@@ -79,6 +79,9 @@ public class AlertDefinitionEntity {
   @Column(name = "label", nullable = true, length = 255)
   private String label;
 
+  @Column(name = "help_url", nullable = true, length = 512)
+  private String helpURL;
+
   @Lob
   @Basic
   @Column(name = "description", nullable = true, length = 32672)
@@ -414,6 +417,24 @@ public class AlertDefinitionEntity {
   }
 
   /**
+   * Gets the help url for this alert.
+   *
+   * @return the helpURL or {@code null} if none.
+   */
+  public String getHelpURL() {
+    return helpURL;
+  }
+
+  /**
+   * Sets a help url for this alert.
+   *
+   * @param helpURL the helpURL or {@code null} if none.
+   */
+  public void setHelpURL(String helpURL) {
+    this.helpURL = helpURL;
+  }
+
+  /**
    * Gets the optional description for this alert definition.
    *
    * @return the description, or {@code null} if none.
@@ -527,4 +548,4 @@ public class AlertDefinitionEntity {
     buffer.append("}");
     return buffer.toString();
   }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity_.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity_.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity_.java
index d2d4cf3..8c59a08 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity_.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/AlertDefinitionEntity_.java
@@ -40,6 +40,7 @@ public class AlertDefinitionEntity_ {
   public static volatile SingularAttribute<AlertDefinitionEntity, String> 
componentName;
   public static volatile SingularAttribute<AlertDefinitionEntity, String> 
definitionName;
   public static volatile SingularAttribute<AlertDefinitionEntity, String> 
label;
+  public static volatile SingularAttribute<AlertDefinitionEntity, String> 
helpURL;
   public static volatile SingularAttribute<AlertDefinitionEntity, Scope> scope;
   public static volatile SingularAttribute<AlertDefinitionEntity, Integer> 
enabled;
   public static volatile SingularAttribute<AlertDefinitionEntity, String> hash;

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinition.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinition.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinition.java
index 9fff5f2..e197cd0 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinition.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinition.java
@@ -19,6 +19,8 @@ package org.apache.ambari.server.state.alert;
 
 import java.util.HashSet;
 
+import org.apache.commons.lang.StringUtils;
+
 import com.google.gson.annotations.SerializedName;
 
 /**
@@ -53,6 +55,9 @@ public class AlertDefinition {
   @SerializedName("ignore_host")
   private boolean ignoreHost = false;
 
+  @SerializedName("help_url")
+  private String helpURL = null;
+
   /**
    * Gets the cluster ID for this definition.
    *
@@ -203,6 +208,22 @@ public class AlertDefinition {
   }
 
   /**
+   * @return the help url for this definition or {@code null} if none.
+   */
+  public String getHelpURL() {
+    return helpURL;
+  }
+
+  /**
+   * Sets the help url for this definition.
+   *
+   * @param helpURL
+   */
+  public void setHelpURL(String helpURL) {
+    this.helpURL = helpURL;
+  }
+
+  /**
    * @return the description
    */
   public String getDescription() {
@@ -240,7 +261,7 @@ public class AlertDefinition {
    * Compares {@link #equals(Object)} of every field. This is used mainly for
    * reconciling the stack versus the database.
    *
-   * @param object
+   * @param obj
    * @return
    */
   public boolean deeplyEquals(Object obj) {
@@ -285,6 +306,10 @@ public class AlertDefinition {
       return false;
     }
 
+    if (!StringUtils.equals(helpURL, other.helpURL)) {
+      return false;
+    }
+
     if (description == null) {
       if (other.description != null) {
         return false;

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
index 3b4f5fc..1676b53 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionFactory.java
@@ -187,6 +187,7 @@ public class AlertDefinitionFactory {
     definition.setScope(entity.getScope());
     definition.setServiceName(entity.getServiceName());
     definition.setLabel(entity.getLabel());
+    definition.setHelpURL(entity.getHelpURL());
     definition.setDescription(entity.getDescription());
     definition.setUuid(entity.getHash());
 
@@ -252,6 +253,7 @@ public class AlertDefinitionFactory {
     entity.setLabel(definition.getLabel());
     entity.setDescription(definition.getDescription());
     entity.setScheduleInterval(definition.getInterval());
+    entity.setHelpURL(definition.getHelpURL());
     entity.setServiceName(definition.getServiceName());
 
     Scope scope = definition.getScope();

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
index a803f73..7b83710 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/upgrade/UpgradeCatalog240.java
@@ -32,7 +32,6 @@ import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.controller.AmbariManagementController;
-import org.apache.ambari.server.orm.DBAccessor;
 import org.apache.ambari.server.orm.DBAccessor.DBColumnInfo;
 import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
 import org.apache.ambari.server.orm.dao.PermissionDAO;
@@ -65,6 +64,8 @@ import com.google.inject.persist.Transactional;
 public class UpgradeCatalog240 extends AbstractUpgradeCatalog {
 
   protected static final String ADMIN_PERMISSION_TABLE = "adminpermission";
+  protected static final String ALERT_DEFINITION_TABLE = "alert_definition";
+  protected static final String HELP_URL_COLUMN = "help_url";
   protected static final String PERMISSION_ID_COL = "permission_name";
   protected static final String SORT_ORDER_COL = "sort_order";
   protected static final String REPO_VERSION_TABLE = "repo_version";
@@ -139,6 +140,7 @@ public class UpgradeCatalog240 extends 
AbstractUpgradeCatalog {
     updateServiceComponentDesiredStateTableDDL();
     createServiceComponentHistoryTable();
     updateClusterTableDDL();
+    updateAlertDefinitionTable();
   }
 
   private void updateClusterTableDDL() throws SQLException {
@@ -442,6 +444,10 @@ public class UpgradeCatalog240 extends 
AbstractUpgradeCatalog {
         new DBColumnInfo(SORT_ORDER_COL, Short.class, null, 1, false));
   }
 
+  protected void updateAlertDefinitionTable() throws SQLException {
+    dbAccessor.addColumn(ALERT_DEFINITION_TABLE, new 
DBColumnInfo(HELP_URL_COLUMN, String.class, 512, null, true));
+  }
+
   protected void setRoleSortOrder() throws SQLException {
     String updateStatement = "UPDATE " + ADMIN_PERMISSION_TABLE + " SET " + 
SORT_ORDER_COL + "=%d WHERE " + PERMISSION_ID_COL + "='%s'";
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
index a85202d..e01e693 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Derby-CREATE.sql
@@ -868,6 +868,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description VARCHAR(3000),
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
index 9b4810c..fb24c89 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-MySQL-CREATE.sql
@@ -878,6 +878,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description TEXT,
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
index cc3d197..2e092b2 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Oracle-CREATE.sql
@@ -868,6 +868,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR2(255),
   scope VARCHAR2(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR2(255),
+  help_url VARCHAR2(512),
   description CLOB,
   enabled NUMBER(1) DEFAULT 1 NOT NULL,
   schedule_interval NUMBER(10) NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
index 07c786d..5f5df3c 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-CREATE.sql
@@ -872,6 +872,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description TEXT,
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
index ab6dc93..3d71f1f 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-Postgres-EMBEDDED-CREATE.sql
@@ -958,6 +958,7 @@ CREATE TABLE ambari.alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description TEXT,
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
index 8e91fde..9d70fbb 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLAnywhere-CREATE.sql
@@ -867,6 +867,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description TEXT,
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql 
b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
index 440ca44..715000e 100644
--- a/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
+++ b/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
@@ -978,6 +978,7 @@ CREATE TABLE alert_definition (
   component_name VARCHAR(255),
   scope VARCHAR(255) DEFAULT 'ANY' NOT NULL,
   label VARCHAR(255),
+  help_url VARCHAR(512),
   description TEXT,
   enabled SMALLINT DEFAULT 1 NOT NULL,
   schedule_interval INTEGER NOT NULL,

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
index d44b7c8..79d512a 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AlertDefinitionResourceProviderTest.java
@@ -69,6 +69,8 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
 
 import com.google.gson.Gson;
 import com.google.inject.Binder;
@@ -76,8 +78,6 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
 
 /**
  * AlertDefinition tests
@@ -228,7 +228,8 @@ public class AlertDefinitionResourceProviderTest {
         AlertDefinitionResourceProvider.ALERT_DEF_DESCRIPTION,
         AlertDefinitionResourceProvider.ALERT_DEF_IGNORE_HOST,
         AlertDefinitionResourceProvider.ALERT_DEF_SOURCE,
-        AlertDefinitionResourceProvider.ALERT_DEF_SOURCE_TYPE);
+        AlertDefinitionResourceProvider.ALERT_DEF_SOURCE_TYPE,
+        AlertDefinitionResourceProvider.ALERT_DEF_HELP_URL);
 
     AmbariManagementController amc = 
createMock(AmbariManagementController.class);
     Clusters clusters = createMock(Clusters.class);
@@ -277,6 +278,10 @@ public class AlertDefinitionResourceProviderTest {
         Boolean.FALSE,
         
r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_IGNORE_HOST));
 
+    Assert.assertEquals(
+            "http://test-help-url";,
+            
r.getPropertyValue(AlertDefinitionResourceProvider.ALERT_DEF_HELP_URL));
+
     Assert.assertNotNull(r.getPropertyValue("AlertDefinition/source/type"));
   }
 
@@ -867,6 +872,7 @@ public class AlertDefinitionResourceProviderTest {
     entity.setSourceType(SourceType.METRIC);
     entity.setSource(sourceJson);
     entity.setCluster(clusterEntity);
+    entity.setHelpURL("http://test-help-url";);
     return Arrays.asList(entity);
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/711e64ac/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
index 7f3b80c..7b2d797 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/upgrade/UpgradeCatalog240Test.java
@@ -19,12 +19,33 @@
 package org.apache.ambari.server.upgrade;
 
 
-import com.google.inject.Binder;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-import com.google.inject.Provider;
+import javax.persistence.EntityManager;
 import junit.framework.Assert;
+import static org.easymock.EasyMock.anyObject;
+import static org.easymock.EasyMock.capture;
+import static org.easymock.EasyMock.createMockBuilder;
+import static org.easymock.EasyMock.createNiceMock;
+import static org.easymock.EasyMock.createStrictMock;
+import static org.easymock.EasyMock.eq;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.newCapture;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.reset;
+import static org.easymock.EasyMock.verify;
+import static org.junit.Assert.assertEquals;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.configuration.Configuration;
@@ -41,31 +62,11 @@ import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import javax.persistence.EntityManager;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.createMockBuilder;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.createStrictMock;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.newCapture;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
-import static org.junit.Assert.assertEquals;
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Module;
+import com.google.inject.Provider;
 
 public class UpgradeCatalog240Test {
   private static Injector injector;
@@ -163,6 +164,9 @@ public class UpgradeCatalog240Test {
     dbAccessor.addFKConstraint(UpgradeCatalog240.CLUSTER_TABLE, 
"FK_clusters_upgrade_id",
         UpgradeCatalog240.CLUSTER_UPGRADE_ID_COLUMN, 
UpgradeCatalog240.UPGRADE_TABLE, "upgrade_id", false);
 
+    Capture<DBAccessor.DBColumnInfo> capturedHelpURLColumnInfo = newCapture();
+    dbAccessor.addColumn(eq(UpgradeCatalog240.ALERT_DEFINITION_TABLE), 
capture(capturedHelpURLColumnInfo));
+
     replay(dbAccessor, configuration, connection, statement, resultSet);
 
     Module module = new Module() {
@@ -239,6 +243,14 @@ public class UpgradeCatalog240Test {
       actualCaptures.put(historyColumnInfo.getName(), 
historyColumnInfo.getType());
     }
 
+    DBAccessor.DBColumnInfo columnHelpURLInfo = 
capturedHelpURLColumnInfo.getValue();
+    Assert.assertNotNull(columnHelpURLInfo);
+    Assert.assertEquals(UpgradeCatalog240.HELP_URL_COLUMN, 
columnHelpURLInfo.getName());
+    Assert.assertEquals(Integer.valueOf(512), columnHelpURLInfo.getLength());
+    Assert.assertEquals(String.class, columnHelpURLInfo.getType());
+    Assert.assertEquals(null, columnHelpURLInfo.getDefaultValue());
+    Assert.assertEquals(true, columnHelpURLInfo.isNullable());
+
     assertEquals(expectedCaptures, actualCaptures);
 
     verify(dbAccessor);

Reply via email to