### Question:
AmbariServerConfigurationHandler extends RootServiceComponentConfigurationHandler { @Override public void updateComponentCategory(String categoryName, Map<String, String> properties, boolean removePropertiesIfNotSpecified) throws AmbariException { boolean toBePublished = false; final Iterator<Map.Entry<String, String>> propertiesIterator = properties.entrySet().iterator(); while (propertiesIterator.hasNext()) { Map.Entry<String, String> property = propertiesIterator.next(); AmbariServerConfigurationKey key = AmbariServerConfigurationUtils.getConfigurationKey(categoryName, property.getKey()); if(key == null) { throw new IllegalArgumentException(String.format("Invalid Ambari server configuration key: %s:%s", categoryName, property.getKey())); } if (AmbariServerConfigurationUtils.isPassword(key)) { final String passwordFileOrCredentialStoreAlias = fetchPasswordFileNameOrCredentialStoreAlias(categoryName, property.getKey()); if (StringUtils.isNotBlank(passwordFileOrCredentialStoreAlias)) { if (updatePasswordIfNeeded(categoryName, property.getKey(), property.getValue())) { toBePublished = true; } propertiesIterator.remove(); } } } if (!properties.isEmpty()) { toBePublished = ambariConfigurationDAO.reconcileCategory(categoryName, properties, removePropertiesIfNotSpecified) || toBePublished; } if (toBePublished) { publisher.publish(new AmbariConfigurationChangedEvent(categoryName)); } } @Inject  AmbariServerConfigurationHandler(AmbariConfigurationDAO ambariConfigurationDAO, AmbariEventPublisher publisher, Configuration ambariConfiguration); @Override Map<String, RootServiceComponentConfiguration> getComponentConfigurations(String categoryName); @Override void removeComponentConfiguration(String categoryName); @Override void updateComponentCategory(String categoryName, Map<String, String> properties, boolean removePropertiesIfNotSpecified); @Override OperationResult performOperation(String categoryName, Map<String, String> properties,
                                          boolean mergeExistingProperties, String operation,
                                          Map<String, Object> operationParameters); Map<String, Map<String, String>> getConfigurations(); Map<String, String> getConfigurationProperties(String categoryName);  }### Answer:
@Test public void updateComponentCategory() throws AmbariException { Map<String, String> properties = new HashMap<>(); properties.put(SSO_ENABLED_SERVICES.key(), "SERVICE1"); properties.put(SSO_MANAGE_SERVICES.key(), "true"); AmbariConfigurationDAO ambariConfigurationDAO = createMock(AmbariConfigurationDAO.class); expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(), properties, true)) .andReturn(true).once(); expect(ambariConfigurationDAO.reconcileCategory(SSO_CONFIGURATION.getCategoryName(), properties, false)) .andReturn(true).once(); AmbariEventPublisher publisher = createMock(AmbariEventPublisher.class); publisher.publish(anyObject(AmbariConfigurationChangedEvent.class)); expectLastCall().times(2); Configuration configuration = createMock(Configuration.class); replayAll(); AmbariServerConfigurationHandler handler = new AmbariServerConfigurationHandler(ambariConfigurationDAO, publisher, configuration); handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), properties, false); handler.updateComponentCategory(SSO_CONFIGURATION.getCategoryName(), properties, true); try { handler.updateComponentCategory("invalid category", properties, true); Assert.fail("Expecting IllegalArgumentException to be thrown"); } catch (IllegalArgumentException e) { } verifyAll(); }