incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbeerbo...@apache.org
Subject svn commit: r1458360 [2/3] - in /incubator/ambari/trunk: ./ ambari-server/src/main/java/org/apache/ambari/server/api/resources/ ambari-server/src/main/java/org/apache/ambari/server/api/services/ ambari-server/src/main/java/org/apache/ambari/server/cont...
Date Tue, 19 Mar 2013 15:56:13 GMT
Modified: incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java (original)
+++ incubator/ambari/trunk/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java Tue Mar 19 15:56:11 2013
@@ -96,6 +96,9 @@ public interface Resource {
     Repository,
     StackService,
     StackConfiguration,
-    StackServiceComponent
+    StackServiceComponent,
+    DRFeed,
+    DRTargetCluster,
+    DRInstance
   }
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/key_properties.json Tue Mar 19 15:56:11 2013
@@ -50,20 +50,17 @@
     "Stack":"Versions/stack_name",
     "StackVersion":"Versions/stack_version"
   },
-  
   "OperatingSystem":{
     "Stack":"OperatingSystems/stack_name",
     "StackVersion":"OperatingSystems/stack_version",
     "OperatingSystem":"OperatingSystems/os_type"
   },
-  
   "Repository":{
     "Stack":"Repositories/stack_name",
     "StackVersion":"Repositories/stack_version",
     "OperatingSystem":"Repositories/os_type",
     "Repository":"Repositories/repo_id"
   },
-  
   "StackService":{
     "Stack":"StackServices/stack_name",
     "StackVersion":"StackServices/stack_version",
@@ -75,10 +72,20 @@
     "StackService":"StackConfigurations/service_name",
     "StackConfiguration":"StackConfigurations/property_name"
   },
-    "StackServiceComponent":{
+  "StackServiceComponent":{
     "Stack":"StackServiceComponents/stack_name",
     "StackVersion":"StackServiceComponents/stack_version",
     "StackService":"StackServiceComponents/service_name",
     "StackServiceComponent":"StackServiceComponents/component_name"
+  },
+  "DRFeed":{
+    "DRFeed":"Feed/name"
+  },
+  "DRTargetCluster":{
+    "DRTargetCluster":"Cluster/name"
+  },
+  "DRInstance":{
+    "DRFeed":"Feed/name",
+    "DRInstance":"Instance/id"
   }
 }

