ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject ambari git commit: AMBARI-8613. Repository Version Management - Fix ignored tests (yshylov via dlysnichenko)
Date Wed, 10 Dec 2014 13:58:50 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk b1853c2f4 -> e148fca5a


AMBARI-8613. Repository Version Management - Fix ignored tests (yshylov via dlysnichenko)


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

Branch: refs/heads/trunk
Commit: e148fca5aadff1f8720de8285d700c1fde7f8a7b
Parents: b1853c2
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Wed Dec 10 15:57:24 2014 +0200
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Wed Dec 10 15:58:36 2014 +0200

----------------------------------------------------------------------
 .../resources/BaseStacksResourceDefinition.java |  6 ++-
 .../OperatingSystemResourceProvider.java        |  4 +-
 .../internal/RepositoryResourceProvider.java    |  4 +-
 .../RepositoryVersionResourceProvider.java      | 40 +++++++++++---------
 .../orm/entities/RepositoryVersionEntity.java   | 15 +++++---
 .../ambari/server/api/query/QueryImplTest.java  |  7 +---
 .../internal/ClusterControllerImplTest.java     | 32 ++++++++++++----
 .../RepositoryVersionResourceProviderTest.java  |  8 ++--
 .../controller/internal/RequestImplTest.java    |  5 +--
 9 files changed, 72 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
index a3a8261..6bff79c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/resources/BaseStacksResourceDefinition.java
@@ -41,7 +41,7 @@ public abstract class BaseStacksResourceDefinition extends BaseResourceDefinitio
     return Collections.<PostProcessor>singletonList(new StacksHrefProcessor());
   }
 
