ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jspei...@apache.org
Subject git commit: AMBARI-4277. Update the /stacks api endpoint to use the api framework for consistency.
Date Tue, 14 Jan 2014 19:27:25 GMT
Updated Branches:
  refs/heads/trunk 88ddc9222 -> 589e92d5c


AMBARI-4277.  Update the /stacks api endpoint to use the api framework for consistency.


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

Branch: refs/heads/trunk
Commit: 589e92d5c7023d6afecb84943eae14e18f03959f
Parents: 88ddc92
Author: John Speidel <jspeidel@hortonworks.com>
Authored: Mon Jan 13 11:20:55 2014 -0500
Committer: John Speidel <jspeidel@hortonworks.com>
Committed: Tue Jan 14 14:26:37 2014 -0500

----------------------------------------------------------------------
 .../server/api/services/AmbariMetaService.java  | 115 --------
 .../server/api/services/Stacks2Service.java     | 295 +++++++++++++++++++
 .../server/api/services/StacksService.java      | 127 ++++----
 .../ambari/server/controller/AmbariServer.java  |   2 -
 .../api/services/AmbariMetaServiceTest.java     |  93 ------
 .../server/api/services/Stacks2ServiceTest.java | 216 ++++++++++++++
 .../server/api/services/StacksServiceTest.java  |  82 +++++-
 7 files changed, 653 insertions(+), 277 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaService.java