Modified: incubator/ambari/trunk/ambari-server/src/main/resources/properties.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/resources/properties.json?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/resources/properties.json (original)
+++ incubator/ambari/trunk/ambari-server/src/main/resources/properties.json Tue Mar 19 15:56:11 2013
@@ -1,165 +1,185 @@
 {
-    "Cluster":[
-        "Clusters/cluster_id",
-        "Clusters/cluster_name",
-        "Clusters/version",
-        "Clusters/state",
-        "Clusters/desired_configs",
-        "Clusters/actual_configs",
-        "_"
-    ],
-    "Service":[
-        "ServiceInfo/service_name",
-        "ServiceInfo/cluster_name",
-        "ServiceInfo/state",
-        "Services/description",
-        "Services/display_name",
-        "Services/attributes",
-        "ServiceInfo/desired_configs",
-        "_"
-    ],
-    "Host":[
-        "Hosts/cluster_name",
-        "Hosts/host_name",
-        "Hosts/ip",
-        "Hosts/attributes",
-        "Hosts/total_mem",
-        "Hosts/cpu_count",
-        "Hosts/os_arch",
-        "Hosts/os_type",
-        "Hosts/rack_info",
-        "Hosts/last_heartbeat_time",
-        "Hosts/last_agent_env",
-        "Hosts/last_registration_time",
-        "Hosts/disk_info",
-        "Hosts/host_status",
-        "Hosts/host_health_report",
-        "Hosts/public_host_name",
-        "Hosts/host_state",
-        "Hosts/desired_configs",
-        "_"
-    ],
-    "Component":[
-        "ServiceComponentInfo/service_name",
-        "ServiceComponentInfo/component_name",
-        "ServiceComponentInfo/cluster_name",
-        "ServiceComponentInfo/state",
-        "ServiceComponents/display_name",
-        "ServiceComponents/description",
-        "ServiceComponentInfo/desired_configs",
-        "_"
-    ],
-    "HostComponent":[
-        "HostRoles/role_id",
-        "HostRoles/cluster_name",
-        "HostRoles/host_name",
-        "HostRoles/component_name",
-        "HostRoles/state",
-        "HostRoles/desired_state",
-        "HostRoles/configs",
-        "HostRoles/desired_configs",
-        "HostRoles/stack_id",
-        "HostRoles/desired_stack_id",
-        "_"
-    ],
-    "Configuration":[
-        "Config/tag",
-        "Config/type",
-        "Config/cluster_name"
-    ],
-    "Action":[
-        "Actions/cluster_name",
-        "Actions/service_name",
-        "Actions/action_name",
-        "_"
-    ],
-    "Request":[
-        "Requests/id",
-        "Requests/cluster_name",
-        "Requests/request_status",
-        "_"
-    ],
-    "Task":[
-        "Tasks/id",
-        "Tasks/request_id",
-        "Tasks/cluster_name",
-        "Tasks/stage_id",
-        "Tasks/host_name",
-        "Tasks/role",
-        "Tasks/command",
-        "Tasks/status",
-        "Tasks/exit_code",
-        "Tasks/stderr",
-        "Tasks/stdout",
-        "Tasks/start_time",
-        "Tasks/attempt_cnt",
-        "_"
-    ],
-    "User":[
-        "Users/user_name",
-        "Users/roles",
-        "Users/password",
-        "Users/old_password",
-        "Users/ldap_user",
-        "_"
-    ],
-     "Stack":[
-        "Stacks/stack_name",
-        "_"
-    ],
-     "StackVersion":[
-        "Versions/stack_name",
-        "Versions/stack_version",
-        "Versions/min_upgrade_version",
-        "_"
-    ],
-    
-    
-   "OperatingSystem":[
-        "OperatingSystems/stack_name",
-        "OperatingSystems/stack_version",
-        "OperatingSystems/os_type",
-        "_"
-    ],
-    
-    "Repository":[
-        "Repositories/stack_name",
-        "Repositories/stack_version",
-        "Repositories/os_type",
-        "Repositories/base_url",
-        "Repositories/repo_id",
-        "Repositories/repo_name",
-        "Repositories/mirrors_list",
-        "_"
-    ],
-    "StackService":[
-        "StackServices/stack_name",
-        "StackServices/stack_version",
-        "StackServices/service_name",
-        "StackServices/user_name",
-        "StackServices/comments",
-        "StackServices/service_version",
-        "_"
-    ],
-    "StackConfiguration":[
-        "StackConfigurations/stack_name",
-        "StackConfigurations/stack_version",
-        "StackConfigurations/service_name",
-        "StackConfigurations/property_name",
-        "StackConfigurations/property_value",
-        "StackConfigurations/property_description",
-        "StackConfigurations/filename",
-        "_"
-    ],
-    "StackServiceComponent":[
-        "StackServiceComponents/stack_name",
-        "StackServiceComponents/stack_version",
-        "StackServiceComponents/service_name",
-        "StackServiceComponents/component_name",
-        "StackServiceComponents/component_category",
-        "StackServiceComponents/is_client",
-        "StackServiceComponents/is_master",
-        "_"
-    ]
-  }
+  "Cluster":[
+    "Clusters/cluster_id",
+    "Clusters/cluster_name",
+    "Clusters/version",
+    "Clusters/state",
+    "Clusters/desired_configs",
+    "Clusters/actual_configs",
+    "_"
+  ],
+  "Service":[
+    "ServiceInfo/service_name",
+    "ServiceInfo/cluster_name",
+    "ServiceInfo/state",
+    "Services/description",
+    "Services/display_name",
+    "Services/attributes",
+    "ServiceInfo/desired_configs",
+    "_"
+  ],
+  "Host":[
+    "Hosts/cluster_name",
+    "Hosts/host_name",
+    "Hosts/ip",
+    "Hosts/attributes",
+    "Hosts/total_mem",
+    "Hosts/cpu_count",
+    "Hosts/os_arch",
+    "Hosts/os_type",
+    "Hosts/rack_info",
+    "Hosts/last_heartbeat_time",
+    "Hosts/last_agent_env",
+    "Hosts/last_registration_time",
+    "Hosts/disk_info",
+    "Hosts/host_status",
+    "Hosts/host_health_report",
+    "Hosts/public_host_name",
+    "Hosts/host_state",
+    "Hosts/desired_configs",
+    "_"
+  ],
+  "Component":[
+    "ServiceComponentInfo/service_name",
+    "ServiceComponentInfo/component_name",
+    "ServiceComponentInfo/cluster_name",
+    "ServiceComponentInfo/state",
+    "ServiceComponents/display_name",
+    "ServiceComponents/description",
+    "ServiceComponentInfo/desired_configs",
+    "_"
+  ],
+  "HostComponent":[
+    "HostRoles/role_id",
+    "HostRoles/cluster_name",
+    "HostRoles/host_name",
+    "HostRoles/component_name",
+    "HostRoles/state",
+    "HostRoles/desired_state",
+    "HostRoles/configs",
+    "HostRoles/desired_configs",
+    "HostRoles/stack_id",
+    "HostRoles/desired_stack_id",
+    "_"
+  ],
+  "Configuration":[
+    "Config/tag",
+    "Config/type",
+    "Config/cluster_name"
+  ],
+  "Action":[
+    "Actions/cluster_name",
+    "Actions/service_name",
+    "Actions/action_name",
+    "_"
+  ],
+  "Request":[
+    "Requests/id",
+    "Requests/cluster_name",
+    "Requests/request_status",
+    "_"
+  ],
+  "Task":[
+    "Tasks/id",
+    "Tasks/request_id",
+    "Tasks/cluster_name",
+    "Tasks/stage_id",
+    "Tasks/host_name",
+    "Tasks/role",
+    "Tasks/command",
+    "Tasks/status",
+    "Tasks/exit_code",
+    "Tasks/stderr",
+    "Tasks/stdout",
+    "Tasks/start_time",
+    "Tasks/attempt_cnt",
+    "_"
+  ],
+  "User":[
+    "Users/user_name",
+    "Users/roles",
+    "Users/password",
+    "Users/old_password",
+    "Users/ldap_user",
+    "_"
+  ],
+  "Stack":[
+    "Stacks/stack_name",
+    "_"
+  ],
+  "StackVersion":[
+    "Versions/stack_name",
+    "Versions/stack_version",
+    "Versions/min_upgrade_version",
+    "_"
+  ],
+  "OperatingSystem":[
+    "OperatingSystems/stack_name",
+    "OperatingSystems/stack_version",
+    "OperatingSystems/os_type",
+    "_"
+  ],
+  "Repository":[
+    "Repositories/stack_name",
+    "Repositories/stack_version",
+    "Repositories/os_type",
+    "Repositories/base_url",
+    "Repositories/repo_id",
+    "Repositories/repo_name",
+    "Repositories/mirrors_list",
+    "_"
+  ],
+  "StackService":[
+    "StackServices/stack_name",
+    "StackServices/stack_version",
+    "StackServices/service_name",
+    "StackServices/user_name",
+    "StackServices/comments",
+    "StackServices/service_version",
+    "_"
+  ],
+  "StackConfiguration":[
+    "StackConfigurations/stack_name",
+    "StackConfigurations/stack_version",
+    "StackConfigurations/service_name",
+    "StackConfigurations/property_name",
+    "StackConfigurations/property_value",
+    "StackConfigurations/property_description",
+    "StackConfigurations/filename",
+    "_"
+  ],
+  "StackServiceComponent":[
+    "StackServiceComponents/stack_name",
+    "StackServiceComponents/stack_version",
+    "StackServiceComponents/service_name",
+    "StackServiceComponents/component_name",
+    "StackServiceComponents/component_category",
+    "StackServiceComponents/is_client",
+    "StackServiceComponents/is_master",
+    "_"
+  ],
+  "DRFeed":[
+    "Feed/name",
+    "Feed/description",
+    "Feed/status",
+    "Feed/schedule",
+    "Feed/sourceClusterName",
+    "Feed/targetClusterName"
+  ],
+  "DRTargetCluster":[
+    "Cluster/name",
+    "Cluster/colo",
+    "Cluster/interfaces",
+    "Cluster/locations",
+    "Cluster/properties"
+  ],
+  "DRInstance":[
+    "Instance/feedName",
+    "Instance/id",
+    "Instance/status",
+    "Instance/startTime",
+    "Instance/endTime",
+    "Instance/details",
+    "Instance/log"
+  ]
 }

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/FeedResourceDefinitionTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/FeedResourceDefinitionTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/FeedResourceDefinitionTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/FeedResourceDefinitionTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.api.resources;
+
+import org.apache.ambari.server.controller.spi.Resource;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+/**
+ * Tests for FeedResourceDefinition.
+ */
+public class FeedResourceDefinitionTest {
+  @Test
+  public void testGetPluralName() throws Exception {
+    FeedResourceDefinition definition = new FeedResourceDefinition();
+    Assert.assertEquals("feeds", definition.getPluralName());
+  }
+
+  @Test
+  public void testGetSingularName() throws Exception {
+    FeedResourceDefinition definition = new FeedResourceDefinition();
+    Assert.assertEquals("feed", definition.getSingularName());
+  }
+
+  @Test
+  public void testGetSubResourceDefinitions() throws Exception {
+    FeedResourceDefinition definition = new FeedResourceDefinition();
+    Set<SubResourceDefinition> subResourceDefinitions = definition.getSubResourceDefinitions ();
+    Assert.assertEquals(1, subResourceDefinitions.size());
+    SubResourceDefinition subResourceDefinition = subResourceDefinitions.iterator().next();
+    Assert.assertEquals(Resource.Type.DRInstance, subResourceDefinition.getType());
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/InstanceResourceDefinitionTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/InstanceResourceDefinitionTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/InstanceResourceDefinitionTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/InstanceResourceDefinitionTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,30 @@
+package org.apache.ambari.server.api.resources;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+/**
+ * Tests for InstanceResourceDefinition.
+ */
+public class InstanceResourceDefinitionTest {
+  @Test
+  public void testGetPluralName() throws Exception {
+    InstanceResourceDefinition definition = new InstanceResourceDefinition();
+    Assert.assertEquals("instances", definition.getPluralName());
+  }
+
+  @Test
+  public void testGetSingularName() throws Exception {
+    InstanceResourceDefinition definition = new InstanceResourceDefinition();
+    Assert.assertEquals("instance", definition.getSingularName());
+  }
+
+  @Test
+  public void testGetSubResourceDefinitions() throws Exception {
+    InstanceResourceDefinition definition = new InstanceResourceDefinition();
+    Set<SubResourceDefinition> subResourceDefinitions = definition.getSubResourceDefinitions ();
+    Assert.assertTrue(subResourceDefinitions.isEmpty());
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinitionTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinitionTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinitionTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/resources/TargetClusterResourceDefinitionTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,30 @@
+package org.apache.ambari.server.api.resources;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Set;
+
+/**
+ * Tests for TargetClusterResourceDefinition.
+ */
+public class TargetClusterResourceDefinitionTest {
+  @Test
+  public void testGetPluralName() throws Exception {
+    TargetClusterResourceDefinition definition = new TargetClusterResourceDefinition();
+    Assert.assertEquals("targets", definition.getPluralName());
+  }
+
+  @Test
+  public void testGetSingularName() throws Exception {
+    TargetClusterResourceDefinition definition = new TargetClusterResourceDefinition();
+    Assert.assertEquals("target", definition.getSingularName());
+  }
+
+  @Test
+  public void testGetSubResourceDefinitions() throws Exception {
+    TargetClusterResourceDefinition definition = new TargetClusterResourceDefinition();
+    Set<SubResourceDefinition> subResourceDefinitions = definition.getSubResourceDefinitions ();
+    Assert.assertTrue(subResourceDefinitions.isEmpty());
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/FeedServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/FeedServiceTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/FeedServiceTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/FeedServiceTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Unit tests for FeedService.
+ */
+public class FeedServiceTest extends BaseServiceTest {
+
+
+  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
+
+    //getFeed
+    FeedService feedService = new TestFeedService("feedName");
+    Method m = feedService.getClass().getMethod("getFeed", HttpHeaders.class, UriInfo.class, String.class);
+    Object[] args = new Object[] {getHttpHeaders(), getUriInfo(), "feedName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, feedService, m, args, null));
+
+    //getFeeds
+    feedService = new TestFeedService(null);
+    m = feedService.getClass().getMethod("getFeeds", HttpHeaders.class, UriInfo.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, feedService, m, args, null));
+
+    //createFeed
+    feedService = new TestFeedService("feedName");
+    m = feedService.getClass().getMethod("createFeed", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "feedName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, feedService, m, args, "body"));
+
+    //updateFeed
+    feedService = new TestFeedService("feedName");
+    m = feedService.getClass().getMethod("updateFeed", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "feedName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, feedService, m, args, "body"));
+
+    //deleteFeed
+    feedService = new TestFeedService("feedName");
+    m = feedService.getClass().getMethod("deleteFeed", HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "feedName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.DELETE, feedService, m, args, null));
+
+    return listInvocations;
+  }
+
+
+  private class TestFeedService extends FeedService {
+    private String m_feedId;
+
+    private TestFeedService(String feedId) {
+      m_feedId = feedId;
+    }
+
+    @Override
+    ResourceInstance createFeedResource(String feedName) {
+      assertEquals(m_feedId, feedName);
+      return getTestResource();
+    }
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+
+  //todo: test getHostHandler, getServiceHandler, getHostComponentHandler
+}

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/InstanceServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/InstanceServiceTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/InstanceServiceTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/InstanceServiceTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit tests for InstanceService.
+ */
+public class InstanceServiceTest extends BaseServiceTest {
+
+  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
+
+    //getInstance
+    InstanceService service = new TestInstanceService("clusterName", "instanceName");
+    Method m = service.getClass().getMethod("getInstance", HttpHeaders.class, UriInfo.class, String.class);
+    Object[] args = new Object[] {getHttpHeaders(), getUriInfo(), "instanceName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //getInstances
+    service = new TestInstanceService("clusterName", null);
+    m = service.getClass().getMethod("getInstances", HttpHeaders.class, UriInfo.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //createInstance
+    service = new TestInstanceService("clusterName", "instanceName");
+    m = service.getClass().getMethod("createInstance", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "instanceName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, service, m, args, "body"));
+
+    //updateInstance
+    service = new TestInstanceService("clusterName", "instanceName");
+    m = service.getClass().getMethod("updateInstance", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "instanceName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, service, m, args, "body"));
+
+    //deleteInstance
+    service = new TestInstanceService("clusterName", "instanceName");
+    m = service.getClass().getMethod("deleteInstance", HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "instanceName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.DELETE, service, m, args, null));
+
+    return listInvocations;
+  }
+
+  private class TestInstanceService extends InstanceService {
+    private String m_feedName;
+    private String m_instanceId;
+
+    private TestInstanceService(String feedName, String instanceId) {
+      super(feedName);
+      m_feedName = feedName;
+      m_instanceId = instanceId;
+    }
+
+    @Override
+    ResourceInstance createInstanceResource(String feedName, String instanceID, UriInfo ui) {
+      assertEquals(m_feedName, feedName);
+      assertEquals(m_instanceId, instanceID);
+      return getTestResource();
+    }
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+}
+
+

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/TargetClusterServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/TargetClusterServiceTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/TargetClusterServiceTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/api/services/TargetClusterServiceTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,108 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.api.services;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.api.services.parsers.RequestBodyParser;
+import org.apache.ambari.server.api.services.serializers.ResultSerializer;
+
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.UriInfo;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+
+
+/**
+ * Unit tests for TargetClusterService.
+ */
+public class TargetClusterServiceTest extends BaseServiceTest {
+
+
+  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
+
+    //getTargetCluster
+    TargetClusterService targetClusterService = new TestTargetClusterService("targetClusterName");
+    Method m = targetClusterService.getClass().getMethod("getTargetCluster", HttpHeaders.class, UriInfo.class, String.class);
+    Object[] args = new Object[] {getHttpHeaders(), getUriInfo(), "targetClusterName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, targetClusterService, m, args, null));
+
+    //getTargetClusters
+    targetClusterService = new TestTargetClusterService(null);
+    m = targetClusterService.getClass().getMethod("getTargetClusters", HttpHeaders.class, UriInfo.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, targetClusterService, m, args, null));
+
+    //createTargetCluster
+    targetClusterService = new TestTargetClusterService("targetClusterName");
+    m = targetClusterService.getClass().getMethod("createTargetCluster", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "targetClusterName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.POST, targetClusterService, m, args, "body"));
+
+    //updateTargetCluster
+    targetClusterService = new TestTargetClusterService("targetClusterName");
+    m = targetClusterService.getClass().getMethod("updateTargetCluster", String.class, HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "targetClusterName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, targetClusterService, m, args, "body"));
+
+    //deleteTargetCluster
+    targetClusterService = new TestTargetClusterService("targetClusterName");
+    m = targetClusterService.getClass().getMethod("deleteTargetCluster", HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "targetClusterName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.DELETE, targetClusterService, m, args, null));
+
+    return listInvocations;
+  }
+
+
+  private class TestTargetClusterService extends TargetClusterService {
+    private String m_targetClusterId;
+
+    private TestTargetClusterService(String targetClusterId) {
+      m_targetClusterId = targetClusterId;
+    }
+
+    @Override
+    ResourceInstance createTargetClusterResource(String targetClusterName) {
+      assertEquals(m_targetClusterId, targetClusterName);
+      return getTestResource();
+    }
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+
+  //todo: test getHostHandler, getServiceHandler, getHostComponentHandler
+}

Added: 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=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractControllerResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import junit.framework.Assert;
+import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+
+/**
+ * Abstract controller resource provider test.
+ */
+public class AbstractControllerResourceProviderTest {
+  @Test
+  public void testGetResourceProvider() throws Exception {
+    Set<String> propertyIds = new HashSet<String>();
+    propertyIds.add("foo");
+    propertyIds.add("cat1/foo");
+    propertyIds.add("cat2/bar");
+    propertyIds.add("cat2/baz");
+    propertyIds.add("cat3/sub1/bam");
+    propertyIds.add("cat4/sub2/sub3/bat");
+    propertyIds.add("cat5/subcat5/map");
+
+    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
+
+    AmbariManagementController managementController = createMock(AmbariManagementController.class);
+
+    AbstractResourceProvider provider =
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
+            Resource.Type.Service,
+            propertyIds,
+            keyPropertyIds,
+            managementController);
+
+    Assert.assertTrue(provider instanceof ServiceResourceProvider);
+  }
+}

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProviderTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProviderTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractDRResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+import junit.framework.Assert;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+
+/**
+ * Tests for AbstractDRResourceProvider.
+ */
+public class AbstractDRResourceProviderTest {
+  @Test
+  public void testGetResourceProvider() throws Exception {
+    Set<String> propertyIds = new HashSet<String>();
+    propertyIds.add("foo");
+    propertyIds.add("cat1/foo");
+    propertyIds.add("cat2/bar");
+    propertyIds.add("cat2/baz");
+    propertyIds.add("cat3/sub1/bam");
+    propertyIds.add("cat4/sub2/sub3/bat");
+    propertyIds.add("cat5/subcat5/map");
+
+    Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>();
+
+    IvoryService ivoryService = createMock(IvoryService.class);
+
+    AbstractResourceProvider provider =
+        (AbstractResourceProvider) AbstractDRResourceProvider.getResourceProvider(
+            Resource.Type.DRFeed,
+            propertyIds,
+            keyPropertyIds,
+            ivoryService);
+
+    Assert.assertTrue(provider instanceof FeedResourceProvider);
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AbstractResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -64,7 +64,7 @@ public class AbstractResourceProviderTes
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     AbstractResourceProvider provider =
-        (AbstractResourceProvider) AbstractResourceProvider.getResourceProvider(
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.Service,
             propertyIds,
             keyPropertyIds,
@@ -104,7 +104,7 @@ public class AbstractResourceProviderTes
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     AbstractResourceProvider provider =
-        (AbstractResourceProvider) AbstractResourceProvider.getResourceProvider(
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.Service,
             propertyIds,
             keyPropertyIds,
@@ -173,13 +173,6 @@ public class AbstractResourceProviderTes
       return null;
     }
 
-    public static Set<ConfigurationRequest> getConfigurationRequestSet(String clusterName, String type,
-                                                                       String tag, Map<String, String> configs)
-    {
-      EasyMock.reportMatcher(new ConfigurationRequestSetMatcher(clusterName, type, tag, configs));
-      return null;
-    }
-
     public static Set<HostRequest> getHostRequestSet(String hostname, String clusterName,
                                                      Map<String, String> hostAttributes)
     {
@@ -236,7 +229,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ClusterRequestMatcher(" + super.toString() + ")");
+      stringBuffer.append("ClusterRequestMatcher(").append(super.toString()).append(")");
     }
   }
 
@@ -261,7 +254,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ConfigurationRequestMatcher(" + super.toString() + ")");
+      stringBuffer.append("ConfigurationRequestMatcher(").append(super.toString()).append(")");
     }
   }
 
@@ -283,7 +276,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("RequestRequestMatcher(" + super.toString() + ")");
+      stringBuffer.append("RequestRequestMatcher(").append(super.toString()).append(")");
     }
   }
 
@@ -321,7 +314,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ActionRequestSetMatcher(" + actionRequest + ")");
+      stringBuffer.append("ActionRequestSetMatcher(").append(actionRequest).append(")");
     }
   }
 
@@ -364,47 +357,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ComponentRequestSetMatcher(" + serviceComponentRequest + ")");
-    }
-  }
-
-  /**
-   * Matcher for a ConfigurationRequest set containing a single request.
-   */
-  public static class ConfigurationRequestSetMatcher extends HashSet<ConfigurationRequest> implements IArgumentMatcher {
-
-    private final ConfigurationRequest configurationRequest;
-
-    public ConfigurationRequestSetMatcher(String clusterName, String type, String tag, Map<String, String> configs) {
-      this.configurationRequest = new ConfigurationRequest(clusterName, type, tag, configs);
-      add(this.configurationRequest);
-    }
-
-    @Override
-    public boolean matches(Object o) {
-
-      if (!(o instanceof Set)) {
-        return false;
-      }
-
-      Set set = (Set) o;
-
-      if (set.size() != 1) {
-        return false;
-      }
-
-      Object request = set.iterator().next();
-
-      return request instanceof ConfigurationRequest &&
-          eq(((ConfigurationRequest) request).getClusterName(), configurationRequest.getClusterName()) &&
-          eq(((ConfigurationRequest) request).getType(), configurationRequest.getType()) &&
-          eq(((ConfigurationRequest) request).getVersionTag(), configurationRequest.getVersionTag()) &&
-          eq(((ConfigurationRequest) request).getProperties(), configurationRequest.getProperties());
-    }
-
-    @Override
-    public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ConfigurationRequestSetMatcher(" + configurationRequest + ")");
+      stringBuffer.append("ComponentRequestSetMatcher(").append(serviceComponentRequest).append(")");
     }
   }
 
@@ -442,7 +395,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("HostRequestSetMatcher(" + hostRequest + ")");
+      stringBuffer.append("HostRequestSetMatcher(").append(hostRequest).append(")");
     }
   }
 
@@ -488,7 +441,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("HostComponentRequestSetMatcher(" + hostComponentRequest + ")");
+      stringBuffer.append("HostComponentRequestSetMatcher(").append(hostComponentRequest).append(")");
     }
   }
 
@@ -528,7 +481,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("ServiceRequestSetMatcher(" + serviceRequest + ")");
+      stringBuffer.append("ServiceRequestSetMatcher(").append(serviceRequest).append(")");
     }
   }
 
@@ -565,7 +518,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("TaskRequestSetMatcher(" + taskStatusRequest + ")");
+      stringBuffer.append("TaskRequestSetMatcher(").append(taskStatusRequest).append(")");
     }
   }
 
@@ -602,7 +555,7 @@ public class AbstractResourceProviderTes
 
     @Override
     public void appendTo(StringBuffer stringBuffer) {
-      stringBuffer.append("UserRequestSetMatcher(" + userRequest + ")");
+      stringBuffer.append("UserRequestSetMatcher(").append(userRequest).append(")");
     }
   }
 

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ActionResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -60,7 +60,7 @@ public class ActionResourceProviderTest 
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -97,7 +97,7 @@ public class ActionResourceProviderTest 
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -135,7 +135,7 @@ public class ActionResourceProviderTest 
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -172,7 +172,7 @@ public class ActionResourceProviderTest 
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -208,7 +208,7 @@ public class ActionResourceProviderTest 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     AbstractResourceProvider provider =
-        (AbstractResourceProvider) AbstractResourceProvider.getResourceProvider(
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.Action,
             propertyIds,
             keyPropertyIds,

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -63,7 +63,7 @@ public class ClusterResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -141,7 +141,7 @@ public class ClusterResourceProviderTest
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -214,7 +214,7 @@ public class ClusterResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -268,8 +268,6 @@ public class ClusterResourceProviderTest
     // replay
     replay(managementController, response);
 
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
-
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
 
     properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100");
@@ -278,15 +276,13 @@ public class ClusterResourceProviderTest
     properties.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "a"), "b");
     properties.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "x"), "y");
 