-  private class StacksHrefProcessor extends BaseHrefPostProcessor {
+  private class StacksHrefProcessor extends BaseHrefPostProcessor { 
     @Override
     /**
      * If processing a /stacks or /stack_versions endpoint, replace the endpoint names.
@@ -57,7 +57,9 @@ public abstract class BaseStacksResourceDefinition extends BaseResourceDefinitio
 
         // The UI currently expects the old sub-resource names so don't do replacement
         // if the href contains "_=" as only the UI uses this syntax.
-        if (! href.contains("_=")) {
+        // UPD: added another hotfix to properly rename subresources for stack_versions and
repository_versions,
+        // it is backward compatible with old fix 
+        if (! href.contains("_=") || href.contains("/stack_versions/") || href.contains("/repository_versions/"))
{
           renameChildren(resultNode);
         }
       }

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
index 682d8bd..b656def 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/OperatingSystemResourceProvider.java
@@ -55,7 +55,7 @@ public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider
{
   };
 
   @SuppressWarnings("serial")
-  private static Set<String> propertyIds = new HashSet<String>() {
+  public static Set<String> propertyIds = new HashSet<String>() {
     {
       add(OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
       add(OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID);
@@ -65,7 +65,7 @@ public class OperatingSystemResourceProvider extends ReadOnlyResourceProvider
{
   };
 
   @SuppressWarnings("serial")
-  private static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
+  public static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
     {
       put(Resource.Type.OperatingSystem, OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID);
       put(Resource.Type.Stack, OPERATING_SYSTEM_STACK_NAME_PROPERTY_ID);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
index c2a81cd..8c0a46c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryResourceProvider.java
@@ -67,7 +67,7 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
   };
 
   @SuppressWarnings("serial")
-  private static Set<String> propertyIds = new HashSet<String>() {
+  public static Set<String> propertyIds = new HashSet<String>() {
     {
       add(REPOSITORY_REPO_NAME_PROPERTY_ID);
       add(REPOSITORY_STACK_NAME_PROPERTY_ID);
@@ -84,7 +84,7 @@ public class RepositoryResourceProvider extends AbstractControllerResourceProvid
   };
 
   @SuppressWarnings("serial")
-  private static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
+  public static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
     {
       put(Resource.Type.Stack, REPOSITORY_STACK_NAME_PROPERTY_ID);
       put(Resource.Type.StackVersion, REPOSITORY_STACK_VERSION_PROPERTY_ID);

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
index db7cb58..4cf844d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProvider.java
@@ -28,6 +28,7 @@ import java.util.regex.Pattern;
 
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
+import org.apache.ambari.server.api.resources.OperatingSystemResourceDefinition;
 import org.apache.ambari.server.api.resources.RepositoryResourceDefinition;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
 import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
@@ -72,7 +73,8 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
   public static final String REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID = PropertyHelper.getPropertyId("RepositoryVersions",
"repository_version");
   public static final String REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID       = PropertyHelper.getPropertyId("RepositoryVersions",
"display_name");
   public static final String REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID       = PropertyHelper.getPropertyId("RepositoryVersions",
"upgrade_pack");
-  public static final String REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID  = PropertyHelper.getPropertyId("RepositoryVersions",
"operating_systems");
+  public static final String SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID         = "operating_systems";
//TODO should be replaced with resource definition when we get rid of Stacks2Service 
+  public static final String SUBRESOURCE_REPOSITORIES_PROPERTY_ID              = new RepositoryResourceDefinition().getPluralName();
 
   @SuppressWarnings("serial")
   private static Set<String> pkPropertyIds = new HashSet<String>() {
@@ -82,7 +84,7 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
   };
 
   @SuppressWarnings("serial")
-  private static Set<String> propertyIds = new HashSet<String>() {
+  public static Set<String> propertyIds = new HashSet<String>() {
     {
       add(REPOSITORY_VERSION_ID_PROPERTY_ID);
       add(REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID);
@@ -90,12 +92,12 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
       add(REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID);
       add(REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID);
       add(REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID);
-      add(REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID);
+      add(SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID);
     }
   };
 
   @SuppressWarnings("serial")
-  private static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
+  public static Map<Type, String> keyPropertyIds = new HashMap<Type, String>()
{
     {
       put(Type.Stack, REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID);
       put(Type.StackVersion, REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID);
@@ -136,7 +138,7 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
         public Void invoke() throws AmbariException {
           final String[] requiredProperties = {
               REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID,
-              REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID,
+              SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
               REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID,
               REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID,
               REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID
@@ -229,7 +231,7 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
             throw new ObjectNotFoundException("There is no repository version with id " +
id);
           }
 
-          if (propertyMap.get(REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID) != null)
{
+          if (propertyMap.get(SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID) != null) {
 
             final List<ClusterVersionEntity> clusterVersionEntities =
                 clusterVersionDAO.findByStackAndVersion(entity.getStack(), entity.getVersion());
@@ -240,9 +242,15 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
                 firstClusterVersion.getState().name() + " on cluster " + firstClusterVersion.getClusterEntity().getClusterName());
             }
 
-            if (propertyMap.get(REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID) != null)
{
-              final Object repositories = propertyMap.get(REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID);
-              entity.setOperatingSystems(gson.toJson(repositories));
+            if (propertyMap.get(SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID) != null) {
+              final Object operatingSystems = propertyMap.get(SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID);
+              final String operatingSystemsJson = gson.toJson(operatingSystems);
+              try {
+                parseOperatingSystems(operatingSystemsJson);
+              } catch (Exception ex) {
+                throw new AmbariException("Json structure for operating systems is incorrect",
ex);
+              }
+              entity.setOperatingSystems(operatingSystemsJson);
             }
 
           }
@@ -354,16 +362,15 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
     final String stackVersion = properties.get(REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID).toString();
     entity.setDisplayName(properties.get(REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID).toString());
     entity.setStack(new StackId(stackName, stackVersion).getStackId());
-    entity.setUpgradePackage(properties.get(REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID).toString());
     entity.setVersion(properties.get(REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID).toString());
-    final Object repositories = properties.get(REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID);
-    final String repositoriesJson = gson.toJson(repositories);
+    final Object operatingSystems = properties.get(SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID);
+    final String operatingSystemsJson = gson.toJson(operatingSystems);
     try {
-      parseRepositories(repositoriesJson);
+      parseOperatingSystems(operatingSystemsJson);
     } catch (Exception ex) {
       throw new AmbariException("Json structure for operating systems is incorrect", ex);
     }
-    entity.setOperatingSystems(repositoriesJson);
+    entity.setOperatingSystems(operatingSystemsJson);
     entity.setUpgradePackage(getUpgradePackageName(stackName, stackVersion, entity.getVersion()));
     return entity;
   }
@@ -427,14 +434,13 @@ public class RepositoryVersionResourceProvider extends AbstractResourceProvider
    * @return list of operating system entities
    * @throws Exception if any kind of json parsing error happened
    */
-  public static List<OperatingSystemEntity> parseRepositories(String repositoriesJson)
throws Exception {
+  public static List<OperatingSystemEntity> parseOperatingSystems(String repositoriesJson)
throws Exception {
     final List<OperatingSystemEntity> operatingSystems = new ArrayList<OperatingSystemEntity>();
     final JsonArray rootJson = new JsonParser().parse(repositoriesJson).getAsJsonArray();
-    final String repositoriesSubresourceName = new RepositoryResourceDefinition().getPluralName();
     for (JsonElement operatingSystemJson: rootJson) {
       final OperatingSystemEntity operatingSystemEntity = new OperatingSystemEntity();
       operatingSystemEntity.setOsType(operatingSystemJson.getAsJsonObject().get(OperatingSystemResourceProvider.OPERATING_SYSTEM_OS_TYPE_PROPERTY_ID).getAsString());
-      for (JsonElement repositoryJson: operatingSystemJson.getAsJsonObject().get(repositoriesSubresourceName).getAsJsonArray())
{
+      for (JsonElement repositoryJson: operatingSystemJson.getAsJsonObject().get(SUBRESOURCE_REPOSITORIES_PROPERTY_ID).getAsJsonArray())
{
         final RepositoryEntity repositoryEntity = new RepositoryEntity();
         repositoryEntity.setBaseUrl(repositoryJson.getAsJsonObject().get(RepositoryResourceProvider.REPOSITORY_BASE_URL_PROPERTY_ID).getAsString());
         repositoryEntity.setName(repositoryJson.getAsJsonObject().get(RepositoryResourceProvider.REPOSITORY_REPO_NAME_PROPERTY_ID).getAsString());

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
index 4b5486a..8931e8c 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/entities/RepositoryVersionEntity.java
@@ -33,6 +33,7 @@ import javax.persistence.UniqueConstraint;
 
 import org.apache.ambari.server.controller.internal.RepositoryVersionResourceProvider;
 import org.apache.ambari.server.state.StackId;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -141,13 +142,15 @@ public class RepositoryVersionEntity {
   }
 
   public List<OperatingSystemEntity> getOperatingSystems() {
-    try {
-      return RepositoryVersionResourceProvider.parseRepositories(operatingSystems);
-    } catch (Exception ex) {
-      // Should never happen as we validate json before storing it to DB
-      LOG.error("Could not parse operating systems json stored in database:" + operatingSystems,
ex);
-      return Collections.emptyList();
+    if (StringUtils.isNotBlank(operatingSystems)) {
+      try {
+        return RepositoryVersionResourceProvider.parseOperatingSystems(operatingSystems);
+      } catch (Exception ex) {
+        // Should never happen as we validate json before storing it to DB
+        LOG.error("Could not parse operating systems json stored in database:" + operatingSystems,
ex);
+      }  
     }
+    return Collections.emptyList();
   }
 
   public String getStackName() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
index c2d82a5..57aea49 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/query/QueryImplTest.java
@@ -54,7 +54,6 @@ import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -163,7 +162,6 @@ public class QueryImplTest {
   }
 
   @Test
-  @Ignore
   public void testGetJoinedResourceProperties() throws Exception {
     ResourceDefinition resourceDefinition = new StackResourceDefinition();
 
@@ -205,7 +203,6 @@ public class QueryImplTest {
   }
 
   @Test
-  @Ignore
   public void testExecute_subResourcePredicate() throws Exception {
     ResourceDefinition resourceDefinition = new StackResourceDefinition();
 
@@ -249,7 +246,6 @@ public class QueryImplTest {
   }
 
   @Test
-  @Ignore
   public void testExecute__Stack_instance_specifiedSubResources() throws Exception {
     ResourceDefinition resourceDefinition = new StackResourceDefinition();
 
@@ -279,7 +275,7 @@ public class QueryImplTest {
     Assert.assertEquals("StackVersion:1", versionNode.getName());
     Assert.assertEquals(Resource.Type.StackVersion, versionNode.getObject().getType());
 
-    Assert.assertEquals(3, versionNode.getChildren().size());
+    Assert.assertEquals(4, versionNode.getChildren().size());
     TreeNode<Resource> opSystemsNode = versionNode.getChild("operatingSystems");
     Assert.assertEquals(3, opSystemsNode.getChildren().size());
 
@@ -346,7 +342,6 @@ public class QueryImplTest {
   }
 
   @Test
-  @Ignore
   public void testExecute_StackVersionPageSubResourcePredicate()
       throws NoSuchParentResourceException, UnsupportedPropertyException,
     NoSuchResourceException, SystemException {

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java
index 8eadb37..3ef0ade 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java
@@ -56,6 +56,7 @@ import org.apache.ambari.server.controller.spi.SortRequest;
 import org.apache.ambari.server.controller.spi.SortRequestProperty;
 import org.apache.ambari.server.controller.spi.SystemException;
 import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.spi.Resource.Type;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PredicateHelper;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
@@ -972,15 +973,11 @@ public class ClusterControllerImplTest {
       }
       providers.put(Resource.Type.Cluster, new TestClusterResourceProvider());
       providers.put(Resource.Type.Host, new TestHostResourceProvider());
-
-
       providers.put(Resource.Type.Stack, new TestStackResourceProvider());
       providers.put(Resource.Type.StackVersion, new TestStackVersionResourceProvider());
       providers.put(Resource.Type.OperatingSystem, new TestOperatingSystemResourceProvider());
       providers.put(Resource.Type.Repository, new TestRepositoryResourceProvider());
-
-
-
+      providers.put(Resource.Type.RepositoryVersion, new TestRepositoryVersionResourceProvider());
     }
 
     @Override
@@ -1003,6 +1000,10 @@ public class ClusterControllerImplTest {
     private TestResourceProvider(Resource.Type type) {
       super(PropertyHelper.getPropertyIds(type), PropertyHelper.getKeyPropertyIds(type));
     }
+    
+    private TestResourceProvider(Set<String> propertyIds, Map<Resource.Type, String>
keyPropertyIds) {
+      super(propertyIds, keyPropertyIds);
+    }
 
     @Override
     public RequestStatus createResources(Request request) throws SystemException, UnsupportedPropertyException,
ResourceAlreadyExistsException, NoSuchParentResourceException {
@@ -1201,7 +1202,7 @@ public class ClusterControllerImplTest {
 
   private static class TestOperatingSystemResourceProvider extends TestResourceProvider {
     private TestOperatingSystemResourceProvider() {
-      super(Resource.Type.OperatingSystem);
+      super(OperatingSystemResourceProvider.propertyIds, OperatingSystemResourceProvider.keyPropertyIds);
     }
 
     @Override
@@ -1219,7 +1220,7 @@ public class ClusterControllerImplTest {
 
   private static class TestRepositoryResourceProvider extends TestResourceProvider {
     private TestRepositoryResourceProvider() {
-      super(Resource.Type.Repository);
+      super(RepositoryResourceProvider.propertyIds, RepositoryResourceProvider.keyPropertyIds);
     }
 
     @Override
@@ -1233,6 +1234,23 @@ public class ClusterControllerImplTest {
       return getResources(Resource.Type.Repository, predicate, "Repositories/repo_id", keyPropertyValues);
     }
   }
+  
+  private static class TestRepositoryVersionResourceProvider extends TestResourceProvider
{
+    private TestRepositoryVersionResourceProvider() {
+      super(RepositoryVersionResourceProvider.propertyIds, RepositoryVersionResourceProvider.keyPropertyIds);
+    }
+
+    @Override
+    public Set<Resource> getResources(Request request, Predicate predicate)
+        throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException
{
+      Set<String> keyPropertyValues = new LinkedHashSet<String>();
+
+      keyPropertyValues.add("1");
+      keyPropertyValues.add("2");
+
+      return getResources(Resource.Type.RepositoryVersion, predicate, "RepositoriVersions/id",
keyPropertyValues);
+    }
+  }  
 
 }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
index 5e89178..6c89671 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
@@ -151,7 +151,7 @@ public class RepositoryVersionResourceProviderTest {
     final Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
     final Map<String, Object> properties = new LinkedHashMap<String, Object>();
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID,
"name");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
+    properties.put(RepositoryVersionResourceProvider.SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID,
"HDP");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID,
"pack1");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID,
"1.1");
@@ -250,7 +250,7 @@ public class RepositoryVersionResourceProviderTest {
     final Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
     final Map<String, Object> properties = new LinkedHashMap<String, Object>();
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID,
"name");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
+    properties.put(RepositoryVersionResourceProvider.SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID,
"HDP");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID,
"pack1");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID,
"1.1");
@@ -280,7 +280,7 @@ public class RepositoryVersionResourceProviderTest {
     final Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String,
Object>>();
     final Map<String, Object> properties = new LinkedHashMap<String, Object>();
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID,
"name");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
+    properties.put(RepositoryVersionResourceProvider.SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]",
Object.class));
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID,
"HDP");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID,
"pack1");
     properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID,
"1.1");
@@ -291,7 +291,7 @@ public class RepositoryVersionResourceProviderTest {
     final Predicate predicateStackVersion = new PredicateBuilder().property(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID).equals("1.1").toPredicate();
     final Request getRequest = PropertyHelper.getReadRequest(
         RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID,
-        RepositoryVersionResourceProvider.REPOSITORY_VERSION_OPERATING_SYSTEMS_PROPERTY_ID,
+        RepositoryVersionResourceProvider.SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID,
         RepositoryVersionResourceProvider.REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID);
     Assert.assertEquals(0, provider.getResources(getRequest, new AndPredicate(predicateStackName,
predicateStackVersion)).size());
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/e148fca5/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
index 202c69a..bf82a85 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestImplTest.java
@@ -51,7 +51,6 @@ public class RequestImplTest {
   }
 
   @Test
-  @Ignore
   public void testValidPropertyIds() {
     Request request = PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.HostComponent));
     Set<String> validPropertyIds = request.getPropertyIds();
@@ -211,7 +210,7 @@ public class RequestImplTest {
     Assert.assertTrue(validPropertyIds.contains("Versions/stack_version"));
     Assert.assertTrue(validPropertyIds.contains("Versions/min_upgrade_version"));
 
-    request = PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.OperatingSystem));
+    request = PropertyHelper.getReadRequest(OperatingSystemResourceProvider.propertyIds);
     validPropertyIds = request.getPropertyIds();
 
     //OperatingSystem resource properties
@@ -220,7 +219,7 @@ public class RequestImplTest {
     Assert.assertTrue(validPropertyIds.contains("OperatingSystems/stack_version"));
     Assert.assertTrue(validPropertyIds.contains("OperatingSystems/os_type"));
 
-    request = PropertyHelper.getReadRequest(PropertyHelper.getPropertyIds(Resource.Type.Repository));
+    request = PropertyHelper.getReadRequest(RepositoryResourceProvider.propertyIds);
     validPropertyIds = request.getPropertyIds();
 
     //Repository resource properties


Mime
View raw message