incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smoha...@apache.org
Subject svn commit: r1468157 - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ ambari-server/src/test/java/org/apache/ambari/server/controller/internal/
Date Mon, 15 Apr 2013 17:17:12 GMT
Author: smohanty
Date: Mon Apr 15 17:17:11 2013
New Revision: 1468157

URL: http://svn.apache.org/r1468157
Log:
AMBARI-1931. params/run_smoke_test=true is not taking effect. (smohanty)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
    incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1468157&r1=1468156&r2=1468157&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon Apr 15 17:17:11 2013
@@ -719,6 +719,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1931. params/run_smoke_test=true is not taking effect. (smohanty)
+
  AMBARI-1919. JobTracker History Server failed to come up on 1.3.0 stack
  and the request for service stall is stalled. (smohanty)
 

Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java?rev=1468157&r1=1468156&r2=1468157&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProvider.java
Mon Apr 15 17:17:11 2013
@@ -125,26 +125,33 @@ public abstract class AbstractController
   }
 
   /**
-   * Extracting given query_paramater value from the predicate(parsed http body)
+   * Extracting given query_paramater value from the predicate
    * @param queryParameterId
    * @param predicate
    * @return
    */
   protected static Object getQueryParameterValue(String queryParameterId, Predicate predicate)
{
 
+    Object result = null;
+
     if (predicate instanceof ArrayPredicate) {
       ArrayPredicate arrayPredicate  = (ArrayPredicate) predicate;
       for (Predicate predicateItem : arrayPredicate.getPredicates()) {
-        if (predicateItem instanceof ComparisonPredicate) {
-          EqualsPredicate equalsPredicate =
-              (EqualsPredicate) predicateItem;
-          if (queryParameterId.equals(equalsPredicate.getPropertyId())) {
-            return equalsPredicate.getValue();
+          if (predicateItem instanceof EqualsPredicate) {
+            EqualsPredicate equalsPredicate =
+                (EqualsPredicate) predicateItem;
+            if (queryParameterId.equals(equalsPredicate.getPropertyId())) {
+              return equalsPredicate.getValue();
+            }
+          } else {
+            result = getQueryParameterValue(queryParameterId, predicateItem);
+            if (result != null) {
+              return result;
           }
         }
       }
 
     }
-    return null;
+    return result;
   }
 }

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java?rev=1468157&r1=1468156&r2=1468157&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
(original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java
Mon Apr 15 17:17:11 2013
@@ -71,12 +71,33 @@ public class AbstractControllerResourceP
     String queryParameterId2 = "qp/variable2";
     String queryParameterValue2 = "value2";
 
+    //Array of predicates
     Predicate  predicate = new PredicateBuilder().property(queryParameterId1).equals(queryParameterValue1).
         and().property(queryParameterId2).equals(queryParameterValue2).toPredicate();
 
     Assert.assertEquals(queryParameterValue1, AbstractControllerResourceProvider.getQueryParameterValue(queryParameterId1,
predicate));
     Assert.assertFalse(queryParameterValue2.equals(AbstractControllerResourceProvider.getQueryParameterValue(queryParameterId1,
predicate)));
     Assert.assertNull(AbstractControllerResourceProvider.getQueryParameterValue("queryParameterIdNotFound",
predicate));
+
+    String queryParameterId3 = "qp/variable3";
+    String queryParameterValue3 = "value3";
+
+    // tests ServiceInfo/state=INSTALLED&params/run_smoke_test=true
+    //Array of arrays of predicates
+    predicate = new PredicateBuilder().property(queryParameterId3).equals(queryParameterValue3).
+        and().begin().property(queryParameterId1).equals(queryParameterValue1).
+        and().property(queryParameterId2).equals(queryParameterValue2).end().toPredicate();
+
+    Assert.assertEquals(queryParameterValue1, AbstractControllerResourceProvider.
+        getQueryParameterValue(queryParameterId1, predicate));
+    Assert.assertFalse(queryParameterValue2.equals(AbstractControllerResourceProvider.
+        getQueryParameterValue(queryParameterId1, predicate)));
+    Assert.assertNull(AbstractControllerResourceProvider.
+        getQueryParameterValue("queryParameterIdNotFound", predicate));
+
+    Assert.assertEquals(queryParameterValue3, AbstractControllerResourceProvider.
+        getQueryParameterValue(queryParameterId3, predicate));
+
   }
 
   }



Mime
View raw message