deleted file mode 100644
index 7a2d2e5..0000000
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/AmbariMetaService.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/**
- * 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 java.io.IOException;
-import java.util.List;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBException;
-
-import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.StackInfo;
-import org.codehaus.jackson.JsonGenerationException;
-import org.codehaus.jackson.map.JsonMappingException;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.codehaus.jackson.map.ser.FilterProvider;
-import org.codehaus.jackson.map.ser.impl.SimpleBeanPropertyFilter;
-import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.inject.Inject;
-
-@Path("/stacks/")
-public class AmbariMetaService {
-  private static AmbariMetaInfo ambariMetainfo;
-  private static Logger LOG = LoggerFactory.getLogger(AmbariMetaService.class);
-
-  @Inject
-  public static void init(AmbariMetaInfo instance) {
-    ambariMetainfo = instance;
-  }
-
-  /**
-   * Filter properties from the service info and others
-   * @param object
-   * @return
-   * @throws IOException
-   * @throws JsonMappingException
-   * @throws JsonGenerationException
-   */
-  public String filterProperties(Object object, boolean ignoreConfigs) throws
-  JsonGenerationException, JsonMappingException, IOException {
-    ObjectMapper mapper = new ObjectMapper();
-    mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
-    mapper.configure(SerializationConfig.Feature.USE_ANNOTATIONS, true);
-    if (ignoreConfigs) {
-    FilterProvider filters = new SimpleFilterProvider().addFilter(
-          "propertiesfilter",
-          SimpleBeanPropertyFilter.serializeAllExcept("properties"));
-      mapper.setFilters(filters);
-    } else {
-      FilterProvider filters = new SimpleFilterProvider().addFilter(
-          "propertiesfilter", SimpleBeanPropertyFilter.serializeAllExcept());
-      mapper.setFilters(filters);
-    }
-    String json = mapper.writeValueAsString(object);
-    return json;
-  }
-
-  @GET
-  @Produces("text/plain")
-  public Response getStacks() throws JsonGenerationException,
-  JsonMappingException, JAXBException, IOException {
-    List<StackInfo> stackInfos = ambariMetainfo.getSupportedStacks();
-    String output = filterProperties(stackInfos, true);
-    return Response.status(Response.Status.OK).entity(output).build();
-  }
-
-  @GET
-  @Path("{stackName}/version/{versionNumber}")
-  @Produces("text/plain")
-  public Response getStack(@PathParam("stackName") String stackName,
-      @PathParam("versionNumber") String versionNumber) throws
-      JsonGenerationException, JsonMappingException, JAXBException, IOException  {
-    StackInfo stackInfo = ambariMetainfo.getStackInfo(stackName, versionNumber);
-    String output = filterProperties(stackInfo, true);
-    return Response.status(Response.Status.OK).entity(output).build();
-  }
-
-  @GET
-  @Path("{stackName}/version/{versionNumber}/services/{serviceName}")
-  @Produces("text/plain")
-  public Response getServiceInfo(@PathParam("stackName") String stackName,
-      @PathParam("versionNumber") String versionNumber,
-      @PathParam("serviceName") String serviceName) throws
-      JsonGenerationException, JsonMappingException, JAXBException, IOException  {
-    ServiceInfo serviceInfo = ambariMetainfo.getServiceInfo(stackName,
-        versionNumber, serviceName);
-    String output = filterProperties(serviceInfo, false);
-    return Response.status(Response.Status.OK).entity(output).build();
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
new file mode 100644
index 0000000..7e1204a
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/Stacks2Service.java
@@ -0,0 +1,295 @@
+/**
+ * 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 java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.ambari.server.api.resources.ResourceInstance;
+import org.apache.ambari.server.controller.spi.Resource;
+
+/**
+ * Service for stacks management.
+ */
+@Path("/stacks2/")
+public class Stacks2Service extends BaseService {
+
+  @GET
+  @Produces("text/plain")
+  public Response getStacks(@Context HttpHeaders headers, @Context UriInfo ui) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+      createStackResource(null));
+  }
+
+  @GET
+  @Path("{stackName}")
+  @Produces("text/plain")
+  public Response getStack(@Context HttpHeaders headers, @Context UriInfo ui,
+      @PathParam("stackName") String stackName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackResource(stackName));
+  }
+
+  @GET
+  @Path("{stackName}/versions")
+  @Produces("text/plain")
+  public Response getStackVersions(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackVersionResource(stackName, null));
+  }
+
+  @GET
+  @Path("{stackName}/versions/{stackVersion}")
+  @Produces("text/plain")
+  public Response getStackVersion(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackVersionResource(stackName, stackVersion));
+  }
+
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories")
+  @Produces("text/plain")
+  public Response getRepositories(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("osType") String osType) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createRepositoryResource(stackName, stackVersion, osType, null));
+  }
+
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
+  @Produces("text/plain")
+  public Response getRepository(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("osType") String osType,
+      @PathParam("repoId") String repoId) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createRepositoryResource(stackName, stackVersion, osType, repoId));
+  }
+  
+  @PUT
+  @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
+  @Produces("text/plain")
+  public Response updateRepository(String body, @Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("osType") String osType,
+      @PathParam("repoId") String repoId) {
+
+    return handleRequest(headers, body, ui, Request.Type.PUT,
+        createRepositoryResource(stackName, stackVersion, osType, repoId));
+  }
+  
+
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices")
+  @Produces("text/plain")
+  public Response getStackServices(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackServiceResource(stackName, stackVersion, null));
+  }
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}")
+  @Produces("text/plain")
+  public Response getStackService(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("serviceName") String serviceName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackServiceResource(stackName, stackVersion, serviceName));
+  }
+  
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations")
+  @Produces("text/plain")
+  public Response getStackConfigurations(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("serviceName") String serviceName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackConfigurationResource(stackName, stackVersion, serviceName, null));
+  }
+  
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations/{propertyName}")
+  @Produces("text/plain")
+  public Response getStackConfiguration(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("serviceName") String serviceName,
+      @PathParam("propertyName") String propertyName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackConfigurationResource(stackName, stackVersion, serviceName, propertyName));
+  }
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents")
+  @Produces("text/plain")
+  public Response getServiceComponents(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("serviceName") String serviceName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackServiceComponentResource(stackName, stackVersion, serviceName, null));
+  }
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents/{componentName}")
+  @Produces("text/plain")
+  public Response getServiceComponent(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("serviceName") String serviceName,
+      @PathParam("componentName") String componentName) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createStackServiceComponentResource(stackName, stackVersion, serviceName, componentName));
+  }
+  
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/operatingSystems")
+  @Produces("text/plain")
+  public Response getOperatingSystems(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createOperatingSystemResource(stackName, stackVersion, null));
+  }
+  
+  @GET
+  @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}")
+  @Produces("text/plain")
+  public Response getOperatingSystem(@Context HttpHeaders headers,
+      @Context UriInfo ui, @PathParam("stackName") String stackName,
+      @PathParam("stackVersion") String stackVersion,
+      @PathParam("osType") String osType) {
+
+    return handleRequest(headers, null, ui, Request.Type.GET,
+        createOperatingSystemResource(stackName, stackVersion, osType));
+  }
+  
+  
+  ResourceInstance createOperatingSystemResource(String stackName,
+      String stackVersion, String osType) {
+    
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+    mapIds.put(Resource.Type.OperatingSystem, osType);
+
+    return createResource(Resource.Type.OperatingSystem, mapIds);
+  }
+
+  ResourceInstance createStackServiceComponentResource(
+      String stackName, String stackVersion, String serviceName, String componentName) {
+
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+    mapIds.put(Resource.Type.StackService, serviceName);
+    mapIds.put(Resource.Type.StackServiceComponent, componentName);
+
+    return createResource(Resource.Type.StackServiceComponent, mapIds);
+  }
+
+  ResourceInstance createStackConfigurationResource(String stackName,
+      String stackVersion, String serviceName, String propertyName) {
+    
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+    mapIds.put(Resource.Type.StackService, serviceName);
+    mapIds.put(Resource.Type.StackConfiguration, propertyName);
+
+    return createResource(Resource.Type.StackConfiguration, mapIds);
+  }
+
+  ResourceInstance createStackServiceResource(String stackName,
+      String stackVersion, String serviceName) {
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+    mapIds.put(Resource.Type.StackService, serviceName);
+
+    return createResource(Resource.Type.StackService, mapIds);
+  }
+
+  ResourceInstance createRepositoryResource(String stackName,
+      String stackVersion, String osType, String repoId) {
+
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+    mapIds.put(Resource.Type.OperatingSystem, osType);
+    mapIds.put(Resource.Type.Repository, repoId);
+
+    return createResource(Resource.Type.Repository, mapIds);
+  }
+
+  ResourceInstance createStackVersionResource(String stackName,
+      String stackVersion) {
+    Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
+    mapIds.put(Resource.Type.Stack, stackName);
+    mapIds.put(Resource.Type.StackVersion, stackVersion);
+
+    return createResource(Resource.Type.StackVersion, mapIds);
+  }
+
+  ResourceInstance createStackResource(String stackName) {
+
+    return createResource(Resource.Type.Stack,
+        Collections.singletonMap(Resource.Type.Stack, stackName));
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
index 31c4c31..104d2bc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/api/services/StacksService.java
@@ -38,7 +38,7 @@ import org.apache.ambari.server.controller.spi.Resource;
 /**
  * Service for stacks management.
  */
-@Path("/stacks2/")
+@Path("/stacks/")
 public class StacksService extends BaseService {
 
   @GET
@@ -46,14 +46,14 @@ public class StacksService extends BaseService {
   public Response getStacks(@Context HttpHeaders headers, @Context UriInfo ui) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
-      createStackResource(null));
+        createStackResource(null));
   }
 
   @GET
   @Path("{stackName}")
   @Produces("text/plain")
   public Response getStack(@Context HttpHeaders headers, @Context UriInfo ui,
-      @PathParam("stackName") String stackName) {
+                           @PathParam("stackName") String stackName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackResource(stackName));
@@ -63,7 +63,7 @@ public class StacksService extends BaseService {
   @Path("{stackName}/versions")
   @Produces("text/plain")
   public Response getStackVersions(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName) {
+                                   @Context UriInfo ui, @PathParam("stackName") String stackName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackVersionResource(stackName, null));
@@ -73,21 +73,21 @@ public class StacksService extends BaseService {
   @Path("{stackName}/versions/{stackVersion}")
   @Produces("text/plain")
   public Response getStackVersion(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion) {
+                                  @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                  @PathParam("stackVersion") String stackVersion) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackVersionResource(stackName, stackVersion));
   }
 
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories")
   @Produces("text/plain")
   public Response getRepositories(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("osType") String osType) {
+                                  @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                  @PathParam("stackVersion") String stackVersion,
+                                  @PathParam("osType") String osType) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createRepositoryResource(stackName, stackVersion, osType, null));
@@ -97,132 +97,132 @@ public class StacksService extends BaseService {
   @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
   @Produces("text/plain")
   public Response getRepository(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("osType") String osType,
-      @PathParam("repoId") String repoId) {
+                                @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                @PathParam("stackVersion") String stackVersion,
+                                @PathParam("osType") String osType,
+                                @PathParam("repoId") String repoId) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createRepositoryResource(stackName, stackVersion, osType, repoId));
   }
