Repository: ambari
Updated Branches:
  refs/heads/trunk 9dfbf91df -> 5bb1faefb


AMBARI-10543. String matches does not work on metrics property of Widget 
response.


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

Branch: refs/heads/trunk
Commit: 5bb1faefb10bce6f2eee5d65d98f4ad9e05d4e8d
Parents: 9dfbf91
Author: Siddharth Wagle <swa...@hortonworks.com>
Authored: Thu Apr 16 11:17:49 2015 -0700
Committer: Siddharth Wagle <swa...@hortonworks.com>
Committed: Thu Apr 16 11:17:49 2015 -0700

----------------------------------------------------------------------
 .../internal/WidgetResourceProvider.java        |  6 ++--
 .../internal/WidgetResourceProviderTest.java    | 32 +++++++++++++-------
 2 files changed, 24 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5bb1faef/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java
 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java
index 1bd1058..59f0e88 100644
--- 
a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java
+++ 
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/WidgetResourceProvider.java
@@ -230,14 +230,14 @@ public class WidgetResourceProvider extends 
AbstractControllerResourceProvider {
       resource.setProperty(WIDGET_ID_PROPERTY_ID, entity.getId());
       resource.setProperty(WIDGET_WIDGET_NAME_PROPERTY_ID, 
entity.getWidgetName());
       resource.setProperty(WIDGET_WIDGET_TYPE_PROPERTY_ID, 
entity.getWidgetType());
-      setResourceProperty(resource, WIDGET_METRICS_PROPERTY_ID, 
gson.fromJson(entity.getMetrics(), ArrayList.class), requestedIds);
+      setResourceProperty(resource, WIDGET_METRICS_PROPERTY_ID, 
entity.getMetrics(), requestedIds);
       setResourceProperty(resource, WIDGET_TIME_CREATED_PROPERTY_ID, 
entity.getTimeCreated(), requestedIds);
       resource.setProperty(WIDGET_AUTHOR_PROPERTY_ID, entity.getAuthor());
       setResourceProperty(resource, WIDGET_DESCRIPTION_PROPERTY_ID, 
entity.getDescription(), requestedIds);
       resource.setProperty(WIDGET_DISPLAY_NAME_PROPERTY_ID, 
entity.getDisplayName());
       resource.setProperty(WIDGET_SCOPE_PROPERTY_ID, entity.getScope());
-      setResourceProperty(resource, WIDGET_VALUES_PROPERTY_ID, 
gson.fromJson(entity.getWidgetValues(), ArrayList.class), requestedIds);
-      setResourceProperty(resource, WIDGET_PROPERTIES_PROPERTY_ID, 
gson.fromJson(entity.getProperties(), Map.class), requestedIds);
+      setResourceProperty(resource, WIDGET_VALUES_PROPERTY_ID, 
entity.getWidgetValues(), requestedIds);
+      setResourceProperty(resource, WIDGET_PROPERTIES_PROPERTY_ID, 
entity.getProperties(), requestedIds);
 
       String clusterName = null;
       try {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5bb1faef/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
index 568a89c..917f1c2 100644
--- 
a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
+++ 
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/WidgetResourceProviderTest.java
@@ -145,11 +145,20 @@ public class WidgetResourceProviderTest {
     Assert.assertEquals("displ_name", 
r.getPropertyValue(WidgetResourceProvider.WIDGET_DISPLAY_NAME_PROPERTY_ID));
     Assert.assertEquals("widget name", 
r.getPropertyValue(WidgetResourceProvider.WIDGET_WIDGET_NAME_PROPERTY_ID));
     Object metrics = 
r.getPropertyValue(WidgetResourceProvider.WIDGET_METRICS_PROPERTY_ID);
-    Assert.assertTrue(metrics instanceof List);
-    Assert.assertEquals(2, ((List) metrics).size());
-    Object values = 
r.getPropertyValue(WidgetResourceProvider.WIDGET_VALUES_PROPERTY_ID);
-    Assert.assertTrue(values instanceof List);
-    Assert.assertEquals(1, ((List) values).size());
+    Assert.assertEquals("[{\"widget_id\":\"metrics/jvm/HeapMemoryUsed\"," +
+            
"\"host_component_criteria\":\"host_components/metrics/dfs/FSNamesystem/HAState\\u003dactive\","
 +
+            "\"service_name\":\"HDFS\",\"component_name\":\"NAMENODE\"," +
+            
"\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[used]\",\"category\":\"\"},"
 +
+            "{\"widget_id\":\"metrics/jvm/HeapMemoryMax\"," +
+            
"\"host_component_criteria\":\"host_components/metrics/dfs/FSNamesystem/HAState\\u003dactive\","
 +
+            "\"service_name\":\"HDFS\",\"component_name\":\"NAMENODE\"," +
+            "\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[max]\"," +
+            "\"category\":\"\"}]", 
r.getPropertyValue(WidgetResourceProvider.WIDGET_METRICS_PROPERTY_ID));
+    Assert.assertEquals("[{\"name\":\"NameNode Heap\"," +
+            "\"value\":\"${java.lang:type\\u003dMemory.HeapMemoryUsage[used] / 
" +
+            "java.lang:type\\u003dMemory.HeapMemoryUsage[max]}\"}]",
+            
r.getPropertyValue(WidgetResourceProvider.WIDGET_VALUES_PROPERTY_ID));
+    Assert.assertEquals("{\"name\":\"value\"}", 
r.getPropertyValue(WidgetResourceProvider.WIDGET_PROPERTIES_PROPERTY_ID));
   }
 
 
@@ -433,12 +442,13 @@ public class WidgetResourceProviderTest {
     widgetEntity.setDescription("Description");
     widgetEntity.setMetrics("[{\"widget_id\":\"metrics/jvm/HeapMemoryUsed\"," +
             
"\"host_component_criteria\":\"host_components/metrics/dfs/FSNamesystem/HAState\\u003dactive\","
 +
-            "\"service_name\":\"HDFS\",\"component_na\n" +
-            
"me\":\"NAMENODE\",\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[used]\",\"category\":\"\"},"
 +
-            
"{\"widget_id\":\"metrics/jvm/HeapMemoryMax\",\"host_component_criteria\":\"host_compone\n"
 +
-            
"nts/metrics/dfs/FSNamesystem/HAState\\u003dactive\",\"service_name\":\"HDFS\","
 +
-            
"\"component_name\":\"NAMENODE\",\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[max]\","
 +
-            "\"category\":\n\"\"}]");
+            "\"service_name\":\"HDFS\",\"component_name\":\"NAMENODE\"," +
+            
"\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[used]\",\"category\":\"\"},"
 +
+            "{\"widget_id\":\"metrics/jvm/HeapMemoryMax\"," +
+            
"\"host_component_criteria\":\"host_components/metrics/dfs/FSNamesystem/HAState\\u003dactive\","
 +
+            "\"service_name\":\"HDFS\",\"component_name\":\"NAMENODE\"," +
+            "\"name\":\"java.lang:type\\u003dMemory.HeapMemoryUsage[max]\"," +
+            "\"category\":\"\"}]");
     widgetEntity.setWidgetValues("[{\"name\":\"NameNode Heap\"," +
             "\"value\":\"${java.lang:type\\u003dMemory.HeapMemoryUsage[used] / 
" +
             "java.lang:type\\u003dMemory.HeapMemoryUsage[max]}\"}]");

Reply via email to