-    propertySet.add(properties);
-
     // create the request
     Request request = PropertyHelper.getUpdateRequest(properties);
     
     Predicate  predicate = new PredicateBuilder().property(
         ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID).equals("Cluster100").toPredicate();
     
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         Resource.Type.Cluster,
         PropertyHelper.getPropertyIds(Resource.Type.Cluster),
         PropertyHelper.getKeyPropertyIds(Resource.Type.Cluster),
@@ -315,7 +311,7 @@ public class ClusterResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ComponentResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -62,7 +62,7 @@ public class ComponentResourceProviderTe
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -109,7 +109,7 @@ public class ComponentResourceProviderTe
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -162,7 +162,7 @@ public class ComponentResourceProviderTe
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -198,7 +198,7 @@ public class ComponentResourceProviderTe
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ConfigurationResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -109,7 +109,7 @@ public class ConfigurationResourceProvid
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -169,8 +169,7 @@ public class ConfigurationResourceProvid
     assertEquals(2, setRequest.size());
     boolean containsTag1 = false;
     boolean containsTag2 = false;
-    for (Iterator<ConfigurationRequest> iter = setRequest.iterator(); iter.hasNext(); ) {
-      ConfigurationRequest cr = iter.next();
+    for (ConfigurationRequest cr : setRequest) {
       assertNull(cr.getClusterName());
       if (cr.getVersionTag().equals("tag1")) {
         containsTag1 = true;
@@ -215,7 +214,7 @@ public class ConfigurationResourceProvid
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -250,7 +249,7 @@ public class ConfigurationResourceProvid
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/FeedResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/FeedResourceProviderTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/FeedResourceProviderTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/FeedResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,213 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+
+import org.apache.ambari.server.controller.ivory.Feed;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Tests for FeedResourceProvider.
+ */
+public class FeedResourceProviderTest {
+  @Test
+  public void testCreateResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    properties.put(FeedResourceProvider.FEED_NAME_PROPERTY_ID, "Feed1");
+    properties.put(FeedResourceProvider.FEED_DESCRIPTION_PROPERTY_ID, "desc");
+    properties.put(FeedResourceProvider.FEED_SCHEDULE_PROPERTY_ID, "sched");
+    properties.put(FeedResourceProvider.FEED_STATUS_PROPERTY_ID, "SUBMITTED");
+    properties.put(FeedResourceProvider.FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID, "source");
+    properties.put(FeedResourceProvider.FEED_TARGET_CLUSTER_NAME_PROPERTY_ID, "target");
+
+    // set expectations
+    service.submitFeed(FeedResourceProvider.getFeed("Feed1", properties));
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    FeedResourceProvider provider = new FeedResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRFeed),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed));
+
+    provider.createResources(request);
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testGetResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    List<String> feedNames = new LinkedList<String>();
+    feedNames.add("Feed1");
+    feedNames.add("Feed2");
+    feedNames.add("Feed3");
+
+    Feed feed1 = new Feed("Feed1", "d", "s", "sch", "source", "target");
+    Feed feed2 = new Feed("Feed2", "d", "s", "sch", "source", "target");
+    Feed feed3 = new Feed("Feed3", "d", "s", "sch", "source", "target");
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(feedNames);
+
+    expect(service.getFeed("Feed1")).andReturn(feed1);
+    expect(service.getFeed("Feed2")).andReturn(feed2);
+    expect(service.getFeed("Feed3")).andReturn(feed3);
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    FeedResourceProvider provider = new FeedResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRFeed),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed));
+
+    Set<Resource> resources = provider.getResources(request, null);
+
+    Assert.assertEquals(3, resources.size());
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testUpdateResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    properties.put(FeedResourceProvider.FEED_NAME_PROPERTY_ID, "Feed1");
+    properties.put(FeedResourceProvider.FEED_DESCRIPTION_PROPERTY_ID, "desc");
+    properties.put(FeedResourceProvider.FEED_SCHEDULE_PROPERTY_ID, "sched");
+    properties.put(FeedResourceProvider.FEED_STATUS_PROPERTY_ID, "SUBMITTED");
+    properties.put(FeedResourceProvider.FEED_SOURCE_CLUSTER_NAME_PROPERTY_ID, "source");
+    properties.put(FeedResourceProvider.FEED_TARGET_CLUSTER_NAME_PROPERTY_ID, "target");
+
+    List<String> feedNames = new LinkedList<String>();
+    feedNames.add("Feed1");
+
+    Feed feed1 = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(feedNames);
+
+    expect(service.getFeed("Feed1")).andReturn(feed1);
+
+    service.updateFeed(feed1);
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    FeedResourceProvider provider = new FeedResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRFeed),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed));
+
+    provider.updateResources(request, null);
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testDeleteResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    List<String> feedNames = new LinkedList<String>();
+    feedNames.add("Feed1");
+
+    Feed feed1 = new Feed("Feed1", "desc", "SUBMITTED", "sched", "source", "target");
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(feedNames);
+
+    expect(service.getFeed("Feed1")).andReturn(feed1);
+
+    service.deleteFeed("Feed1");
+
+    // replay
+    replay(service);
+
+    FeedResourceProvider provider = new FeedResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRFeed),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed));
+
+    Predicate predicate = new PredicateBuilder().property(FeedResourceProvider.FEED_NAME_PROPERTY_ID).equals("Feed1").toPredicate();
+
+    provider.deleteResources(predicate);
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testGetKeyPropertyIds() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Map<Resource.Type, String> keyPropertyIds = PropertyHelper.getKeyPropertyIds(Resource.Type.DRFeed);
+
+    FeedResourceProvider provider = new FeedResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRFeed),
+        keyPropertyIds);
+
+    Assert.assertEquals(keyPropertyIds, provider.getKeyPropertyIds());
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostComponentResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -67,7 +67,7 @@ public class HostComponentResourceProvid
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -137,7 +137,7 @@ public class HostComponentResourceProvid
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -196,7 +196,7 @@ public class HostComponentResourceProvid
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -250,7 +250,7 @@ public class HostComponentResourceProvid
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -287,7 +287,7 @@ public class HostComponentResourceProvid
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -330,7 +330,7 @@ public class HostComponentResourceProvid
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     AbstractResourceProvider provider =
-        (AbstractResourceProvider) AbstractResourceProvider.getResourceProvider(
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.HostComponent,
             propertyIds,
             keyPropertyIds,

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/HostResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -62,7 +62,7 @@ public class HostResourceProviderTest {
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -116,7 +116,7 @@ public class HostResourceProviderTest {
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -151,7 +151,6 @@ public class HostResourceProviderTest {
   
   @Test
   public void testUpdateDesiredConfig() throws Exception {
-    Resource.Type type = Resource.Type.Host;
 
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
     RequestStatusResponse response = createNiceMock(RequestStatusResponse.class);
@@ -173,7 +172,6 @@ public class HostResourceProviderTest {
     // replay
     replay(managementController, response);
     
-    Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
 
     Map<String, Object> properties = new LinkedHashMap<String, Object>();
 
@@ -185,8 +183,6 @@ public class HostResourceProviderTest {
     properties.put(PropertyHelper.getPropertyId("Hosts.desired_config.properties", "a"), "b");
     properties.put(PropertyHelper.getPropertyId("Hosts.desired_config.properties", "x"), "y");
 
-    propertySet.add(properties);
-
     // create the request
     Request request = PropertyHelper.getUpdateRequest(properties);
     
@@ -194,7 +190,7 @@ public class HostResourceProviderTest {
         equals("Cluster100").
         and().property(HostResourceProvider.HOST_NAME_PROPERTY_ID).equals("Host100").toPredicate();
     
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         Resource.Type.Host,
         PropertyHelper.getPropertyIds(Resource.Type.Host),
         PropertyHelper.getKeyPropertyIds(Resource.Type.Host),
@@ -228,7 +224,7 @@ public class HostResourceProviderTest {
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -263,7 +259,7 @@ public class HostResourceProviderTest {
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),

Added: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/InstanceResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/InstanceResourceProviderTest.java?rev=1458360&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/InstanceResourceProviderTest.java (added)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/InstanceResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -0,0 +1,198 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.controller.internal;
+
+
+import org.apache.ambari.server.controller.ivory.Instance;
+import org.apache.ambari.server.controller.ivory.IvoryService;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.utilities.PredicateBuilder;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
+
+/**
+ * Tests for InstanceResourceProvider.
+ */
+public class InstanceResourceProviderTest {
+  @Test
+  public void testCreateResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    InstanceResourceProvider provider = new InstanceResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRInstance),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance));
+
+    try {
+      provider.createResources(request);
+      Assert.fail("Expected UnsupportedOperationException");
+
+    } catch (UnsupportedOperationException e) {
+      // expected
+    }
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testGetResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    List<Instance> instances = new LinkedList<Instance>();
+
+    Instance instance1 = new Instance("Feed1", "Instance1", "s", "st", "et", "d", "l");
+    Instance instance2 = new Instance("Feed1", "Instance2", "s", "st", "et", "d", "l");
+    Instance instance3 = new Instance("Feed1", "Instance3", "s", "st", "et", "d", "l");
+
+    instances.add(instance1);
+    instances.add(instance2);
+    instances.add(instance3);
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(Collections.singletonList("Feed1"));
+    expect(service.getInstances("Feed1")).andReturn(instances);
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    InstanceResourceProvider provider = new InstanceResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRInstance),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance));
+
+    Set<Resource> resources = provider.getResources(request, null);
+
+    Assert.assertEquals(3, resources.size());
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testUpdateResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>();
+
+    Map<String, Object> properties = new HashMap<String, Object>();
+
+    properties.put(InstanceResourceProvider.INSTANCE_FEED_NAME_PROPERTY_ID, "Feed1");
+    properties.put(InstanceResourceProvider.INSTANCE_ID_PROPERTY_ID, "Instance1");
+    properties.put(InstanceResourceProvider.INSTANCE_STATUS_PROPERTY_ID, "SUSPEND");
+    properties.put(InstanceResourceProvider.INSTANCE_START_TIME_PROPERTY_ID, "ST");
+    properties.put(InstanceResourceProvider.INSTANCE_END_TIME_PROPERTY_ID, "ET");
+    properties.put(InstanceResourceProvider.INSTANCE_DETAILS_PROPERTY_ID, "DETAILS");
+    properties.put(InstanceResourceProvider.INSTANCE_LOG_PROPERTY_ID, "log");
+
+    List<Instance> instances = new LinkedList<Instance>();
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(Collections.singletonList("Feed1"));
+    expect(service.getInstances("Feed1")).andReturn(instances);
+
+    // replay
+    replay(service);
+
+    propertySet.add(properties);
+
+    Request request = PropertyHelper.getCreateRequest(propertySet);
+
+    InstanceResourceProvider provider = new InstanceResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRInstance),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance));
+
+    provider.updateResources(request, null);
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testDeleteResources() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Instance instance1 = new Instance("Feed1", "Instance1", "SUBMITTED", "start", "end", "details", "log");
+
+    // set expectations
+    expect(service.getFeedNames()).andReturn(Collections.singletonList("Feed1"));
+    expect(service.getInstances("Feed1")).andReturn(Collections.singletonList(instance1));
+    service.killInstance("Feed1", "Instance1");
+
+    // replay
+    replay(service);
+
+    InstanceResourceProvider provider = new InstanceResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRInstance),
+        PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance));
+
+    Predicate predicate = new PredicateBuilder().property(InstanceResourceProvider.INSTANCE_ID_PROPERTY_ID).equals("Instance1").toPredicate();
+
+    provider.deleteResources(predicate);
+
+    // verify
+    verify(service);
+  }
+
+  @Test
+  public void testGetKeyPropertyIds() throws Exception {
+    IvoryService service = createMock(IvoryService.class);
+
+    Map<Resource.Type, String> keyPropertyIds = PropertyHelper.getKeyPropertyIds(Resource.Type.DRInstance);
+
+    InstanceResourceProvider provider = new InstanceResourceProvider(service,
+        PropertyHelper.getPropertyIds(Resource.Type.DRInstance),
+        keyPropertyIds);
+
+    Assert.assertEquals(keyPropertyIds, provider.getKeyPropertyIds());
+  }
+}

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RequestResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -55,7 +55,7 @@ public class RequestResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -101,7 +101,7 @@ public class RequestResourceProviderTest
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -135,7 +135,7 @@ public class RequestResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -170,7 +170,7 @@ public class RequestResourceProviderTest
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),

Modified: incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java?rev=1458360&r1=1458359&r2=1458360&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java (original)
+++ incubator/ambari/trunk/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ServiceResourceProviderTest.java Tue Mar 19 15:56:11 2013
@@ -63,7 +63,7 @@ public class ServiceResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -120,7 +120,7 @@ public class ServiceResourceProviderTest
     // replay
     replay(managementController);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -190,7 +190,7 @@ public class ServiceResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -226,7 +226,7 @@ public class ServiceResourceProviderTest
     // replay
     replay(managementController, response);
 
-    ResourceProvider provider = AbstractResourceProvider.getResourceProvider(
+    ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider(
         type,
         PropertyHelper.getPropertyIds(type),
         PropertyHelper.getKeyPropertyIds(type),
@@ -268,7 +268,7 @@ public class ServiceResourceProviderTest
     AmbariManagementController managementController = createMock(AmbariManagementController.class);
 
     AbstractResourceProvider provider =
-        (AbstractResourceProvider) AbstractResourceProvider.getResourceProvider(
+        (AbstractResourceProvider) AbstractControllerResourceProvider.getResourceProvider(
             Resource.Type.Service,
             propertyIds,
             keyPropertyIds,



Mime
View raw message