-  
+
   @PUT
   @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{repoId}")
   @Produces("text/plain")
   public Response updateRepository(String body, @Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("osType") String osType,
-      @PathParam("repoId") String repoId) {
+                                   @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                   @PathParam("stackVersion") String stackVersion,
+                                   @PathParam("osType") String osType,
+                                   @PathParam("repoId") String repoId) {
 
     return handleRequest(headers, body, ui, Request.Type.PUT,
         createRepositoryResource(stackName, stackVersion, osType, repoId));
   }
-  
+
 
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices")
   @Produces("text/plain")
   public Response getStackServices(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion) {
+                                   @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                   @PathParam("stackVersion") String stackVersion) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackServiceResource(stackName, stackVersion, null));
   }
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}")
   @Produces("text/plain")
   public Response getStackService(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("serviceName") String serviceName) {
+                                  @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                  @PathParam("stackVersion") String stackVersion,
+                                  @PathParam("serviceName") String serviceName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackServiceResource(stackName, stackVersion, serviceName));
   }
-  
-  
+
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations")
   @Produces("text/plain")
   public Response getStackConfigurations(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("serviceName") String serviceName) {
+                                         @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                         @PathParam("stackVersion") String stackVersion,
+                                         @PathParam("serviceName") String serviceName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackConfigurationResource(stackName, stackVersion, serviceName, null));
   }
