You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2017/11/15 17:11:56 UTC
[2/3] ambari git commit: AMBARI-22418. Make Ambari configuration API
consistent with existing API. (rlevas)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
new file mode 100644
index 0000000..ea9cf4f
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentConfigurationResourceProvider.java
@@ -0,0 +1,476 @@
+/*
+ * 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 java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.ambari.server.AmbariException;
+import org.apache.ambari.server.controller.RootComponent;
+import org.apache.ambari.server.controller.RootService;
+import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
+import org.apache.ambari.server.controller.spi.NoSuchResourceException;
+import org.apache.ambari.server.controller.spi.Predicate;
+import org.apache.ambari.server.controller.spi.Request;
+import org.apache.ambari.server.controller.spi.RequestStatus;
+import org.apache.ambari.server.controller.spi.Resource;
+import org.apache.ambari.server.controller.spi.ResourceAlreadyExistsException;
+import org.apache.ambari.server.controller.spi.SystemException;
+import org.apache.ambari.server.controller.spi.UnsupportedPropertyException;
+import org.apache.ambari.server.controller.utilities.PredicateHelper;
+import org.apache.ambari.server.controller.utilities.PropertyHelper;
+import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
+import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
+import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
+import org.apache.ambari.server.orm.entities.AmbariConfigurationEntity;
+import org.apache.ambari.server.security.authorization.RoleAuthorization;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.inject.Inject;
+
+public class RootServiceComponentConfigurationResourceProvider extends AbstractAuthorizedResourceProvider {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(RootServiceComponentConfigurationResourceProvider.class);
+
+ static final String RESOURCE_KEY = "Configuration";
+
+ static final String CONFIGURATION_CATEGORY_PROPERTY_ID = PropertyHelper.getPropertyId(RESOURCE_KEY, "category");
+ static final String CONFIGURATION_PROPERTIES_PROPERTY_ID = PropertyHelper.getPropertyId(RESOURCE_KEY, "properties");
+ static final String CONFIGURATION_COMPONENT_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(RESOURCE_KEY, "component_name");
+ static final String CONFIGURATION_SERVICE_NAME_PROPERTY_ID = PropertyHelper.getPropertyId(RESOURCE_KEY, "service_name");
+
+ private static final Set<String> PROPERTIES;
+
+ private static final Map<Resource.Type, String> PK_PROPERTY_MAP;
+
+ private static final Set<String> PK_PROPERTY_IDS;
+
+ static {
+ Set<String> set = new HashSet<>();
+ set.add(CONFIGURATION_SERVICE_NAME_PROPERTY_ID);
+ set.add(CONFIGURATION_COMPONENT_NAME_PROPERTY_ID);
+ set.add(CONFIGURATION_CATEGORY_PROPERTY_ID);
+ set.add(CONFIGURATION_PROPERTIES_PROPERTY_ID);
+
+ PROPERTIES = Collections.unmodifiableSet(set);
+
+ Map<Resource.Type, String> map = new HashMap<>();
+ map.put(Resource.Type.RootService, CONFIGURATION_SERVICE_NAME_PROPERTY_ID);
+ map.put(Resource.Type.RootServiceComponent, CONFIGURATION_COMPONENT_NAME_PROPERTY_ID);
+ map.put(Resource.Type.RootServiceComponentConfiguration, CONFIGURATION_CATEGORY_PROPERTY_ID);
+
+ PK_PROPERTY_MAP = Collections.unmodifiableMap(map);
+ PK_PROPERTY_IDS = Collections.unmodifiableSet(new HashSet<>(PK_PROPERTY_MAP.values()));
+ }
+
+ @Inject
+ private AmbariConfigurationDAO ambariConfigurationDAO;
+
+ @Inject
+ private AmbariEventPublisher publisher;
+
+ public RootServiceComponentConfigurationResourceProvider() {
+ super(PROPERTIES, PK_PROPERTY_MAP);
+
+ Set<RoleAuthorization> authorizations = EnumSet.of(RoleAuthorization.AMBARI_MANAGE_CONFIGURATION);
+ setRequiredCreateAuthorizations(authorizations);
+ setRequiredDeleteAuthorizations(authorizations);
+ setRequiredUpdateAuthorizations(authorizations);
+ setRequiredGetAuthorizations(authorizations);
+ }
+
+ @Override
+ protected Set<String> getPKPropertyIds() {
+ return PK_PROPERTY_IDS;
+ }
+
+ @Override
+ public RequestStatus createResourcesAuthorized(Request request)
+ throws SystemException, UnsupportedPropertyException, ResourceAlreadyExistsException, NoSuchParentResourceException {
+
+ createOrAddProperties(null, null, null, request.getProperties(), true);
+
+ return getRequestStatus(null);
+ }
+
+ @Override
+ protected Set<Resource> getResourcesAuthorized(Request request, Predicate predicate) throws SystemException,
+ UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+
+ return getResources(new Command<Set<Resource>>() {
+ @Override
+ public Set<Resource> invoke() throws AmbariException {
+ Set<Resource> resources = new HashSet<>();
+ Set<String> requestedIds = getRequestPropertyIds(request, predicate);
+
+ if (CollectionUtils.isEmpty(requestedIds)) {
+ requestedIds = PROPERTIES;
+ }
+
+ if (predicate == null) {
+ Set<Resource> _resources;
+ try {
+ _resources = getConfigurationResources(requestedIds, null);
+ } catch (NoSuchResourceException e) {
+ throw new AmbariException(e.getMessage(), e);
+ }
+
+ if (!CollectionUtils.isEmpty(_resources)) {
+ resources.addAll(_resources);
+ }
+ } else {
+ for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) {
+ Set<Resource> _resources;
+ try {
+ _resources = getConfigurationResources(requestedIds, propertyMap);
+ } catch (NoSuchResourceException e) {
+ throw new AmbariException(e.getMessage(), e);
+ }
+
+ if (!CollectionUtils.isEmpty(_resources)) {
+ resources.addAll(_resources);
+ }
+ }
+ }
+
+ return resources;
+ }
+ });
+ }
+
+
+ @Override
+ protected RequestStatus deleteResourcesAuthorized(Request request, Predicate predicate) throws SystemException,
+ UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+
+ String serviceName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_SERVICE_NAME_PROPERTY_ID);
+ String componentName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_COMPONENT_NAME_PROPERTY_ID);
+ String categoryName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_CATEGORY_PROPERTY_ID);
+
+ ConfigurationHandler handler = getConfigurationHandler(serviceName, componentName);
+ if (handler != null) {
+ handler.removeConfiguration(categoryName);
+ } else {
+ throw new SystemException(String.format("Configurations may not be updated for the %s component of the root service %s", componentName, serviceName));
+ }
+
+ return getRequestStatus(null);
+ }
+
+ @Override
+ protected RequestStatus updateResourcesAuthorized(Request request, Predicate predicate)
+ throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException {
+
+ String serviceName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_SERVICE_NAME_PROPERTY_ID);
+ String componentName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_COMPONENT_NAME_PROPERTY_ID);
+ String categoryName = (String) PredicateHelper.getProperties(predicate).get(CONFIGURATION_CATEGORY_PROPERTY_ID);
+
+ createOrAddProperties(serviceName, componentName, categoryName, request.getProperties(), false);
+
+ return getRequestStatus(null);
+ }
+
+ private Resource toResource(String serviceName, String componentName, String categoryName, Map<String, String> properties, Set<String> requestedIds) {
+ Resource resource = new ResourceImpl(Resource.Type.RootServiceComponentConfiguration);
+ setResourceProperty(resource, CONFIGURATION_SERVICE_NAME_PROPERTY_ID, serviceName, requestedIds);
+ setResourceProperty(resource, CONFIGURATION_COMPONENT_NAME_PROPERTY_ID, componentName, requestedIds);
+ setResourceProperty(resource, CONFIGURATION_CATEGORY_PROPERTY_ID, categoryName, requestedIds);
+ setResourceProperty(resource, CONFIGURATION_PROPERTIES_PROPERTY_ID, properties, requestedIds);
+ return resource;
+ }
+
+ /**
+ * Retrieves groups of properties from the request data and create or updates them as needed.
+ * <p>
+ * Each group of properties is expected to have a category (<code>AmbariConfiguration/category</code>)
+ * value and one or more property (<code>AmbariConfiguration/properties/property.name</code>) values.
+ * If a category cannot be determined from the propery set, the default category value (passed in)
+ * is used. If a default category is set, it is assumed that it was parsed from the request predicate
+ * (if availabe).
+ *
+ * @param defaultServiceName the default service name to use if needed
+ * @param defaultComponentName the default component name to use if needed
+ * @param defaultCategoryName the default category to use if needed
+ * @param requestProperties a collection of property maps parsed from the request
+ * @param removePropertiesIfNotSpecified <code>true</code> to remove existing properties that have not been specifed in the request;
+ * <code>false</code> append or update the existing set of properties with values from the request
+ * @throws SystemException if an error occurs saving the configuration data
+ */
+ private void createOrAddProperties(String defaultServiceName, String defaultComponentName, String defaultCategoryName,
+ Set<Map<String, Object>> requestProperties, boolean removePropertiesIfNotSpecified)
+ throws SystemException {
+ // set of resource properties (each entry in the set belongs to a different resource)
+ if (requestProperties != null) {
+ for (Map<String, Object> resourceProperties : requestProperties) {
+ RequestDetails requestDetails = parseProperties(defaultServiceName, defaultComponentName, defaultCategoryName, resourceProperties);
+
+ ConfigurationHandler handler = getConfigurationHandler(requestDetails.serviceName, requestDetails.componentName);
+
+ if (handler != null) {
+ handler.updateCategory(requestDetails.categoryName, requestDetails.properties, removePropertiesIfNotSpecified);
+ } else {
+ throw new SystemException(String.format("Configurations may not be updated for the %s component of the root service, %s", requestDetails.serviceName, requestDetails.componentName));
+ }
+ }
+ }
+ }
+
+ /**
+ * Parse the property map from a request into a map of services to components to category names to maps of property names and values.
+ *
+ * @param defaultServiceName the default service name to use if one is not found in the map of properties
+ * @param defaultComponentName the default component name to use if one is not found in the map of properties
+ * @param defaultCategoryName the default category name to use if one is not found in the map of properties
+ * @param resourceProperties a map of properties from a request item @return a map of category names to maps of name/value pairs
+ * @throws SystemException if an issue with the data is determined
+ */
+ private RequestDetails parseProperties(String defaultServiceName, String defaultComponentName, String defaultCategoryName, Map<String, Object> resourceProperties) throws SystemException {
+ String serviceName = defaultServiceName;
+ String componentName = defaultComponentName;
+ String categoryName = defaultCategoryName;
+ Map<String, String> properties = new HashMap<>();
+
+ for (Map.Entry<String, Object> entry : resourceProperties.entrySet()) {
+ String propertyName = entry.getKey();
+
+ if (CONFIGURATION_CATEGORY_PROPERTY_ID.equals(propertyName)) {
+ if (entry.getValue() instanceof String) {
+ categoryName = (String) entry.getValue();
+ }
+ } else if (CONFIGURATION_COMPONENT_NAME_PROPERTY_ID.equals(propertyName)) {
+ if (entry.getValue() instanceof String) {
+ componentName = (String) entry.getValue();
+ }
+ } else if (CONFIGURATION_SERVICE_NAME_PROPERTY_ID.equals(propertyName)) {
+ if (entry.getValue() instanceof String) {
+ serviceName = (String) entry.getValue();
+ }
+ } else {
+ String propertyCategory = PropertyHelper.getPropertyCategory(entry.getKey());
+ if ((propertyCategory != null) && propertyCategory.equals(CONFIGURATION_PROPERTIES_PROPERTY_ID)) {
+ String name = PropertyHelper.getPropertyName(entry.getKey());
+ Object value = entry.getValue();
+ properties.put(name, (value == null) ? null : value.toString());
+ }
+ }
+ }
+
+ if (StringUtils.isEmpty(serviceName)) {
+ throw new SystemException("The service name must be set");
+ }
+
+ if (StringUtils.isEmpty(componentName)) {
+ throw new SystemException("The component name must be set");
+ }
+
+ if (StringUtils.isEmpty(categoryName)) {
+ throw new SystemException("The configuration category must be set");
+ }
+
+ if (properties.isEmpty()) {
+ throw new SystemException("The configuration properties must be set");
+ }
+
+ return new RequestDetails(serviceName, componentName, categoryName, properties);
+ }
+
+ /**
+ * Retrieves the requested configration resources
+ *
+ * @param requestedIds the requested properties ids
+ * @param propertyMap the request properties
+ * @return a set of resources built from the found data
+ * @throws NoSuchResourceException if the requested resource was not found
+ */
+ private Set<Resource> getConfigurationResources(Set<String> requestedIds, Map<String, Object> propertyMap) throws NoSuchResourceException {
+ Set<Resource> resources = new HashSet<>();
+
+ String serviceName = getStringProperty(propertyMap, CONFIGURATION_SERVICE_NAME_PROPERTY_ID);
+ String componentName = getStringProperty(propertyMap, CONFIGURATION_COMPONENT_NAME_PROPERTY_ID);
+
+ ConfigurationHandler handler = getConfigurationHandler(serviceName, componentName);
+
+ if (handler != null) {
+ String categoryName = getStringProperty(propertyMap, CONFIGURATION_CATEGORY_PROPERTY_ID);
+ Map<String, Map<String, String>> configurations = handler.getConfigurations(categoryName);
+
+ if (configurations != null) {
+ for (Map.Entry<String, Map<String, String>> entry : configurations.entrySet()) {
+ resources.add(toResource(serviceName, componentName, entry.getKey(), entry.getValue(), requestedIds));
+ }
+ }
+ }
+
+ return resources;
+ }
+
+ /**
+ * Returns the internal configuration handler used to support various configuration storage facilites.
+ *
+ * @param serviceName the service name
+ * @param componentName the component name
+ * @return
+ */
+ private ConfigurationHandler getConfigurationHandler(String serviceName, String componentName) {
+ if (RootService.AMBARI.name().equals(serviceName)) {
+ if (RootComponent.AMBARI_SERVER.name().equals(componentName)) {
+ return new AmbariServerConfigurationHandler();
+ }
+ }
+
+ return null;
+ }
+
+
+ private String getStringProperty(Map<String, Object> propertyMap, String propertyId) {
+ String value = null;
+
+ if (propertyMap != null) {
+ Object o = propertyMap.get(propertyId);
+ if (o instanceof String) {
+ value = (String) o;
+ }
+ }
+
+ return value;
+ }
+
+ /**
+ * ConfigurationHandler is an interface to be implemented to support the relevant types of storage
+ * used to persist root-level component configurations.
+ */
+ private abstract class ConfigurationHandler {
+ /**
+ * Retrieve the request configurations.
+ *
+ * @param categoryName the category name (or <code>null</code> for all)
+ * @return a map of category names to properties (name/value pairs).
+ * @throws NoSuchResourceException if the requested data is not found
+ */
+ public abstract Map<String, Map<String, String>> getConfigurations(String categoryName) throws NoSuchResourceException;
+
+ /**
+ * Delete the requested configuration.
+ *
+ * @param categoryName the category name
+ * @throws NoSuchResourceException if the requested category does not exist
+ */
+ public abstract void removeConfiguration(String categoryName) throws NoSuchResourceException;
+
+ /**
+ * Set or update a configuration category with the specified properties.
+ * <p>
+ * If <code>removePropertiesIfNotSpecified</code> is <code>true</code>, the persisted category is to include only the specified properties.
+ * <p>
+ * If <code>removePropertiesIfNotSpecified</code> is <code>false</code>, the persisted category is to include the union of the existing and specified properties.
+ * <p>
+ * In any case, existing property values will be overwritten by the one specified in the property map.
+ *
+ * @param categoryName the category name
+ * @param properties a map of properties to set
+ * @param removePropertiesIfNotSpecified <code>true</code> to ensure the set of properties are only those that have be explicitly specified;
+ * <code>false</code> to update the set of exising properties with the specified set of properties, adding missing properties but not removing any properties
+ */
+ public abstract void updateCategory(String categoryName, Map<String, String> properties, boolean removePropertiesIfNotSpecified);
+ }
+
+ /**
+ * AmbariServerConfigurationHandler handle Ambari server specific configuration properties.
+ */
+ private class AmbariServerConfigurationHandler extends ConfigurationHandler {
+ @Override
+ public Map<String, Map<String, String>> getConfigurations(String categoryName)
+ throws NoSuchResourceException {
+ Map<String, Map<String, String>> configurations = null;
+
+ List<AmbariConfigurationEntity> entities = (categoryName == null)
+ ? ambariConfigurationDAO.findAll()
+ : ambariConfigurationDAO.findByCategory(categoryName);
+
+ if (entities != null) {
+ configurations = new HashMap<>();
+
+ for (AmbariConfigurationEntity entity : entities) {
+ String category = entity.getCategoryName();
+ Map<String, String> properties = configurations.get(category);
+
+ if (properties == null) {
+ properties = new TreeMap<>();
+ configurations.put(category, properties);
+ }
+
+ properties.put(entity.getPropertyName(), entity.getPropertyValue());
+ }
+ }
+
+ return configurations;
+ }
+
+ @Override
+ public void removeConfiguration(String categoryName) throws NoSuchResourceException {
+ if (null == categoryName) {
+ LOGGER.debug("No resource id provided in the request");
+ } else {
+ LOGGER.debug("Deleting Ambari configuration with id: {}", categoryName);
+ try {
+ if (ambariConfigurationDAO.removeByCategory(categoryName) > 0) {
+ publisher.publish(new AmbariConfigurationChangedEvent(categoryName));
+ }
+ } catch (IllegalStateException e) {
+ throw new NoSuchResourceException(e.getMessage());
+ }
+ }
+ }
+
+ @Override
+ public void updateCategory(String categoryName, Map<String, String> properties, boolean removePropertiesIfNotSpecified) {
+ if (ambariConfigurationDAO.reconcileCategory(categoryName, properties, removePropertiesIfNotSpecified)) {
+ // notify subscribers about the configuration changes
+ publisher.publish(new AmbariConfigurationChangedEvent(categoryName));
+ }
+ }
+ }
+
+ /**
+ * RequestDetails is a container for details parsed from the request.
+ */
+ private class RequestDetails {
+ final String serviceName;
+ final String componentName;
+ final String categoryName;
+ final Map<String, String> properties;
+
+ private RequestDetails(String serviceName, String componentName, String categoryName, Map<String, String> properties) {
+ this.serviceName = serviceName;
+ this.componentName = componentName;
+ this.categoryName = categoryName;
+ this.properties = properties;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentPropertyProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentPropertyProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentPropertyProvider.java
index 433c1fa..b5bbc94 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentPropertyProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentPropertyProvider.java
@@ -29,7 +29,7 @@ import java.util.Set;
import javax.crypto.Cipher;
-import org.apache.ambari.server.controller.RootServiceResponseFactory;
+import org.apache.ambari.server.controller.RootComponent;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.spi.PropertyProvider;
import org.apache.ambari.server.controller.spi.Request;
@@ -126,7 +126,7 @@ public class RootServiceComponentPropertyProvider extends BaseProvider implement
for (Resource resource : resources) {
// If this resource represents the AMBARI_SERVER component, handle it's specific properties...
- if (RootServiceResponseFactory.Components.AMBARI_SERVER.name().equals(resource.getPropertyValue(RootServiceComponentResourceProvider.COMPONENT_NAME_PROPERTY_ID))) {
+ if (RootComponent.AMBARI_SERVER.name().equals(resource.getPropertyValue(RootServiceComponentResourceProvider.COMPONENT_NAME_PROPERTY_ID))) {
// Attempt to fill in the cipher details only if explicitly asked for.
if (requestedIds.contains(JCE_POLICY_PROPERTY_ID) || requestedIds.contains(CIPHER_PROPERTIES_PROPERTY_ID)) {
setCipherDetails(resource, requestedIds);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProvider.java
index 3925aeb..dfca00e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/RootServiceComponentResourceProvider.java
@@ -25,9 +25,9 @@ import java.util.Set;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.controller.AmbariManagementController;
+import org.apache.ambari.server.controller.RootComponent;
import org.apache.ambari.server.controller.RootServiceComponentRequest;
import org.apache.ambari.server.controller.RootServiceComponentResponse;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
import org.apache.ambari.server.controller.spi.NoSuchParentResourceException;
import org.apache.ambari.server.controller.spi.NoSuchResourceException;
import org.apache.ambari.server.controller.spi.Predicate;
@@ -99,7 +99,7 @@ public class RootServiceComponentResourceProvider extends ReadOnlyResourceProvid
setResourceProperty(resource, PROPERTIES_PROPERTY_ID, response.getProperties(), requestedIds);
setResourceProperty(resource, COMPONENT_VERSION_PROPERTY_ID, response.getComponentVersion(), requestedIds);
- if (Components.AMBARI_SERVER.name().equals(response.getComponentName())) {
+ if (RootComponent.AMBARI_SERVER.name().equals(response.getComponentName())) {
setResourceProperty(resource, SERVER_CLOCK_PROPERTY_ID, response.getServerClock(), requestedIds);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
index 7835373..90e0315 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/spi/Resource.java
@@ -110,6 +110,7 @@ public interface Resource {
TaskAttempt,
RootService,
RootServiceComponent,
+ RootServiceComponentConfiguration,
RootServiceHostComponent,
View,
ViewURL,
@@ -160,8 +161,7 @@ public interface Resource {
VersionDefinition,
ClusterKerberosDescriptor,
LoggingQuery,
- RemoteCluster,
- AmbariConfiguration;
+ RemoteCluster;
/**
* Get the {@link Type} that corresponds to this InternalType.
@@ -232,6 +232,7 @@ public interface Resource {
public static final Type TaskAttempt = InternalType.TaskAttempt.getType();
public static final Type RootService = InternalType.RootService.getType();
public static final Type RootServiceComponent = InternalType.RootServiceComponent.getType();
+ public static final Type RootServiceComponentConfiguration = InternalType.RootServiceComponentConfiguration.getType();
public static final Type RootServiceHostComponent = InternalType.RootServiceHostComponent.getType();
public static final Type View = InternalType.View.getType();
public static final Type ViewURL = InternalType.ViewURL.getType();
@@ -283,7 +284,6 @@ public interface Resource {
public static final Type ClusterKerberosDescriptor = InternalType.ClusterKerberosDescriptor.getType();
public static final Type LoggingQuery = InternalType.LoggingQuery.getType();
public static final Type RemoteCluster = InternalType.RemoteCluster.getType();
- public static final Type AmbariConfiguration = InternalType.AmbariConfiguration.getType();
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java
index 266c7e8..7198814 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertReceivedListener.java
@@ -26,8 +26,8 @@ import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.EagerSingleton;
import org.apache.ambari.server.configuration.Configuration;
import org.apache.ambari.server.controller.MaintenanceStateHelper;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootComponent;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.events.AlertEvent;
import org.apache.ambari.server.events.AlertReceivedEvent;
import org.apache.ambari.server.events.AlertStateChangeEvent;
@@ -434,9 +434,9 @@ public class AlertReceivedListener {
String hostName = alert.getHostName();
// AMBARI/AMBARI_SERVER is always a valid service/component combination
- String ambariServiceName = Services.AMBARI.name();
- String ambariServerComponentName = Components.AMBARI_SERVER.name();
- String ambariAgentComponentName = Components.AMBARI_AGENT.name();
+ String ambariServiceName = RootService.AMBARI.name();
+ String ambariServerComponentName = RootComponent.AMBARI_SERVER.name();
+ String ambariAgentComponentName = RootComponent.AMBARI_AGENT.name();
if (ambariServiceName.equals(serviceName) && ambariServerComponentName.equals(componentName)) {
return true;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java
index d5dc530..8701b6d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/events/listeners/alerts/AlertStateChangedListener.java
@@ -24,7 +24,7 @@ import java.util.UUID;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.EagerSingleton;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.events.AlertStateChangeEvent;
import org.apache.ambari.server.events.publishers.AlertEventPublisher;
import org.apache.ambari.server.orm.dao.AlertDispatchDAO;
@@ -67,7 +67,7 @@ import com.google.inject.Singleton;
* <ul>
* <li>If {@link AlertTargetEntity#isEnabled()} is {@code false}
* <li>If the cluster is upgrading or the upgrade is suspended, only
- * {@link Services#AMBARI} alerts will be dispatched.
+ * {@link RootService#AMBARI} alerts will be dispatched.
* </ul>
*/
@Singleton
@@ -230,7 +230,7 @@ public class AlertStateChangedListener {
if (null != cluster.getUpgradeInProgress()) {
// only send AMBARI alerts if in an upgrade
String serviceName = definition.getServiceName();
- if (!StringUtils.equals(serviceName, Services.AMBARI.name())) {
+ if (!StringUtils.equals(serviceName, RootService.AMBARI.name())) {
LOG.debug(
"Skipping alert notifications for {} because the cluster is upgrading",
definition.getDefinitionName(), target);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
index 0c1ec0a..6c466ba 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfiguration.java
@@ -33,7 +33,7 @@ public class AmbariLdapConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(AmbariLdapConfiguration.class);
- private final Map<String, Object> configurationMap;
+ private final Map<String, String> configurationMap;
private Object configValue(AmbariLdapConfigKeys ambariLdapConfigKeys) {
Object value = null;
@@ -45,13 +45,13 @@ public class AmbariLdapConfiguration {
return value;
}
- public void setValueFor(AmbariLdapConfigKeys ambariLdapConfigKeys, Object value) {
+ public void setValueFor(AmbariLdapConfigKeys ambariLdapConfigKeys, String value) {
configurationMap.put(ambariLdapConfigKeys.key(), value);
}
// intentionally package private, instances to be created through the factory
@Inject
- AmbariLdapConfiguration(@Assisted Map<String, Object> configuration) {
+ AmbariLdapConfiguration(@Assisted Map<String, String> configuration) {
this.configurationMap = configuration;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationFactory.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationFactory.java b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationFactory.java
index 2b9f24b..aafd204 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationFactory.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/domain/AmbariLdapConfigurationFactory.java
@@ -30,5 +30,5 @@ public interface AmbariLdapConfigurationFactory {
* @param configuration a map where keys are the configuration properties and values are the configuration values
* @return an AmbariLdapConfiguration instance
*/
- AmbariLdapConfiguration createLdapConfiguration(Map<String, Object> configuration);
+ AmbariLdapConfiguration createLdapConfiguration(Map<String, String> configuration);
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigurationProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigurationProvider.java
index b32d1ed..ac9c1bc 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigurationProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/ldap/service/AmbariLdapConfigurationProvider.java
@@ -84,7 +84,7 @@ public class AmbariLdapConfigurationProvider implements Provider<AmbariLdapConfi
configEntities = ambariConfigurationDAOProvider.get().findByCategory("ldap-configuration");
if (configEntities != null) {
- Map<String, Object> properties = toProperties(configEntities);
+ Map<String, String> properties = toProperties(configEntities);
instance = ldapConfigurationFactory.createLdapConfiguration(properties);
}
@@ -93,8 +93,8 @@ public class AmbariLdapConfigurationProvider implements Provider<AmbariLdapConfi
return instance;
}
- private Map<String, Object> toProperties(List<AmbariConfigurationEntity> configEntities) {
- Map<String, Object> map = new HashMap<>();
+ private Map<String, String> toProperties(List<AmbariConfigurationEntity> configEntities) {
+ Map<String, String> map = new HashMap<>();
for (AmbariConfigurationEntity entity : configEntities) {
map.put(entity.getPropertyName(), entity.getPropertyValue());
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/metadata/AmbariServiceAlertDefinitions.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/metadata/AmbariServiceAlertDefinitions.java b/ambari-server/src/main/java/org/apache/ambari/server/metadata/AmbariServiceAlertDefinitions.java
index 1e20571..d6b0c99 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/metadata/AmbariServiceAlertDefinitions.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/metadata/AmbariServiceAlertDefinitions.java
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootComponent;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.state.alert.AlertDefinition;
import org.apache.ambari.server.state.alert.AlertDefinitionFactory;
import org.slf4j.Logger;
@@ -36,7 +36,7 @@ import com.google.inject.Singleton;
/**
* The {@link AmbariServiceAlertDefinitions} class is used to represent the
* alerts defined in {@code alerts.json} which are for
- * {@link Components#AMBARI_AGENT} and {@link Components#AMBARI_SERVER}. These
+ * {@link RootComponent#AMBARI_AGENT} and {@link RootComponent#AMBARI_SERVER}. These
* alerts are bound to the host and are not part of a cluster or hadoop service.
*/
@Singleton
@@ -67,7 +67,7 @@ public class AmbariServiceAlertDefinitions {
* Gets all of the {@link AlertDefinition}s that exist on the path for all
* agent hosts.
*
- * @return the alerts with {@link Components#AMBARI_AGENT} as the component
+ * @return the alerts with {@link RootComponent#AMBARI_AGENT} as the component
* and {@code AMBARI} as the service.
*/
public List<AlertDefinition> getAgentDefinitions() {
@@ -75,15 +75,15 @@ public class AmbariServiceAlertDefinitions {
return m_agentDefinitions;
}
- m_agentDefinitions = getDefinitions(Components.AMBARI_AGENT);
+ m_agentDefinitions = getDefinitions(RootComponent.AMBARI_AGENT);
return m_agentDefinitions;
}
/**
* Gets all of the {@link AlertDefinition}s that exist on the path for
- * {@link Components#AMBARI_SERVER}.
+ * {@link RootComponent#AMBARI_SERVER}.
*
- * @return the alerts with {@link Components#AMBARI_SERVER} as the component
+ * @return the alerts with {@link RootComponent#AMBARI_SERVER} as the component
* and {@code AMBARI} as the service.
*/
public List<AlertDefinition> getServerDefinitions() {
@@ -91,7 +91,7 @@ public class AmbariServiceAlertDefinitions {
return m_serverDefinitions;
}
- m_serverDefinitions = getDefinitions(Components.AMBARI_SERVER);
+ m_serverDefinitions = getDefinitions(RootComponent.AMBARI_SERVER);
return m_serverDefinitions;
}
@@ -104,7 +104,7 @@ public class AmbariServiceAlertDefinitions {
* @return the alert definitions for {@code AMBARI} service for the given
* component.
*/
- private List<AlertDefinition> getDefinitions(Components component) {
+ private List<AlertDefinition> getDefinitions(RootComponent component) {
List<AlertDefinition> definitions = new ArrayList<>();
InputStream inputStream = ClassLoader.getSystemResourceAsStream("alerts.json");
@@ -112,7 +112,7 @@ public class AmbariServiceAlertDefinitions {
try {
Set<AlertDefinition> allDefinitions = m_factory.getAlertDefinitions(
- reader, Services.AMBARI.name());
+ reader, RootService.AMBARI.name());
String componentName = component.name();
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java
index cda03f3..424910b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDefinitionDAO.java
@@ -25,7 +25,8 @@ import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import org.apache.ambari.server.AmbariException;
-import org.apache.ambari.server.controller.RootServiceResponseFactory;
+import org.apache.ambari.server.controller.RootComponent;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.controller.internal.AlertDefinitionResourceProvider;
import org.apache.ambari.server.events.AlertDefinitionChangedEvent;
import org.apache.ambari.server.events.AlertDefinitionDeleteEvent;
@@ -300,10 +301,10 @@ public class AlertDefinitionDAO {
query.setParameter("clusterId", clusterId);
query.setParameter("serviceName",
- RootServiceResponseFactory.Services.AMBARI.name());
+ RootService.AMBARI.name());
query.setParameter("componentName",
- RootServiceResponseFactory.Components.AMBARI_AGENT.name());
+ RootComponent.AMBARI_AGENT.name());
return daoUtils.selectList(query);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
index 5c6a82f..1746048 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/orm/dao/AlertDispatchDAO.java
@@ -33,7 +33,7 @@ import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.api.query.JpaPredicateVisitor;
import org.apache.ambari.server.api.query.JpaSortBuilder;
import org.apache.ambari.server.controller.AlertNoticeRequest;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.controller.spi.Predicate;
import org.apache.ambari.server.controller.utilities.PredicateHelper;
import org.apache.ambari.server.orm.RequiresSession;
@@ -452,7 +452,7 @@ public class AlertDispatchDAO {
// AMBARI is a special service that we let through, otherwise we need to
// verify that the service exists before we create the default group
- String ambariServiceName = Services.AMBARI.name();
+ String ambariServiceName = RootService.AMBARI.name();
if (!ambariServiceName.equals(serviceName)) {
Cluster cluster = m_clusters.get().getClusterById(clusterId);
Map<String, Service> services = cluster.getServices();
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
index 15f7048..a1c7249 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/alert/AlertDefinitionHash.java
@@ -37,8 +37,8 @@ import org.apache.ambari.server.ClusterNotFoundException;
import org.apache.ambari.server.agent.ActionQueue;
import org.apache.ambari.server.agent.AgentCommand.AgentCommandType;
import org.apache.ambari.server.agent.AlertDefinitionCommand;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootComponent;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
import org.apache.ambari.server.state.Cluster;
@@ -375,8 +375,8 @@ public class AlertDefinitionHash {
return affectedHosts;
}
- String ambariServiceName = Services.AMBARI.name();
- String agentComponentName = Components.AMBARI_AGENT.name();
+ String ambariServiceName = RootService.AMBARI.name();
+ String agentComponentName = RootComponent.AMBARI_AGENT.name();
// intercept host agent alerts; they affect all hosts
if (ambariServiceName.equals(definitionServiceName)
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 9c0b0ca..8f5e4f4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -57,7 +57,7 @@ import org.apache.ambari.server.controller.AmbariSessionManager;
import org.apache.ambari.server.controller.ClusterResponse;
import org.apache.ambari.server.controller.ConfigurationResponse;
import org.apache.ambari.server.controller.MaintenanceStateHelper;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Services;
+import org.apache.ambari.server.controller.RootService;
import org.apache.ambari.server.controller.ServiceConfigVersionResponse;
import org.apache.ambari.server.events.AmbariEvent.AmbariEventType;
import org.apache.ambari.server.events.ClusterConfigChangedEvent;
@@ -2050,7 +2050,7 @@ public class ClusterImpl implements Cluster {
// server-side events either don't have a service name or are AMBARI;
// either way they are not handled by this method since it expects a
// real service and component
- if (StringUtils.isBlank(serviceName) || Services.AMBARI.name().equals(serviceName)) {
+ if (StringUtils.isBlank(serviceName) || RootService.AMBARI.name().equals(serviceName)) {
continue;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/main/java/org/apache/ambari/server/state/services/AmbariServerAlertService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AmbariServerAlertService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AmbariServerAlertService.java
index d3237a9..305f693 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/services/AmbariServerAlertService.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/services/AmbariServerAlertService.java
@@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.ambari.server.AmbariService;
import org.apache.ambari.server.alerts.AlertRunnable;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
+import org.apache.ambari.server.controller.RootComponent;
import org.apache.ambari.server.orm.dao.AlertDefinitionDAO;
import org.apache.ambari.server.orm.entities.AlertDefinitionEntity;
import org.apache.ambari.server.state.Cluster;
@@ -133,7 +133,7 @@ public class AmbariServerAlertService extends AbstractScheduledService {
/**
* {@inheritDoc}
* <p/>
- * Compares all known {@link Components#AMBARI_SERVER} alerts with those that
+ * Compares all known {@link RootComponent#AMBARI_SERVER} alerts with those that
* are scheduled. If any are not scheduled or have their intervals changed,
* then reschedule those.
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
index 959db15..2afbf8a 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/api/services/stackadvisor/commands/StackAdvisorCommandTest.java
@@ -301,9 +301,9 @@ public class StackAdvisorCommandTest {
"items",
list(
map(
- "AmbariConfiguration",
+ "Configuration",
map(
- "data", list(ldapConfigData)
+ "properties", ldapConfigData
)
)
)
@@ -380,7 +380,7 @@ public class StackAdvisorCommandTest {
"items",
list(
map(
- "AmbariConfiguration",
+ "Configuration",
map(
"data",
list(ldapConfigData, ldapConfigData)
@@ -417,7 +417,7 @@ public class StackAdvisorCommandTest {
.build();
Map<String, Object> ldapConfig = map(
- "AmbariConfiguration",
+ "Configuration",
map(
"data",
list(
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index 7094caa..d95dcef 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -8248,13 +8248,13 @@ public class AmbariManagementControllerTest {
RootServiceRequest request = new RootServiceRequest(null);
Set<RootServiceResponse> responses = controller.getRootServices(Collections.singleton(request));
- Assert.assertEquals(RootServiceResponseFactory.Services.values().length, responses.size());
+ Assert.assertEquals(RootService.values().length, responses.size());
- RootServiceRequest requestWithParams = new RootServiceRequest(RootServiceResponseFactory.Services.AMBARI.toString());
+ RootServiceRequest requestWithParams = new RootServiceRequest(RootService.AMBARI.toString());
Set<RootServiceResponse> responsesWithParams = controller.getRootServices(Collections.singleton(requestWithParams));
Assert.assertEquals(1, responsesWithParams.size());
for (RootServiceResponse responseWithParams: responsesWithParams) {
- Assert.assertEquals(responseWithParams.getServiceName(), RootServiceResponseFactory.Services.AMBARI.toString());
+ Assert.assertEquals(responseWithParams.getServiceName(), RootService.AMBARI.toString());
}
RootServiceRequest invalidRequest = new RootServiceRequest(NON_EXT_VALUE);
@@ -8268,18 +8268,18 @@ public class AmbariManagementControllerTest {
@Test
public void testGetRootServiceComponents() throws Exception {
- RootServiceComponentRequest request = new RootServiceComponentRequest(RootServiceResponseFactory.Services.AMBARI.toString(), null);
+ RootServiceComponentRequest request = new RootServiceComponentRequest(RootService.AMBARI.toString(), null);
Set<RootServiceComponentResponse> responses = controller.getRootServiceComponents(Collections.singleton(request));
- Assert.assertEquals(RootServiceResponseFactory.Services.AMBARI.getComponents().length, responses.size());
+ Assert.assertEquals(RootService.AMBARI.getComponents().length, responses.size());
RootServiceComponentRequest requestWithParams = new RootServiceComponentRequest(
- RootServiceResponseFactory.Services.AMBARI.toString(),
- RootServiceResponseFactory.Services.AMBARI.getComponents()[0].toString());
+ RootService.AMBARI.toString(),
+ RootService.AMBARI.getComponents()[0].toString());
Set<RootServiceComponentResponse> responsesWithParams = controller.getRootServiceComponents(Collections.singleton(requestWithParams));
Assert.assertEquals(1, responsesWithParams.size());
for (RootServiceComponentResponse responseWithParams: responsesWithParams) {
- Assert.assertEquals(responseWithParams.getComponentName(), RootServiceResponseFactory.Services.AMBARI.getComponents()[0].toString());
+ Assert.assertEquals(responseWithParams.getComponentName(), RootService.AMBARI.getComponents()[0].toString());
}
RootServiceComponentRequest invalidRequest = new RootServiceComponentRequest(NON_EXT_VALUE, NON_EXT_VALUE);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
index c27ef7e..e194115 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/RootServiceResponseFactoryTest.java
@@ -29,7 +29,6 @@ import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.H2DatabaseCleaner;
import org.apache.ambari.server.ObjectNotFoundException;
import org.apache.ambari.server.api.services.AmbariMetaInfo;
-import org.apache.ambari.server.controller.RootServiceResponseFactory.Components;
import org.apache.ambari.server.orm.GuiceJpaInitializer;
import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
import org.junit.After;
@@ -66,13 +65,13 @@ public class RootServiceResponseFactoryTest {
// Request a null service name
RootServiceRequest request = new RootServiceRequest(null);
Set<RootServiceResponse> rootServices = responseFactory.getRootServices(request);
- assertEquals(RootServiceResponseFactory.Services.values().length,
+ assertEquals(RootService.values().length,
rootServices.size());
// null request
request = null;
rootServices = responseFactory.getRootServices(request);
- assertEquals(RootServiceResponseFactory.Services.values().length,
+ assertEquals(RootService.values().length,
rootServices.size());
// Request nonexistent service
@@ -85,12 +84,12 @@ public class RootServiceResponseFactoryTest {
// Request existent service
request = new RootServiceRequest(
- RootServiceResponseFactory.Services.AMBARI.name());
+ RootService.AMBARI.name());
rootServices = responseFactory.getRootServices(request);
assertEquals(1, rootServices.size());
assertTrue(rootServices.contains(new RootServiceResponse(
- RootServiceResponseFactory.Services.AMBARI.name())));
+ RootService.AMBARI.name())));
}
@Test
@@ -106,7 +105,7 @@ public class RootServiceResponseFactoryTest {
assertTrue(e instanceof ObjectNotFoundException);
}
- RootServiceResponseFactory.Components ambariServerComponent = RootServiceResponseFactory.Components.AMBARI_SERVER;
+ RootComponent ambariServerComponent = RootComponent.AMBARI_SERVER;
// Request null service name, not-null component name
request = new RootServiceComponentRequest(null, ambariServerComponent.name());
@@ -118,18 +117,18 @@ public class RootServiceResponseFactoryTest {
}
// Request existent service name, null component name
- String serviceName = RootServiceResponseFactory.Services.AMBARI.name();
+ String serviceName = RootService.AMBARI.name();
request = new RootServiceComponentRequest(serviceName, null);
rootServiceComponents = responseFactory.getRootServiceComponents(request);
assertEquals(
- RootServiceResponseFactory.Services.AMBARI.getComponents().length,
+ RootService.AMBARI.getComponents().length,
rootServiceComponents.size());
String ambariVersion = ambariMetaInfo.getServerVersion();
- for (int i = 0; i < RootServiceResponseFactory.Services.AMBARI.getComponents().length; i++) {
- Components component = RootServiceResponseFactory.Services.AMBARI.getComponents()[i];
+ for (int i = 0; i < RootService.AMBARI.getComponents().length; i++) {
+ RootComponent component = RootService.AMBARI.getComponents()[i];
if (component.name().equals(ambariServerComponent.name())) {
for (RootServiceComponentResponse response : rootServiceComponents) {
@@ -148,14 +147,14 @@ public class RootServiceResponseFactoryTest {
// Request existent service name, existent component name
request = new RootServiceComponentRequest(
- RootServiceResponseFactory.Services.AMBARI.name(),
- RootServiceResponseFactory.Services.AMBARI.getComponents()[0].name());
+ RootService.AMBARI.name(),
+ RootService.AMBARI.getComponents()[0].name());
rootServiceComponents = responseFactory.getRootServiceComponents(request);
assertEquals(1, rootServiceComponents.size());
for (RootServiceComponentResponse response : rootServiceComponents) {
if (response.getComponentName().equals(
- RootServiceResponseFactory.Services.AMBARI.getComponents()[0].name())) {
+ RootService.AMBARI.getComponents()[0].name())) {
assertEquals(ambariVersion, response.getComponentVersion());
assertEquals(2, response.getProperties().size());
assertTrue(response.getProperties().containsKey("jdk_location"));
@@ -166,7 +165,7 @@ public class RootServiceResponseFactoryTest {
// Request existent service name, and component, not belongs to requested
// service
request = new RootServiceComponentRequest(
- RootServiceResponseFactory.Services.AMBARI.name(), "XXX");
+ RootService.AMBARI.name(), "XXX");
try {
rootServiceComponents = responseFactory.getRootServiceComponents(request);
http://git-wip-us.apache.org/repos/asf/ambari/blob/3f2743b5/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariConfigurationResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariConfigurationResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariConfigurationResourceProviderTest.java
deleted file mode 100644
index a2ecb27..0000000
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/AmbariConfigurationResourceProviderTest.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Licensed 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 static org.apache.ambari.server.controller.internal.AmbariConfigurationResourceProvider.AMBARI_CONFIGURATION_CATEGORY_PROPERTY_ID;
-import static org.apache.ambari.server.controller.internal.AmbariConfigurationResourceProvider.AMBARI_CONFIGURATION_PROPERTIES_PROPERTY_ID;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.capture;
-import static org.easymock.EasyMock.eq;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.newCapture;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import javax.persistence.EntityManager;
-
-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.spi.ResourceProvider;
-import org.apache.ambari.server.controller.utilities.PredicateBuilder;
-import org.apache.ambari.server.events.AmbariConfigurationChangedEvent;
-import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
-import org.apache.ambari.server.orm.dao.AmbariConfigurationDAO;
-import org.apache.ambari.server.orm.entities.AmbariConfigurationEntity;
-import org.apache.ambari.server.security.TestAuthenticationFactory;
-import org.apache.ambari.server.security.authorization.AuthorizationException;
-import org.easymock.Capture;
-import org.easymock.EasyMockSupport;
-import org.junit.After;
-import org.junit.Test;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-public class AmbariConfigurationResourceProviderTest extends EasyMockSupport {
-
- private static final String CATEGORY_NAME_1 = "test-category-1";
- private static final String CATEGORY_NAME_2 = "test-category-2";
-
- @After
- public void clearAuthentication() {
- SecurityContextHolder.getContext().setAuthentication(null);
- }
-
- @Test
- public void testCreateResources_Administrator() throws Exception {
- testCreateResources(TestAuthenticationFactory.createAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testCreateResources_ClusterAdministrator() throws Exception {
- testCreateResources(TestAuthenticationFactory.createClusterAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testCreateResources_ClusterOperator() throws Exception {
- testCreateResources(TestAuthenticationFactory.createClusterOperator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testCreateResources_ServiceAdministrator() throws Exception {
- testCreateResources(TestAuthenticationFactory.createServiceAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testCreateResources_ServiceOperator() throws Exception {
- testCreateResources(TestAuthenticationFactory.createServiceOperator());
- }
-
- private void testCreateResources(Authentication authentication) throws Exception {
- Injector injector = createInjector();
-
- ResourceProvider resourceProvider = injector.getInstance(AmbariConfigurationResourceProvider.class);
-
- Set<Map<String, Object>> propertySets = new HashSet<>();
-
- Map<String, String> properties1 = new HashMap<>();
- properties1.put("property1a", "value1");
- properties1.put("property2a", "value2");
- propertySets.add(toRequestProperties(CATEGORY_NAME_1, properties1));
-
- Map<String, String> properties2 = new HashMap<>();
- properties2.put("property1b", "value1");
- properties2.put("property2b", "value2");
- propertySets.add(toRequestProperties(CATEGORY_NAME_2, properties2));
-
- Request request = createMock(Request.class);
- expect(request.getProperties()).andReturn(propertySets).once();
-
- Capture<Map<String, String>> capturedProperties1 = newCapture();
- Capture<Map<String, String>> capturedProperties2 = newCapture();
-
- AmbariConfigurationDAO dao = injector.getInstance(AmbariConfigurationDAO.class);
- expect(dao.reconcileCategory(eq(CATEGORY_NAME_1), capture(capturedProperties1), eq(true)))
- .andReturn(true)
- .once();
- expect(dao.reconcileCategory(eq(CATEGORY_NAME_2), capture(capturedProperties2), eq(true)))
- .andReturn(true)
- .once();
-
- AmbariEventPublisher publisher = injector.getInstance(AmbariEventPublisher.class);
- publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
- expectLastCall().times(2);
-
- replayAll();
-
- SecurityContextHolder.getContext().setAuthentication(authentication);
-
- resourceProvider.createResources(request);
-
- verifyAll();
-
- validateCapturedProperties(properties1, capturedProperties1);
- validateCapturedProperties(properties2, capturedProperties2);
- }
-
- @Test
- public void testDeleteResources_Administrator() throws Exception {
- testDeleteResources(TestAuthenticationFactory.createAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testDeleteResources_ClusterAdministrator() throws Exception {
- testDeleteResources(TestAuthenticationFactory.createClusterAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testDeleteResources_ClusterOperator() throws Exception {
- testDeleteResources(TestAuthenticationFactory.createClusterOperator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testDeleteResources_ServiceAdministrator() throws Exception {
- testDeleteResources(TestAuthenticationFactory.createServiceAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testDeleteResources_ServiceOperator() throws Exception {
- testDeleteResources(TestAuthenticationFactory.createServiceOperator());
- }
-
- private void testDeleteResources(Authentication authentication) throws Exception {
- Injector injector = createInjector();
-
- ResourceProvider resourceProvider = injector.getInstance(AmbariConfigurationResourceProvider.class);
-
- Predicate predicate = new PredicateBuilder()
- .property(AMBARI_CONFIGURATION_CATEGORY_PROPERTY_ID)
- .equals(CATEGORY_NAME_1)
- .toPredicate();
-
- Request request = createMock(Request.class);
-
- AmbariConfigurationDAO dao = injector.getInstance(AmbariConfigurationDAO.class);
- expect(dao.removeByCategory(CATEGORY_NAME_1)).andReturn(1).once();
-
- AmbariEventPublisher publisher = injector.getInstance(AmbariEventPublisher.class);
- publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
- expectLastCall().once();
-
- replayAll();
-
- SecurityContextHolder.getContext().setAuthentication(authentication);
-
- resourceProvider.deleteResources(request, predicate);
-
- verifyAll();
- }
-
- @Test
- public void testGetResources_Administrator() throws Exception {
- testGetResources(TestAuthenticationFactory.createAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testGetResources_ClusterAdministrator() throws Exception {
- testGetResources(TestAuthenticationFactory.createClusterAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testGetResources_ClusterOperator() throws Exception {
- testGetResources(TestAuthenticationFactory.createClusterOperator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testGetResources_ServiceAdministrator() throws Exception {
- testGetResources(TestAuthenticationFactory.createServiceAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testGetResources_ServiceOperator() throws Exception {
- testGetResources(TestAuthenticationFactory.createServiceOperator());
- }
-
- private void testGetResources(Authentication authentication) throws Exception {
- Injector injector = createInjector();
-
- ResourceProvider resourceProvider = injector.getInstance(AmbariConfigurationResourceProvider.class);
-
- Predicate predicate = new PredicateBuilder()
- .property(AMBARI_CONFIGURATION_CATEGORY_PROPERTY_ID)
- .equals(CATEGORY_NAME_1)
- .toPredicate();
-
- Request request = createMock(Request.class);
- expect(request.getPropertyIds()).andReturn(null).anyTimes();
-
- Map<String, String> properties = new HashMap<>();
- properties.put("property1a", "value1");
- properties.put("property2a", "value2");
-
- AmbariConfigurationDAO dao = injector.getInstance(AmbariConfigurationDAO.class);
- expect(dao.findByCategory(CATEGORY_NAME_1)).andReturn(createEntities(CATEGORY_NAME_1, properties)).once();
-
- replayAll();
-
- SecurityContextHolder.getContext().setAuthentication(authentication);
-
- Set<Resource> response = resourceProvider.getResources(request, predicate);
-
- verifyAll();
-
- junit.framework.Assert.assertNotNull(response);
- junit.framework.Assert.assertEquals(1, response.size());
-
- Resource resource = response.iterator().next();
- junit.framework.Assert.assertEquals(Resource.Type.AmbariConfiguration, resource.getType());
-
- Map<String, Map<String, Object>> propertiesMap = resource.getPropertiesMap();
- junit.framework.Assert.assertEquals(2, propertiesMap.size());
-
- junit.framework.Assert.assertEquals(CATEGORY_NAME_1, propertiesMap.get(Resource.Type.AmbariConfiguration.name()).get("category"));
-
- Map<String, Object> retrievedProperties = propertiesMap.get(Resource.Type.AmbariConfiguration.name() + "/properties");
- junit.framework.Assert.assertEquals(2, retrievedProperties.size());
-
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- junit.framework.Assert.assertEquals(entry.getValue(), retrievedProperties.get(entry.getKey()));
- }
- }
-
- @Test
- public void testUpdateResources_Administrator() throws Exception {
- testUpdateResources(TestAuthenticationFactory.createAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testUpdateResources_ClusterAdministrator() throws Exception {
- testUpdateResources(TestAuthenticationFactory.createClusterAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testUpdateResources_ClusterOperator() throws Exception {
- testUpdateResources(TestAuthenticationFactory.createClusterOperator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testUpdateResources_ServiceAdministrator() throws Exception {
- testUpdateResources(TestAuthenticationFactory.createServiceAdministrator());
- }
-
- @Test(expected = AuthorizationException.class)
- public void testUpdateResources_ServiceOperator() throws Exception {
- testUpdateResources(TestAuthenticationFactory.createServiceOperator());
- }
-
- private void testUpdateResources(Authentication authentication) throws Exception {
- Injector injector = createInjector();
-
- ResourceProvider resourceProvider = injector.getInstance(AmbariConfigurationResourceProvider.class);
-
- Predicate predicate = new PredicateBuilder()
- .property(AMBARI_CONFIGURATION_CATEGORY_PROPERTY_ID)
- .equals(CATEGORY_NAME_1)
- .toPredicate();
-
- Set<Map<String, Object>> propertySets = new HashSet<>();
-
- Map<String, String> properties1 = new HashMap<>();
- properties1.put("property1a", "value1");
- properties1.put("property2a", "value2");
- propertySets.add(toRequestProperties(CATEGORY_NAME_1, properties1));
-
- Request request = createMock(Request.class);
- expect(request.getProperties()).andReturn(propertySets).once();
-
- Capture<Map<String, String>> capturedProperties1 = newCapture();
-
- AmbariConfigurationDAO dao = injector.getInstance(AmbariConfigurationDAO.class);
- expect(dao.reconcileCategory(eq(CATEGORY_NAME_1), capture(capturedProperties1), eq(false)))
- .andReturn(true)
- .once();
-
- AmbariEventPublisher publisher = injector.getInstance(AmbariEventPublisher.class);
- publisher.publish(anyObject(AmbariConfigurationChangedEvent.class));
- expectLastCall().times(1);
-
- replayAll();
-
- SecurityContextHolder.getContext().setAuthentication(authentication);
-
- resourceProvider.updateResources(request, predicate);
-
- verifyAll();
-
- validateCapturedProperties(properties1, capturedProperties1);
- }
-
- private List<AmbariConfigurationEntity> createEntities(String categoryName, Map<String, String> properties) {
- List<AmbariConfigurationEntity> entities = new ArrayList<>();
-
- for (Map.Entry<String, String> property : properties.entrySet()) {
- AmbariConfigurationEntity entity = new AmbariConfigurationEntity();
- entity.setCategoryName(categoryName);
- entity.setPropertyName(property.getKey());
- entity.setPropertyValue(property.getValue());
- entities.add(entity);
- }
-
- return entities;
- }
-
- private Map<String, Object> toRequestProperties(String categoryName1, Map<String, String> properties) {
- Map<String, Object> requestProperties = new HashMap<>();
- requestProperties.put(AMBARI_CONFIGURATION_CATEGORY_PROPERTY_ID, categoryName1);
- for (Map.Entry<String, String> entry : properties.entrySet()) {
- requestProperties.put(AMBARI_CONFIGURATION_PROPERTIES_PROPERTY_ID + "/" + entry.getKey(), entry.getValue());
- }
- return requestProperties;
- }
-
- private void validateCapturedProperties(Map<String, String> expectedProperties, Capture<Map<String, String>> capturedProperties) {
- junit.framework.Assert.assertTrue(capturedProperties.hasCaptured());
-
- Map<String, String> properties = capturedProperties.getValue();
- junit.framework.Assert.assertNotNull(properties);
-
- // Convert the Map to a TreeMap to help with comparisons
- expectedProperties = new TreeMap<>(expectedProperties);
- properties = new TreeMap<>(properties);
- junit.framework.Assert.assertEquals(expectedProperties, properties);
- }
-
- private Injector createInjector() throws Exception {
- return Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(EntityManager.class).toInstance(createNiceMock(EntityManager.class));
- bind(AmbariConfigurationDAO.class).toInstance(createMock(AmbariConfigurationDAO.class));
- bind(AmbariEventPublisher.class).toInstance(createMock(AmbariEventPublisher.class));
- }
- });
- }
-}
\ No newline at end of file