-  
-  
+
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/configurations/{propertyName}")
   @Produces("text/plain")
   public Response getStackConfiguration(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("serviceName") String serviceName,
-      @PathParam("propertyName") String propertyName) {
+                                        @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                        @PathParam("stackVersion") String stackVersion,
+                                        @PathParam("serviceName") String serviceName,
+                                        @PathParam("propertyName") String propertyName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackConfigurationResource(stackName, stackVersion, serviceName, propertyName));
   }
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents")
   @Produces("text/plain")
   public Response getServiceComponents(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("serviceName") String serviceName) {
+                                       @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                       @PathParam("stackVersion") String stackVersion,
+                                       @PathParam("serviceName") String serviceName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackServiceComponentResource(stackName, stackVersion, serviceName, null));
   }
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/stackServices/{serviceName}/serviceComponents/{componentName}")
   @Produces("text/plain")
   public Response getServiceComponent(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("serviceName") String serviceName,
-      @PathParam("componentName") String componentName) {
+                                      @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                      @PathParam("stackVersion") String stackVersion,
+                                      @PathParam("serviceName") String serviceName,
+                                      @PathParam("componentName") String componentName) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createStackServiceComponentResource(stackName, stackVersion, serviceName, componentName));
   }
-  
-  
+
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/operatingSystems")
   @Produces("text/plain")
   public Response getOperatingSystems(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion) {
+                                      @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                      @PathParam("stackVersion") String stackVersion) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createOperatingSystemResource(stackName, stackVersion, null));
   }
-  
+
   @GET
   @Path("{stackName}/versions/{stackVersion}/operatingSystems/{osType}")
   @Produces("text/plain")
   public Response getOperatingSystem(@Context HttpHeaders headers,
-      @Context UriInfo ui, @PathParam("stackName") String stackName,
-      @PathParam("stackVersion") String stackVersion,
-      @PathParam("osType") String osType) {
+                                     @Context UriInfo ui, @PathParam("stackName") String stackName,
+                                     @PathParam("stackVersion") String stackVersion,
+                                     @PathParam("osType") String osType) {
 
     return handleRequest(headers, null, ui, Request.Type.GET,
         createOperatingSystemResource(stackName, stackVersion, osType));
   }
-  
-  
+
+
   ResourceInstance createOperatingSystemResource(String stackName,
-      String stackVersion, String osType) {
-    
+                                                 String stackVersion, String osType) {
+
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Stack, stackName);
     mapIds.put(Resource.Type.StackVersion, stackVersion);
@@ -244,8 +244,8 @@ public class StacksService extends BaseService {
   }
 
   ResourceInstance createStackConfigurationResource(String stackName,
-      String stackVersion, String serviceName, String propertyName) {
-    
+                                                    String stackVersion, String serviceName, String propertyName) {
+
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Stack, stackName);
     mapIds.put(Resource.Type.StackVersion, stackVersion);
@@ -256,7 +256,7 @@ public class StacksService extends BaseService {
   }
 
   ResourceInstance createStackServiceResource(String stackName,
-      String stackVersion, String serviceName) {
+                                              String stackVersion, String serviceName) {
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Stack, stackName);
     mapIds.put(Resource.Type.StackVersion, stackVersion);
@@ -266,7 +266,7 @@ public class StacksService extends BaseService {
   }
 
   ResourceInstance createRepositoryResource(String stackName,
-      String stackVersion, String osType, String repoId) {
+                                            String stackVersion, String osType, String repoId) {
 
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Stack, stackName);
@@ -278,7 +278,7 @@ public class StacksService extends BaseService {
   }
 
   ResourceInstance createStackVersionResource(String stackName,
-      String stackVersion) {
+                                              String stackVersion) {
     Map<Resource.Type, String> mapIds = new HashMap<Resource.Type, String>();
     mapIds.put(Resource.Type.Stack, stackName);
     mapIds.put(Resource.Type.StackVersion, stackVersion);
@@ -293,3 +293,4 @@ public class StacksService extends BaseService {
 
   }
 }
+

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index 8cefa74..e745994 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -34,7 +34,6 @@ import org.apache.ambari.server.agent.rest.AgentResource;
 import org.apache.ambari.server.api.AmbariPersistFilter;
 import org.apache.ambari.server.api.rest.BootStrapResource;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.api.services.AmbariMetaService;
 import org.apache.ambari.server.api.services.KeyService;
 import org.apache.ambari.server.api.services.PersistKeyValueImpl;
 import org.apache.ambari.server.api.services.PersistKeyValueService;
@@ -466,7 +465,6 @@ public class AmbariServer {
     GetResource.init(injector.getInstance(ResourceManager.class));
     PersistKeyValueService.init(injector.getInstance(PersistKeyValueImpl.class));
     KeyService.init(injector.getInstance(PersistKeyValueImpl.class));
-    AmbariMetaService.init(injector.getInstance(AmbariMetaInfo.class));
     BootStrapResource.init(injector.getInstance(BootStrapImpl.class));
     StageUtils.setGson(injector.getInstance(Gson.class));
     WorkflowJsonService.setDBProperties(

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaServiceTest.java
deleted file mode 100644
index f60c08e..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/AmbariMetaServiceTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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 java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import junit.framework.Assert;
-
-import org.apache.ambari.server.state.ServiceInfo;
-import org.apache.ambari.server.state.StackInfo;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
-import org.codehaus.jettison.json.JSONException;
-import org.junit.Test;
-
-import com.google.inject.Injector;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.UniformInterfaceException;
-import com.sun.jersey.api.client.WebResource;
-import com.sun.jersey.api.client.config.ClientConfig;
-import com.sun.jersey.api.client.config.DefaultClientConfig;
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-import com.sun.jersey.test.framework.JerseyTest;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-
-public class AmbariMetaServiceTest extends JerseyTest {
-  static String PACKAGE_NAME = "org.apache.ambari.server.api.services";
-  private static Log LOG = LogFactory.getLog(AmbariMetaService.class);
-  Injector injector;
-  protected Client client;
-  
-  public  AmbariMetaServiceTest() {
-    super(new WebAppDescriptor.Builder(PACKAGE_NAME).servletClass(ServletContainer.class)
-        .initParam("com.sun.jersey.api.json.POJOMappingFeature", "true")
-        .build());
-  }
-
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-    
-    AmbariMetaInfo metainfo = new AmbariMetaInfo(new File("src/test/resources/stacks"), new File("target/version"));
-    metainfo.init();
-    
-    AmbariMetaService.init(metainfo);
-  }
-
-  @Test
-  public void testStacks() throws UniformInterfaceException, JSONException,
-    IOException {
-    ClientConfig clientConfig = new DefaultClientConfig();
-    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
-    client = Client.create(clientConfig);
-    WebResource webResource = client.resource("http://localhost:9998/stacks");
-    
-    String output = webResource.get(String.class);
-    LOG.info("All Stack Info \n" + output);
-    ObjectMapper mapper = new ObjectMapper();
-    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, 
-        false);
-    List<StackInfo> stackInfos = mapper.readValue(output,
-        new TypeReference<List<StackInfo>>(){});
-    StackInfo stackInfo = stackInfos.get(0);
-    Assert.assertEquals("HDP", stackInfo.getName());
-    webResource = client.resource("http://localhost:9998/stacks/" +
-    		"HDP/version/0.1/services/HDFS");
-    output = webResource.get(String.class);
-    ServiceInfo info = mapper.readValue(output, ServiceInfo.class);
-    Assert.assertEquals("HDFS", info.getName());
-  }
-}

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
new file mode 100644
index 0000000..be08abd
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/Stacks2ServiceTest.java
@@ -0,0 +1,216 @@
+/**
+ * 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 StacksService.
+ */
+public class Stacks2ServiceTest extends BaseServiceTest {
+
+  @Override
+  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
+    List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
+
+    //getStack
+    Stacks2Service service = new TestStacksService("stackName", null);
+    Method m = service.getClass().getMethod("getStack", HttpHeaders.class, UriInfo.class, String.class);
+    Object[] args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //getStacks
+    service = new TestStacksService(null, null);
+    m = service.getClass().getMethod("getStacks", HttpHeaders.class, UriInfo.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo()};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //getStackVersion
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getStackVersion", HttpHeaders.class, UriInfo.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    //getStackVersions
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackVersions", HttpHeaders.class, UriInfo.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getRepository
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getRepository", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getRepositories
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getRepositories", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // updateRepository
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("updateRepository", String.class, HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, service, m, args, "body"));
+
+    // getStackService
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackService", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackServices
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackServices", HttpHeaders.class, UriInfo.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackConfiguration
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getStackConfiguration", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "property-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackConfigurations
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackConfigurations", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getServiceComponent
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getServiceComponent", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "component-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getServiceComponents
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getServiceComponents", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getOperationSystem
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getOperatingSystem", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os-type"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getOperationSystems
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getOperatingSystems", HttpHeaders.class, UriInfo.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    return listInvocations;
+  }
+
+  private class TestStacksService extends Stacks2Service {
+
+    private String m_stackId;
+    private String m_stackVersion;
+
+    private TestStacksService(String stackName, String stackVersion) {
+      m_stackId = stackName;
+      m_stackVersion = stackVersion;
+    }
+
+    @Override
+    ResourceInstance createStackResource(String stackName) {
+      assertEquals(m_stackId, stackName);
+      return getTestResource();
+    }
+
+    @Override
+    ResourceInstance createStackVersionResource(String stackName, String stackVersion) {
+      assertEquals(m_stackId, stackName);
+      assertEquals(m_stackVersion, stackVersion);
+      return getTestResource();
+    }
+
+    @Override
+    ResourceInstance createRepositoryResource(String stackName,
+        String stackVersion, String osType, String repoId) {
+
+      return getTestResource();
+    }
+
+    @Override
+    ResourceInstance createStackServiceResource(String stackName,
+        String stackVersion, String serviceName) {
+
+      return getTestResource();
+    }
+
+    ResourceInstance createStackConfigurationResource(String stackName,
+        String stackVersion, String serviceName, String propertyName) {
+
+      return getTestResource();
+    }
+
+    ResourceInstance createStackServiceComponentResource(String stackName,
+        String stackVersion, String serviceName, String componentName) {
+
+      return getTestResource();
+    }
+
+    ResourceInstance createOperatingSystemResource(String stackName, String stackVersion, String osType) {
+      return getTestResource();
+    }
+
+
+    @Override
+    RequestFactory getRequestFactory() {
+      return getTestRequestFactory();
+    }
+
+    @Override
+    protected RequestBodyParser getBodyParser() {
+      return getTestBodyParser();
+    }
+
+    @Override
+    protected ResultSerializer getResultSerializer() {
+      return getTestResultSerializer();
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/589e92d5/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
index 9454993..f8c385f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/StacksServiceTest.java
@@ -40,7 +40,7 @@ public class StacksServiceTest extends BaseServiceTest {
   public List<ServiceTestInvocation> getTestInvocations() throws Exception {
     List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();
 
-    //getStack
+    // getStack
     StacksService service = new TestStacksService("stackName", null);
     Method m = service.getClass().getMethod("getStack", HttpHeaders.class, UriInfo.class, String.class);
     Object[] args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName"};
@@ -52,19 +52,93 @@ public class StacksServiceTest extends BaseServiceTest {
     args = new Object[] {getHttpHeaders(), getUriInfo()};
     listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
 
-    //getStackVersion
+    // getStackVersion
     service = new TestStacksService("stackName", "stackVersion");
     m = service.getClass().getMethod("getStackVersion", HttpHeaders.class, UriInfo.class, String.class, String.class);
     args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
     listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
 
-    //getStackVersions
+    // getStackVersions
     service = new TestStacksService("stackName", null);
     m = service.getClass().getMethod("getStackVersions", HttpHeaders.class, UriInfo.class, String.class);
     args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName"};
     listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
 
-    //todo: other methods
+    // getRepository
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getRepository", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getRepositories
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getRepositories", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // updateRepository
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("updateRepository", String.class, HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class, String.class);
+    args = new Object[] {"body", getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os", "repo-id"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.PUT, service, m, args, "body"));
+
+    // getStackService
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackService", HttpHeaders.class, UriInfo.class, String.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackServices
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackServices", HttpHeaders.class, UriInfo.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackConfiguration
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getStackConfiguration", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "property-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getStackConfigurations
+    service = new TestStacksService("stackName", null);
+    m = service.getClass().getMethod("getStackConfigurations", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getServiceComponent
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getServiceComponent", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name", "component-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getServiceComponents
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getServiceComponents", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "service-name"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getOperationSystem
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getOperatingSystem", HttpHeaders.class, UriInfo.class,
+        String.class, String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion", "os-type"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
+
+    // getOperationSystems
+    service = new TestStacksService("stackName", "stackVersion");
+    m = service.getClass().getMethod("getOperatingSystems", HttpHeaders.class, UriInfo.class,
+        String.class, String.class);
+    args = new Object[] {getHttpHeaders(), getUriInfo(), "stackName", "stackVersion"};
+    listInvocations.add(new ServiceTestInvocation(Request.Type.GET, service, m, args, null));
 
     return listInvocations;
   }


Mime
View raw message