http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java index a386e7f..8ec8603 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/BlueprintResourceProviderTest.java @@ -128,7 +128,7 @@ public class BlueprintResourceProviderTest { } private Map<String, Set<HashMap<String, String>>> getSettingProperties() { - return new HashMap<String, Set<HashMap<String, String>>>(); + return new HashMap<>(); } @Before @@ -191,7 +191,7 @@ public class BlueprintResourceProviderTest { Request request = createMock(Request.class); Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, null); // set expectations @@ -440,7 +440,7 @@ public class BlueprintResourceProviderTest { BlueprintEntity entity = createEntity(getBlueprintTestProperties().iterator().next()); - List<BlueprintEntity> results = new ArrayList<BlueprintEntity>(); + List<BlueprintEntity> results = new ArrayList<>(); results.add(entity); // set expectations @@ -468,7 +468,7 @@ public class BlueprintResourceProviderTest { setConfigurationProperties(testProperties); BlueprintEntity entity = createEntity(testProperties.iterator().next()); - List<BlueprintEntity> results = new ArrayList<BlueprintEntity>(); + List<BlueprintEntity> results = new ArrayList<>(); results.add(entity); // set expectations @@ -495,8 +495,8 @@ public class BlueprintResourceProviderTest { expectLastCall(); replay(dao); - Predicate predicate = new EqualsPredicate<String>( - BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID, BLUEPRINT_NAME); + Predicate predicate = new EqualsPredicate<>( + BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID, BLUEPRINT_NAME); AbstractResourceProviderTest.TestObserver observer = new AbstractResourceProviderTest.TestObserver(); provider.addObserver(observer); @@ -518,7 +518,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); setConfigurationProperties(setProperties); AmbariManagementController managementController = createMock(AmbariManagementController.class); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); Map<String, Set<HashMap<String, String>>> settingProperties = getSettingProperties(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"configurations\":[]}"); Request request = createMock(Request.class); @@ -567,7 +567,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); setConfigurationProperties(setProperties); AmbariManagementController managementController = createMock(AmbariManagementController.class); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); Map<String, Set<HashMap<String, String>>> settingProperties = getSettingProperties(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"configurations\":[{\"configuration-type\":{\"properties\":{\"property\":\"value\"}}}]}"); Request request = createMock(Request.class); @@ -618,7 +618,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); String configurationData = "{\"configurations\":[{\"config-type1\":{\"properties\" :{\"property\":\"property-value\"}}," + "\"config-type2\" : {\"properties_attributes\" : {\"property\" : \"property-value\"}, \"properties\" : {\"property\" : \"property-value\"}}}" + "]}"; @@ -649,7 +649,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); String configurationData = "{\"configurations\":[\"config-type1\", \"config-type2\"]}"; requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, configurationData); @@ -678,7 +678,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> setProperties = getBlueprintTestProperties(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); String configurationData = "{\"configurations\":{\"config-type1\": \"properties\", \"config-type2\": \"properties\"}}"; requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, configurationData); @@ -700,34 +700,34 @@ public class BlueprintResourceProviderTest { } public static Set<Map<String, Object>> getBlueprintTestProperties() { - Map<String, String> mapHostGroupComponentProperties = new HashMap<String, String>(); + Map<String, String> mapHostGroupComponentProperties = new HashMap<>(); mapHostGroupComponentProperties.put(BlueprintResourceProvider.COMPONENT_NAME_PROPERTY_ID, "component1"); - Map<String, String> mapHostGroupComponentProperties2 = new HashMap<String, String>(); + Map<String, String> mapHostGroupComponentProperties2 = new HashMap<>(); mapHostGroupComponentProperties2.put(BlueprintResourceProvider.COMPONENT_NAME_PROPERTY_ID, "component2"); - Set<Map<String, String>> setComponentProperties = new HashSet<Map<String, String>>(); + Set<Map<String, String>> setComponentProperties = new HashSet<>(); setComponentProperties.add(mapHostGroupComponentProperties); setComponentProperties.add(mapHostGroupComponentProperties2); - Set<Map<String, String>> setComponentProperties2 = new HashSet<Map<String, String>>(); + Set<Map<String, String>> setComponentProperties2 = new HashSet<>(); setComponentProperties2.add(mapHostGroupComponentProperties); - Map<String, Object> mapHostGroupProperties = new HashMap<String, Object>(); + Map<String, Object> mapHostGroupProperties = new HashMap<>(); mapHostGroupProperties.put(BlueprintResourceProvider.HOST_GROUP_NAME_PROPERTY_ID, "group1"); mapHostGroupProperties.put(BlueprintResourceProvider.HOST_GROUP_CARDINALITY_PROPERTY_ID, "1"); mapHostGroupProperties.put(BlueprintResourceProvider.COMPONENT_PROPERTY_ID, setComponentProperties); - Map<String, Object> mapHostGroupProperties2 = new HashMap<String, Object>(); + Map<String, Object> mapHostGroupProperties2 = new HashMap<>(); mapHostGroupProperties2.put(BlueprintResourceProvider.HOST_GROUP_NAME_PROPERTY_ID, "group2"); mapHostGroupProperties2.put(BlueprintResourceProvider.HOST_GROUP_CARDINALITY_PROPERTY_ID, "2"); mapHostGroupProperties2.put(BlueprintResourceProvider.COMPONENT_PROPERTY_ID, setComponentProperties2); - Set<Map<String, Object>> setHostGroupProperties = new HashSet<Map<String, Object>>(); + Set<Map<String, Object>> setHostGroupProperties = new HashSet<>(); setHostGroupProperties.add(mapHostGroupProperties); setHostGroupProperties.add(mapHostGroupProperties2); - Map<String, Object> mapProperties = new HashMap<String, Object>(); + Map<String, Object> mapProperties = new HashMap<>(); mapProperties.put(BlueprintResourceProvider.BLUEPRINT_NAME_PROPERTY_ID, BLUEPRINT_NAME); mapProperties.put(BlueprintResourceProvider.STACK_NAME_PROPERTY_ID, "test-stack-name"); mapProperties.put(BlueprintResourceProvider.STACK_VERSION_PROPERTY_ID, "test-stack-version"); @@ -737,22 +737,22 @@ public class BlueprintResourceProviderTest { } public static Map<String, Object> getBlueprintRawBodyProperties() { - return new HashMap<String, Object>(); + return new HashMap<>(); } public static void setConfigurationProperties(Set<Map<String, Object>> properties ) { - Map<String, String> clusterProperties = new HashMap<String, String>(); + Map<String, String> clusterProperties = new HashMap<>(); clusterProperties.put("core-site/properties/fs.trash.interval", "480"); clusterProperties.put("core-site/properties/ipc.client.idlethreshold", "8500"); clusterProperties.put("core-site/properties_attributes/final/ipc.client.idlethreshold", "true"); // single entry in set which was created in getTestProperties Map<String, Object> mapProperties = properties.iterator().next(); - Set<Map<String, String>> configurations = new HashSet<Map<String, String>>(); + Set<Map<String, String>> configurations = new HashSet<>(); configurations.add(clusterProperties); mapProperties.put("configurations", configurations); - Map<String, Object> hostGroupProperties = new HashMap<String, Object>(); + Map<String, Object> hostGroupProperties = new HashMap<>(); hostGroupProperties.put("core-site/my.custom.hg.property", "anything"); Collection<Map<String, Object>> hostGroups = (Collection<Map<String, Object>>) mapProperties.get @@ -849,7 +849,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, Object>> hostGroupProperties = (Set<Map<String, Object>>) properties.get( BlueprintResourceProvider.HOST_GROUP_PROPERTY_ID); - Collection<HostGroupEntity> hostGroups = new ArrayList<HostGroupEntity>(); + Collection<HostGroupEntity> hostGroups = new ArrayList<>(); for (Map<String, Object> groupProperties : hostGroupProperties) { HostGroupEntity hostGroup = new HostGroupEntity(); hostGroups.add(hostGroup); @@ -860,7 +860,7 @@ public class BlueprintResourceProviderTest { Set<Map<String, String>> setComponentProperties = (Set<Map<String, String>>) groupProperties.get( BlueprintResourceProvider.COMPONENT_PROPERTY_ID); - Collection<HostGroupComponentEntity> components = new ArrayList<HostGroupComponentEntity>(); + Collection<HostGroupComponentEntity> components = new ArrayList<>(); for (Map<String, String> compProperties : setComponentProperties) { HostGroupComponentEntity component = new HostGroupComponentEntity(); components.add(component); @@ -879,7 +879,7 @@ public class BlueprintResourceProviderTest { } private Map<String, String> getTestRequestInfoProperties() { - Map<String, String> setPropertiesInfo = new HashMap<String, String>(); + Map<String, String> setPropertiesInfo = new HashMap<>(); String configurationData = "{\"configurations\":[{\"config-type1\":{\"properties\" :{\"property\":\"property-value\"}}}," + "{\"config-type2\" : {\"properties_attributes\" : {\"property\" : \"property-value\"}, \"properties\" : {\"property\" : \"property-value\"}}}" + "]}"; @@ -889,7 +889,7 @@ public class BlueprintResourceProviderTest { @Test public void testPopulateConfigurationEntity_oldSchema() throws Exception { - Map<String, String> configuration = new HashMap<String, String>(); + Map<String, String> configuration = new HashMap<>(); configuration.put("global/property1", "val1"); configuration.put("global/property2", "val2"); BlueprintConfiguration config = new BlueprintConfigEntity(); @@ -912,7 +912,7 @@ public class BlueprintResourceProviderTest { @Test public void testPopulateConfigurationEntity_newSchema() throws Exception { - Map<String, String> configuration = new HashMap<String, String>(); + Map<String, String> configuration = new HashMap<>(); configuration.put("global/properties/property1", "val1"); configuration.put("global/properties/property2", "val2"); configuration.put("global/properties_attributes/final/property1", "true"); @@ -964,7 +964,7 @@ public class BlueprintResourceProviderTest { @Test public void testPopulateConfigurationEntity_configIsEmpty() throws Exception { - Map<String, String> configuration = new HashMap<String, String>(); + Map<String, String> configuration = new HashMap<>(); BlueprintConfiguration config = new BlueprintConfigEntity(); provider.populateConfigurationEntity(configuration, config); @@ -975,7 +975,7 @@ public class BlueprintResourceProviderTest { @Test public void testDecidePopulationStrategy_configIsEmpty() throws Exception { - Map<String, String> configMap = new HashMap<String, String>(); + Map<String, String> configMap = new HashMap<>(); BlueprintConfigPopulationStrategy provisioner = provider.decidePopulationStrategy(configMap); @@ -997,7 +997,7 @@ public class BlueprintResourceProviderTest { @Test public void testDecidePopulationStrategy_withOldSchema() throws Exception { - Map<String, String> configMap = new HashMap<String, String>(); + Map<String, String> configMap = new HashMap<>(); configMap.put("global/hive_database", "db"); BlueprintConfigPopulationStrategy provisioner = @@ -1009,7 +1009,7 @@ public class BlueprintResourceProviderTest { @Test public void testDecidePopulationStrategy_withNewSchema_attributes() throws Exception { - Map<String, String> configMap = new HashMap<String, String>(); + Map<String, String> configMap = new HashMap<>(); configMap.put("global/properties_attributes/final/foo_contact", "true"); BlueprintConfigPopulationStrategy provisioner = @@ -1021,7 +1021,7 @@ public class BlueprintResourceProviderTest { @Test public void testDecidePopulationStrategy_withNewSchema_properties() throws Exception { - Map<String, String> configMap = new HashMap<String, String>(); + Map<String, String> configMap = new HashMap<>(); configMap.put("global/properties/foo_contact", "foo@ffl.dsfds"); BlueprintConfigPopulationStrategy provisioner = @@ -1033,7 +1033,7 @@ public class BlueprintResourceProviderTest { @Test public void testDecidePopulationStrategy_unsupportedSchema() throws Exception { - Map<String, String> configMap = new HashMap<String, String>(); + Map<String, String> configMap = new HashMap<>(); configMap.put("global/properties/lot/foo_contact", "foo@ffl.dsfds"); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage(BlueprintResourceProvider.SCHEMA_IS_NOT_SUPPORTED_MESSAGE);
http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java index cd2f99e..c399a4c 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/CalculatedStatusTest.java @@ -494,7 +494,7 @@ public class CalculatedStatusTest { @Test public void testCalculateStatusCounts() throws Exception { - Collection<HostRoleStatus> hostRoleStatuses = new LinkedList<HostRoleStatus>(); + Collection<HostRoleStatus> hostRoleStatuses = new LinkedList<>(); hostRoleStatuses.add(HostRoleStatus.PENDING); hostRoleStatuses.add(HostRoleStatus.QUEUED); @@ -529,7 +529,7 @@ public class CalculatedStatusTest { @Test public void testCountsWithRepeatHosts() throws Exception { - List<Stage> stages = new ArrayList<Stage>(); + List<Stage> stages = new ArrayList<>(); stages.addAll(getStages(getTaskEntities( HostRoleStatus.COMPLETED, HostRoleStatus.COMPLETED, @@ -697,7 +697,7 @@ public class CalculatedStatusTest { } private Collection<HostRoleCommandEntity> getTaskEntities(HostRoleStatus... statuses) { - Collection<HostRoleCommandEntity> entities = new LinkedList<HostRoleCommandEntity>(); + Collection<HostRoleCommandEntity> entities = new LinkedList<>(); for (int i = 0; i < statuses.length; i++) { HostRoleStatus status = statuses[i]; @@ -712,7 +712,7 @@ public class CalculatedStatusTest { private Collection<StageEntity> getStageEntities(Collection<HostRoleCommandEntity> ... taskCollections) { - Collection<StageEntity> entities = new LinkedList<StageEntity>(); + Collection<StageEntity> entities = new LinkedList<>(); for (Collection<HostRoleCommandEntity> taskEntities : taskCollections) { StageEntity entity = new StageEntity(); @@ -726,7 +726,7 @@ public class CalculatedStatusTest { private Collection<Stage> getStages(Collection<HostRoleCommandEntity> ... taskCollections) { - Collection<Stage> entities = new LinkedList<Stage>(); + Collection<Stage> entities = new LinkedList<>(); for (Collection<HostRoleCommandEntity> taskEntities : taskCollections) { TestStage stage = new TestStage(); @@ -740,7 +740,7 @@ public class CalculatedStatusTest { private class TestStage extends Stage { - private final List<HostRoleCommand> hostRoleCommands = new LinkedList<HostRoleCommand>(); + private final List<HostRoleCommand> hostRoleCommands = new LinkedList<>(); private TestStage() { super(1L, "", "", 1L, "", "", "", "", hostRoleCommandFactory, ecwFactory); http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java index 83414cc..8f0c66f 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProviderTest.java @@ -109,9 +109,9 @@ public class ClientConfigResourceProviderTest { managementController); // add the property map to a set for the request. add more maps for multiple creates - Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); + Set<Map<String, Object>> propertySet = new LinkedHashSet<>(); - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); // add properties to the request map properties.put(ClientConfigResourceProvider.COMPONENT_CLUSTER_NAME_PROPERTY_ID, "c1"); @@ -151,7 +151,7 @@ public class ClientConfigResourceProviderTest { managementController); // add the property map to a set for the request. - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); // create the request Request request = PropertyHelper.getUpdateRequest(properties, null); @@ -200,20 +200,18 @@ public class ClientConfigResourceProviderTest { Runtime runtime = createMock(Runtime.class); Process process = createNiceMock(Process.class); - Map<String, DesiredConfig> desiredConfigMap = new HashMap<String, DesiredConfig>(); + Map<String, DesiredConfig> desiredConfigMap = new HashMap<>(); desiredConfigMap.put("hive-site", desiredConfig); - Map<String, Map<String, String>> allConfigTags = new HashMap<String, Map<String, String>>(); - Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); - Map<String, Map<String, String>> configTags = new HashMap<String, - Map<String, String>>(); - Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, - Map<String, Map<String, String>>>(); + Map<String, Map<String, String>> allConfigTags = new HashMap<>(); + Map<String, Map<String, String>> properties = new HashMap<>(); + Map<String, Map<String, String>> configTags = new HashMap<>(); + Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>(); ClientConfigFileDefinition clientConfigFileDefinition = new ClientConfigFileDefinition(); clientConfigFileDefinition.setDictionaryName("pig-env"); clientConfigFileDefinition.setFileName("pig-env.sh"); clientConfigFileDefinition.setType("env"); - List <ClientConfigFileDefinition> clientConfigFileDefinitionList = new LinkedList<ClientConfigFileDefinition>(); + List <ClientConfigFileDefinition> clientConfigFileDefinitionList = new LinkedList<>(); clientConfigFileDefinitionList.add(clientConfigFileDefinition); ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider( @@ -241,23 +239,23 @@ public class ClientConfigResourceProviderTest { packageFolder = "PIG\\package"; } - HashMap<String, Host> hosts = new HashMap<String, Host>(); + HashMap<String, Host> hosts = new HashMap<>(); hosts.put(hostName, host); - HashMap<String, Service> services = new HashMap<String, Service>(); + HashMap<String, Service> services = new HashMap<>(); services.put(serviceName,service); - HashMap<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>(); + HashMap<String, ServiceComponent> serviceComponentMap = new HashMap<>(); serviceComponentMap.put(componentName,serviceComponent); - HashMap<String, ServiceComponentHost> serviceComponentHosts = new HashMap<String, ServiceComponentHost>(); + HashMap<String, ServiceComponentHost> serviceComponentHosts = new HashMap<>(); serviceComponentHosts.put(componentName, serviceComponentHost); - HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>(); + HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<>(); serviceOsSpecificHashMap.put("key",serviceOsSpecific); ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostname,desiredState, "", null, null, null); - Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>(); + Set<ServiceComponentHostResponse> responses = new LinkedHashSet<>(); responses.add(shr1); - Map<String, String> returnConfigMap = new HashMap<String, String>(); + Map<String, String> returnConfigMap = new HashMap<>(); returnConfigMap.put(Configuration.SERVER_TMP_DIR.getKey(), Configuration.SERVER_TMP_DIR.getDefaultValue()); returnConfigMap.put(Configuration.AMBARI_PYTHON_WRAP.getKey(), Configuration.AMBARI_PYTHON_WRAP.getDefaultValue()); @@ -278,7 +276,7 @@ public class ClientConfigResourceProviderTest { expect(configuration.getAgentStackRetryOnInstallCount()).andReturn("5"); expect(configuration.getExternalScriptThreadPoolSize()).andReturn(Configuration.THREAD_POOL_SIZE_FOR_EXTERNAL_SCRIPT.getDefaultValue()); expect(configuration.getExternalScriptTimeout()).andReturn(Configuration.EXTERNAL_SCRIPT_TIMEOUT.getDefaultValue()); - Map<String,String> props = new HashMap<String, String>(); + Map<String,String> props = new HashMap<>(); props.put("key","value"); expect(clusterConfig.getProperties()).andReturn(props); expect(configHelper.getEffectiveDesiredTags(cluster, null)).andReturn(allConfigTags); @@ -287,12 +285,12 @@ public class ClientConfigResourceProviderTest { expect(cluster.getCurrentStackVersion()).andReturn(stackId); PowerMock.mockStaticPartial(StageUtils.class, "getClusterHostInfo"); - Map<String, Set<String>> clusterHostInfo = new HashMap<String, Set<String>>(); - Set<String> all_hosts = new HashSet<String>(Arrays.asList("Host100","Host101","Host102")); - Set<String> some_hosts = new HashSet<String>(Arrays.asList("0-1","2")); - Set<String> ohter_hosts = new HashSet<String>(Arrays.asList("0,1")); - Set<String> clusterHostTypes = new HashSet<String>(Arrays.asList("nm_hosts", "hs_host", - "namenode_host", "rm_host", "snamenode_host", "slave_hosts", "zookeeper_hosts")); + Map<String, Set<String>> clusterHostInfo = new HashMap<>(); + Set<String> all_hosts = new HashSet<>(Arrays.asList("Host100", "Host101", "Host102")); + Set<String> some_hosts = new HashSet<>(Arrays.asList("0-1", "2")); + Set<String> ohter_hosts = new HashSet<>(Arrays.asList("0,1")); + Set<String> clusterHostTypes = new HashSet<>(Arrays.asList("nm_hosts", "hs_host", + "namenode_host", "rm_host", "snamenode_host", "slave_hosts", "zookeeper_hosts")); for (String hostTypes: clusterHostTypes) { if (hostTypes.equals("slave_hosts")) { clusterHostInfo.put(hostTypes, ohter_hosts); @@ -300,7 +298,7 @@ public class ClientConfigResourceProviderTest { clusterHostInfo.put(hostTypes, some_hosts); } } - Map<String, Host> stringHostMap = new HashMap<String, Host>(); + Map<String, Host> stringHostMap = new HashMap<>(); stringHostMap.put(hostName, host); clusterHostInfo.put("all_hosts",all_hosts); expect(StageUtils.getClusterHostInfo(cluster)).andReturn(clusterHostInfo); @@ -320,12 +318,12 @@ public class ClientConfigResourceProviderTest { expect(cluster.getDesiredConfigs()).andReturn(desiredConfigMap); expect(clusters.getHost(hostName)).andReturn(host); - HashMap<String, String> rcaParams = new HashMap<String, String>(); + HashMap<String, String> rcaParams = new HashMap<>(); rcaParams.put("key","value"); expect(managementController.getRcaParameters()).andReturn(rcaParams).anyTimes(); expect(ambariMetaInfo.getService(stackName, stackVersion, serviceName)).andReturn(serviceInfo); expect(serviceInfo.getOsSpecifics()).andReturn(new HashMap<String, ServiceOsSpecific>()).anyTimes(); - Set<String> userSet = new HashSet<String>(); + Set<String> userSet = new HashSet<>(); userSet.add("hdfs"); expect(configHelper.getPropertyValuesWithPropertyType( stackId, PropertyInfo.PropertyType.USER, cluster, desiredConfigMap)).andReturn(userSet); @@ -353,7 +351,7 @@ public class ClientConfigResourceProviderTest { userProperties.put(userProperty, "hdfsUser"); groupProperties.put(groupProperty, "hdfsGroup"); Map<String, Set<String>> userGroupsMap = new HashMap<>(); - userGroupsMap.put("hdfsUser", new HashSet<String>(Arrays.asList("hdfsGroup"))); + userGroupsMap.put("hdfsUser", new HashSet<>(Arrays.asList("hdfsGroup"))); expect(configHelper.getPropertiesWithPropertyType( stackId, PropertyInfo.PropertyType.USER, cluster, desiredConfigMap)).andReturn(userProperties).anyTimes(); expect(configHelper.getPropertiesWithPropertyType( @@ -437,20 +435,18 @@ public class ClientConfigResourceProviderTest { Runtime runtime = createMock(Runtime.class); Process process = createNiceMock(Process.class); - Map<String, DesiredConfig> desiredConfigMap = new HashMap<String, DesiredConfig>(); + Map<String, DesiredConfig> desiredConfigMap = new HashMap<>(); desiredConfigMap.put("hive-site", desiredConfig); - Map<String, Map<String, String>> allConfigTags = new HashMap<String, Map<String, String>>(); - Map<String, Map<String, String>> properties = new HashMap<String, Map<String, String>>(); - Map<String, Map<String, String>> configTags = new HashMap<String, - Map<String, String>>(); - Map<String, Map<String, Map<String, String>>> attributes = new HashMap<String, - Map<String, Map<String, String>>>(); + Map<String, Map<String, String>> allConfigTags = new HashMap<>(); + Map<String, Map<String, String>> properties = new HashMap<>(); + Map<String, Map<String, String>> configTags = new HashMap<>(); + Map<String, Map<String, Map<String, String>>> attributes = new HashMap<>(); ClientConfigFileDefinition clientConfigFileDefinition = new ClientConfigFileDefinition(); clientConfigFileDefinition.setDictionaryName("pig-env"); clientConfigFileDefinition.setFileName("pig-env.sh"); clientConfigFileDefinition.setType("env"); - List <ClientConfigFileDefinition> clientConfigFileDefinitionList = new LinkedList<ClientConfigFileDefinition>(); + List <ClientConfigFileDefinition> clientConfigFileDefinitionList = new LinkedList<>(); clientConfigFileDefinitionList.add(clientConfigFileDefinition); ResourceProvider provider = AbstractControllerResourceProvider.getResourceProvider( @@ -489,23 +485,23 @@ public class ClientConfigResourceProviderTest { packageFolder = StackManager.COMMON_SERVICES + "\\PIG\\package"; } - HashMap<String, Host> hosts = new HashMap<String, Host>(); + HashMap<String, Host> hosts = new HashMap<>(); hosts.put(hostName, host); - HashMap<String, Service> services = new HashMap<String, Service>(); + HashMap<String, Service> services = new HashMap<>(); services.put(serviceName,service); - HashMap<String, ServiceComponent> serviceComponentMap = new HashMap<String, ServiceComponent>(); + HashMap<String, ServiceComponent> serviceComponentMap = new HashMap<>(); serviceComponentMap.put(componentName,serviceComponent); - HashMap<String, ServiceComponentHost> serviceComponentHosts = new HashMap<String, ServiceComponentHost>(); + HashMap<String, ServiceComponentHost> serviceComponentHosts = new HashMap<>(); serviceComponentHosts.put(componentName, serviceComponentHost); - HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<String, ServiceOsSpecific>(); + HashMap<String, ServiceOsSpecific> serviceOsSpecificHashMap = new HashMap<>(); serviceOsSpecificHashMap.put("key",serviceOsSpecific); ServiceComponentHostResponse shr1 = new ServiceComponentHostResponse(clusterName, serviceName, componentName, displayName, hostName, publicHostName, desiredState, "", null, null, null); - Set<ServiceComponentHostResponse> responses = new LinkedHashSet<ServiceComponentHostResponse>(); + Set<ServiceComponentHostResponse> responses = new LinkedHashSet<>(); responses.add(shr1); - Map<String, String> returnConfigMap = new HashMap<String, String>(); + Map<String, String> returnConfigMap = new HashMap<>(); returnConfigMap.put(Configuration.SERVER_TMP_DIR.getKey(), Configuration.SERVER_TMP_DIR.getDefaultValue()); returnConfigMap.put(Configuration.AMBARI_PYTHON_WRAP.getKey(), Configuration.AMBARI_PYTHON_WRAP.getDefaultValue()); @@ -527,7 +523,7 @@ public class ClientConfigResourceProviderTest { expect(configuration.getExternalScriptThreadPoolSize()).andReturn(Configuration.THREAD_POOL_SIZE_FOR_EXTERNAL_SCRIPT.getDefaultValue()); expect(configuration.getExternalScriptTimeout()).andReturn(Configuration.EXTERNAL_SCRIPT_TIMEOUT.getDefaultValue()); - Map<String,String> props = new HashMap<String, String>(); + Map<String,String> props = new HashMap<>(); props.put("key","value"); expect(clusterConfig.getProperties()).andReturn(props); expect(configHelper.getEffectiveDesiredTags(cluster, null)).andReturn(allConfigTags); @@ -536,12 +532,12 @@ public class ClientConfigResourceProviderTest { expect(cluster.getCurrentStackVersion()).andReturn(stackId); PowerMock.mockStaticPartial(StageUtils.class, "getClusterHostInfo"); - Map<String, Set<String>> clusterHostInfo = new HashMap<String, Set<String>>(); - Set<String> all_hosts = new HashSet<String>(Arrays.asList("Host100","Host101","Host102")); - Set<String> some_hosts = new HashSet<String>(Arrays.asList("0-1","2")); - Set<String> ohter_hosts = new HashSet<String>(Arrays.asList("0,1")); - Set<String> clusterHostTypes = new HashSet<String>(Arrays.asList("nm_hosts", "hs_host", - "namenode_host", "rm_host", "snamenode_host", "slave_hosts", "zookeeper_hosts")); + Map<String, Set<String>> clusterHostInfo = new HashMap<>(); + Set<String> all_hosts = new HashSet<>(Arrays.asList("Host100", "Host101", "Host102")); + Set<String> some_hosts = new HashSet<>(Arrays.asList("0-1", "2")); + Set<String> ohter_hosts = new HashSet<>(Arrays.asList("0,1")); + Set<String> clusterHostTypes = new HashSet<>(Arrays.asList("nm_hosts", "hs_host", + "namenode_host", "rm_host", "snamenode_host", "slave_hosts", "zookeeper_hosts")); for (String hostTypes: clusterHostTypes) { if (hostTypes.equals("slave_hosts")) { clusterHostInfo.put(hostTypes, ohter_hosts); @@ -549,7 +545,7 @@ public class ClientConfigResourceProviderTest { clusterHostInfo.put(hostTypes, some_hosts); } } - Map<String, Host> stringHostMap = new HashMap<String, Host>(); + Map<String, Host> stringHostMap = new HashMap<>(); stringHostMap.put(hostName, host); clusterHostInfo.put("all_hosts",all_hosts); expect(StageUtils.getClusterHostInfo(cluster)).andReturn(clusterHostInfo); @@ -569,12 +565,12 @@ public class ClientConfigResourceProviderTest { expect(cluster.getDesiredConfigs()).andReturn(desiredConfigMap); expect(clusters.getHost(hostName)).andReturn(host); - HashMap<String, String> rcaParams = new HashMap<String, String>(); + HashMap<String, String> rcaParams = new HashMap<>(); rcaParams.put("key","value"); expect(managementController.getRcaParameters()).andReturn(rcaParams).anyTimes(); expect(ambariMetaInfo.getService(stackName, stackVersion, serviceName)).andReturn(serviceInfo); expect(serviceInfo.getOsSpecifics()).andReturn(new HashMap<String, ServiceOsSpecific>()).anyTimes(); - Set<String> userSet = new HashSet<String>(); + Set<String> userSet = new HashSet<>(); userSet.add("hdfs"); expect(configHelper.getPropertyValuesWithPropertyType(stackId, PropertyInfo.PropertyType.USER, cluster, desiredConfigMap)).andReturn(userSet); PowerMock.expectNew(File.class, new Class<?>[]{String.class}, anyObject(String.class)).andReturn(mockFile).anyTimes(); http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java index 0c9f152..ec05fa6 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterControllerImplTest.java @@ -67,7 +67,7 @@ import junit.framework.Assert; */ public class ClusterControllerImplTest { - private static final Set<String> propertyProviderProperties = new HashSet<String>(); + private static final Set<String> propertyProviderProperties = new HashSet<>(); private static final String UNSUPPORTED_PROPERTY = PropertyHelper.getPropertyId("c1", "unsupported"); @@ -98,7 +98,7 @@ public class ClusterControllerImplTest { @Override public Set<String> checkPropertyIds(Set<String> propertyIds) { if (!propertyProviderProperties.containsAll(propertyIds)) { - Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds); + Set<String> unsupportedPropertyIds = new HashSet<>(propertyIds); unsupportedPropertyIds.removeAll(propertyProviderProperties); return unsupportedPropertyIds; } @@ -106,20 +106,20 @@ public class ClusterControllerImplTest { } }; - private static final List<PropertyProvider> propertyProviders = new LinkedList<PropertyProvider>(); + private static final List<PropertyProvider> propertyProviders = new LinkedList<>(); static { propertyProviders.add(propertyProvider); } - private static final Map<Resource.Type, String> keyPropertyIds = new HashMap<Resource.Type, String>(); + private static final Map<Resource.Type, String> keyPropertyIds = new HashMap<>(); static { keyPropertyIds.put(Resource.Type.Cluster, PropertyHelper.getPropertyId("Hosts", "cluster_name")); keyPropertyIds.put(Resource.Type.Host, PropertyHelper.getPropertyId("Hosts", "host_name")); } - private static final Set<String> resourceProviderProperties = new HashSet<String>(); + private static final Set<String> resourceProviderProperties = new HashSet<>(); static { resourceProviderProperties.add(PropertyHelper.getPropertyId("Hosts", "cluster_name")); @@ -138,7 +138,7 @@ public class ClusterControllerImplTest { public void testGetResources() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p3")); @@ -159,7 +159,7 @@ public class ClusterControllerImplTest { public void testGetResourcesPageFromStart() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -168,7 +168,7 @@ public class ClusterControllerImplTest { PageResponse pageResponse = controller.getResources(Resource.Type.Host, request, null, pageRequest, null); Iterable<Resource> iterable = pageResponse.getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -186,7 +186,7 @@ public class ClusterControllerImplTest { pageResponse = controller.getResources(Resource.Type.Host, request, null, pageRequest, null); iterable = pageResponse.getIterable(); - list = new LinkedList<Resource>(); + list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -206,7 +206,7 @@ public class ClusterControllerImplTest { public void testGetResourcesSortedByProperty() throws Exception { ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p2")); @@ -223,7 +223,7 @@ public class ClusterControllerImplTest { Iterable<Resource> iterable = controller.getResources(Resource.Type.Host, request, null, null, sortRequest).getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -243,7 +243,7 @@ public class ClusterControllerImplTest { iterable = controller.getResources(Resource.Type.Host, request, null, null, sortRequest).getIterable(); - list = new LinkedList<Resource>(); + list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -260,7 +260,7 @@ public class ClusterControllerImplTest { public void testGetResourcesSortedByMultiProperty() throws Exception { ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p2")); @@ -278,7 +278,7 @@ public class ClusterControllerImplTest { Iterable<Resource> iterable = controller.getResources(Resource.Type.Host, request, null, null, sortRequest).getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -295,7 +295,7 @@ public class ClusterControllerImplTest { public void testGetResourcesPageFromOffset() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -308,7 +308,7 @@ public class ClusterControllerImplTest { Assert.assertEquals("host:3", pageResponse.getNextResource().getPropertyValue(PropertyHelper.getPropertyId("Hosts", "host_name"))); Iterable<Resource> iterable = pageResponse.getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -330,7 +330,7 @@ public class ClusterControllerImplTest { Assert.assertEquals("host:3", pageResponse.getNextResource().getPropertyValue(PropertyHelper.getPropertyId("Hosts", "host_name"))); iterable = pageResponse.getIterable(); - list = new LinkedList<Resource>(); + list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -350,7 +350,7 @@ public class ClusterControllerImplTest { public void testGetResourcesPageToEnd() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -359,7 +359,7 @@ public class ClusterControllerImplTest { PageResponse pageResponse = controller.getResources(Resource.Type.Host, request, null, pageRequest, null); Iterable<Resource> iterable = pageResponse.getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -377,7 +377,7 @@ public class ClusterControllerImplTest { pageResponse = controller.getResources(Resource.Type.Host, request, null, pageRequest, null); iterable = pageResponse.getIterable(); - list = new LinkedList<Resource>(); + list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -397,7 +397,7 @@ public class ClusterControllerImplTest { public void testGetResourcesPageToOffset() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -412,7 +412,7 @@ public class ClusterControllerImplTest { Assert.assertEquals(4, pageResponse.getTotalResourceCount().intValue()); Iterable<Resource> iterable = pageResponse.getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -432,7 +432,7 @@ public class ClusterControllerImplTest { Assert.assertEquals("host:3", pageResponse.getNextResource().getPropertyValue(PropertyHelper.getPropertyId("Hosts", "host_name"))); iterable = pageResponse.getIterable(); - list = new LinkedList<Resource>(); + list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -452,7 +452,7 @@ public class ClusterControllerImplTest { public void testGetResourcesEmptyRequest() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -470,7 +470,7 @@ public class ClusterControllerImplTest { public void testGetResourcesCheckOrder() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -496,7 +496,7 @@ public class ClusterControllerImplTest { public void testGetResourcesWithPredicate() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p2")); @@ -521,7 +521,7 @@ public class ClusterControllerImplTest { public void testGetResourcesWithUnsupportedPropertyPredicate() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p2")); @@ -544,7 +544,7 @@ public class ClusterControllerImplTest { public void testGetResourcesWithUnsupportedPropertyRequest() throws Exception{ ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(PropertyHelper.getPropertyId("c1", "p1")); propertyIds.add(PropertyHelper.getPropertyId("c1", "p2")); @@ -569,7 +569,7 @@ public class ClusterControllerImplTest { ClusterControllerImpl controller = new ClusterControllerImpl(new TestProviderModule()); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); Request request = PropertyHelper.getReadRequest(propertyIds); @@ -586,7 +586,7 @@ public class ClusterControllerImplTest { controller.getResources(Resource.Type.Host, request, predicate, pageRequest, sortRequest); Iterable<Resource> iterable = pageResponse.getIterable(); - List<Resource> list = new LinkedList<Resource>(); + List<Resource> list = new LinkedList<>(); for (Resource resource : iterable) { list.add(resource); @@ -626,8 +626,8 @@ public class ClusterControllerImplTest { TestHostResourceProvider resourceProvider = (TestHostResourceProvider) providerModule.getResourceProvider(Resource.Type.Host); ClusterController controller = new ClusterControllerImpl(providerModule); - Set<Map<String, Object>> properties = new HashSet<Map<String, Object>>(); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Set<Map<String, Object>> properties = new HashSet<>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(PropertyHelper.getPropertyId("c1", "p2"), 2); @@ -648,8 +648,8 @@ public class ClusterControllerImplTest { TestProviderModule providerModule = new TestProviderModule(); ClusterController controller = new ClusterControllerImpl(providerModule); - Set<Map<String, Object>> properties = new HashSet<Map<String, Object>>(); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Set<Map<String, Object>> properties = new HashSet<>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(UNSUPPORTED_PROPERTY, 2); @@ -672,7 +672,7 @@ public class ClusterControllerImplTest { TestHostResourceProvider resourceProvider = (TestHostResourceProvider) providerModule.getResourceProvider(Resource.Type.Host); ClusterController controller = new ClusterControllerImpl(providerModule); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(PropertyHelper.getPropertyId("c1", "p2"), 2); @@ -693,7 +693,7 @@ public class ClusterControllerImplTest { TestProviderModule providerModule = new TestProviderModule(); ClusterController controller = new ClusterControllerImpl(providerModule); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(UNSUPPORTED_PROPERTY, 2); @@ -715,7 +715,7 @@ public class ClusterControllerImplTest { TestProviderModule providerModule = new TestProviderModule(); ClusterController controller = new ClusterControllerImpl(providerModule); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(PropertyHelper.getPropertyId("c1", "p2"), 2); @@ -738,7 +738,7 @@ public class ClusterControllerImplTest { TestHostResourceProvider resourceProvider = (TestHostResourceProvider) providerModule.getResourceProvider(Resource.Type.Host); ClusterController controller = new ClusterControllerImpl(providerModule); - Map<String, Object> propertyMap = new HashMap<String, Object>(); + Map<String, Object> propertyMap = new HashMap<>(); propertyMap.put(PropertyHelper.getPropertyId("c1", "p1"), 99); propertyMap.put(PropertyHelper.getPropertyId("c1", "p2"), 2); @@ -908,12 +908,12 @@ public class ClusterControllerImplTest { ClusterControllerImpl controller = new ClusterControllerImpl(providerModule); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(AlertHistoryResourceProvider.ALERT_HISTORY_HOSTNAME); // create a result set that we will use to ensure that the contents // were unmodified - Set<Resource> providerResources = new LinkedHashSet<Resource>(); + Set<Resource> providerResources = new LinkedHashSet<>(); providerResources.add(new ResourceImpl(Resource.Type.AlertHistory)); Request request = PropertyHelper.getReadRequest(propertyIds, null, null, @@ -930,7 +930,7 @@ public class ClusterControllerImplTest { } public static class TestProviderModule implements ProviderModule { - private Map<Resource.Type, ResourceProvider> providers = new HashMap<Resource.Type, ResourceProvider>(); + private Map<Resource.Type, ResourceProvider> providers = new HashMap<>(); public TestProviderModule() { @@ -1000,11 +1000,11 @@ public class ClusterControllerImplTest { protected Set<Resource> getResources(Resource.Type type, Predicate predicate, String keyPropertyId, Set<String> keyPropertyValues) throws SystemException, UnsupportedPropertyException, NoSuchParentResourceException, NoSuchResourceException { - Set<Resource> resources = new HashSet<Resource>(); + Set<Resource> resources = new HashSet<>(); for (Map<String, Object> propertyMap : getPropertyMaps(predicate)) { - Set<Resource> resources2 = new HashSet<Resource>(); + Set<Resource> resources2 = new HashSet<>(); if (!propertyMap.containsKey(keyPropertyId)) { for (String keyPropertyValue : keyPropertyValues) { @@ -1054,7 +1054,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<Resource> resources = new HashSet<Resource>(); + Set<Resource> resources = new HashSet<>(); for (int cnt = 0; cnt < 4; ++ cnt) { ResourceImpl resource = new ResourceImpl(Resource.Type.Host); @@ -1109,7 +1109,7 @@ public class ClusterControllerImplTest { @Override public Set<String> checkPropertyIds(Set<String> propertyIds) { if (!resourceProviderProperties.containsAll(propertyIds)) { - Set<String> unsupportedPropertyIds = new HashSet<String>(propertyIds); + Set<String> unsupportedPropertyIds = new HashSet<>(propertyIds); unsupportedPropertyIds.removeAll(resourceProviderProperties); return unsupportedPropertyIds; } @@ -1150,7 +1150,7 @@ public class ClusterControllerImplTest { public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new HashSet<String>(); + Set<String> keyPropertyValues = new HashSet<>(); return getResources(Resource.Type.Stack, predicate, "Stacks/stack_name", keyPropertyValues); } @@ -1165,7 +1165,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("1.2.1"); keyPropertyValues.add("1.2.2"); @@ -1183,7 +1183,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("centos5"); keyPropertyValues.add("centos6"); @@ -1201,7 +1201,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("repo1"); keyPropertyValues.add("repo2"); @@ -1218,7 +1218,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("1"); keyPropertyValues.add("2"); @@ -1235,7 +1235,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("1"); keyPropertyValues.add("2"); @@ -1252,7 +1252,7 @@ public class ClusterControllerImplTest { @Override public Set<Resource> getResources(Request request, Predicate predicate) throws SystemException, UnsupportedPropertyException, NoSuchResourceException, NoSuchParentResourceException { - Set<String> keyPropertyValues = new LinkedHashSet<String>(); + Set<String> keyPropertyValues = new LinkedHashSet<>(); keyPropertyValues.add("kerberos_descriptor"); http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterKerberosDescriptorResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterKerberosDescriptorResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterKerberosDescriptorResourceProviderTest.java index 3167710..e0335e6 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterKerberosDescriptorResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterKerberosDescriptorResourceProviderTest.java @@ -91,96 +91,96 @@ public class ClusterKerberosDescriptorResourceProviderTest extends EasyMockSuppo private static final Map<String, Object> COMPOSITE_MAP; static { - TreeMap<String, Object> stackProperties = new TreeMap<String, Object>(); + TreeMap<String, Object> stackProperties = new TreeMap<>(); stackProperties.put("realm", "EXAMPLE.COM"); stackProperties.put("some.property", "Hello World"); - Collection<String> authToLocalRules = new ArrayList<String>(); + Collection<String> authToLocalRules = new ArrayList<>(); authToLocalRules.add("global.name.rules"); - TreeMap<String, Object> stackServices = new TreeMap<String, Object>(); + TreeMap<String, Object> stackServices = new TreeMap<>(); stackServices.put((String) KerberosServiceDescriptorTest.MAP_VALUE.get("name"), KerberosServiceDescriptorTest.MAP_VALUE); - TreeMap<String, Object> stackClusterConfProperties = new TreeMap<String, Object>(); + TreeMap<String, Object> stackClusterConfProperties = new TreeMap<>(); stackClusterConfProperties.put("property1", "red"); - TreeMap<String, Object> stackClusterConf = new TreeMap<String, Object>(); + TreeMap<String, Object> stackClusterConf = new TreeMap<>(); stackClusterConf.put("cluster-conf", stackClusterConfProperties); - TreeMap<String, Object> stackConfigurations = new TreeMap<String, Object>(); + TreeMap<String, Object> stackConfigurations = new TreeMap<>(); stackConfigurations.put("cluster-conf", stackClusterConf); - TreeMap<String, Object> stackSharedIdentityKeytabOwner = new TreeMap<String, Object>(); + TreeMap<String, Object> stackSharedIdentityKeytabOwner = new TreeMap<>(); stackSharedIdentityKeytabOwner.put("name", "root"); stackSharedIdentityKeytabOwner.put("access", "rw"); - TreeMap<String, Object> sharedIdentityKeytabGroup = new TreeMap<String, Object>(); + TreeMap<String, Object> sharedIdentityKeytabGroup = new TreeMap<>(); sharedIdentityKeytabGroup.put("name", "hadoop"); sharedIdentityKeytabGroup.put("access", "r"); - TreeMap<String, Object> stackSharedIdentityKeytab = new TreeMap<String, Object>(); + TreeMap<String, Object> stackSharedIdentityKeytab = new TreeMap<>(); stackSharedIdentityKeytab.put("file", "/etc/security/keytabs/subject.service.keytab"); stackSharedIdentityKeytab.put("owner", stackSharedIdentityKeytabOwner); stackSharedIdentityKeytab.put("group", sharedIdentityKeytabGroup); stackSharedIdentityKeytab.put("configuration", "service-site/service2.component.keytab.file"); - TreeMap<String, Object> stackSharedIdentity = new TreeMap<String, Object>(); + TreeMap<String, Object> stackSharedIdentity = new TreeMap<>(); stackSharedIdentity.put("name", "shared"); - stackSharedIdentity.put("principal", new TreeMap<String, Object>(KerberosPrincipalDescriptorTest.MAP_VALUE)); + stackSharedIdentity.put("principal", new TreeMap<>(KerberosPrincipalDescriptorTest.MAP_VALUE)); stackSharedIdentity.put("keytab", stackSharedIdentityKeytab); - TreeMap<String, Object> stackIdentities = new TreeMap<String, Object>(); + TreeMap<String, Object> stackIdentities = new TreeMap<>(); stackIdentities.put("shared", stackSharedIdentity); - STACK_MAP = new TreeMap<String, Object>(); + STACK_MAP = new TreeMap<>(); STACK_MAP.put("properties", stackProperties); STACK_MAP.put(AbstractKerberosDescriptor.Type.AUTH_TO_LOCAL_PROPERTY.getDescriptorPluralName(), authToLocalRules); STACK_MAP.put(AbstractKerberosDescriptor.Type.SERVICE.getDescriptorPluralName(), stackServices.values()); STACK_MAP.put(AbstractKerberosDescriptor.Type.CONFIGURATION.getDescriptorPluralName(), stackConfigurations.values()); STACK_MAP.put(AbstractKerberosDescriptor.Type.IDENTITY.getDescriptorPluralName(), stackIdentities.values()); - TreeMap<String, Object> userProperties = new TreeMap<String, Object>(); + TreeMap<String, Object> userProperties = new TreeMap<>(); userProperties.put("realm", "HWX.COM"); userProperties.put("some.property", "Hello World"); - TreeMap<String, Object> userClusterConfProperties = new TreeMap<String, Object>(); + TreeMap<String, Object> userClusterConfProperties = new TreeMap<>(); userClusterConfProperties.put("property1", "blue"); userClusterConfProperties.put("property2", "orange"); - TreeMap<String, Object> userClusterConf = new TreeMap<String, Object>(); + TreeMap<String, Object> userClusterConf = new TreeMap<>(); userClusterConf.put("cluster-conf", userClusterConfProperties); - TreeMap<String, Object> userConfigurations = new TreeMap<String, Object>(); + TreeMap<String, Object> userConfigurations = new TreeMap<>(); userConfigurations.put("cluster-conf", userClusterConf); - TreeMap<String, Object> userSharedIdentityKeytabOwner = new TreeMap<String, Object>(); + TreeMap<String, Object> userSharedIdentityKeytabOwner = new TreeMap<>(); userSharedIdentityKeytabOwner.put("name", "root"); userSharedIdentityKeytabOwner.put("access", "rw"); - TreeMap<String, Object> userSharedIdentityKeytabGroup = new TreeMap<String, Object>(); + TreeMap<String, Object> userSharedIdentityKeytabGroup = new TreeMap<>(); userSharedIdentityKeytabGroup.put("name", "hadoop"); userSharedIdentityKeytabGroup.put("access", "r"); - TreeMap<String, Object> userSharedIdentityKeytab = new TreeMap<String, Object>(); + TreeMap<String, Object> userSharedIdentityKeytab = new TreeMap<>(); userSharedIdentityKeytab.put("file", "/etc/security/keytabs/subject.service.keytab"); userSharedIdentityKeytab.put("owner", userSharedIdentityKeytabOwner); userSharedIdentityKeytab.put("group", userSharedIdentityKeytabGroup); userSharedIdentityKeytab.put("configuration", "service-site/service2.component.keytab.file"); - TreeMap<String, Object> userSharedIdentity = new TreeMap<String, Object>(); + TreeMap<String, Object> userSharedIdentity = new TreeMap<>(); userSharedIdentity.put("name", "shared"); - userSharedIdentity.put("principal", new TreeMap<String, Object>(KerberosPrincipalDescriptorTest.MAP_VALUE)); + userSharedIdentity.put("principal", new TreeMap<>(KerberosPrincipalDescriptorTest.MAP_VALUE)); userSharedIdentity.put("keytab", userSharedIdentityKeytab); - TreeMap<String, Object> userIdentities = new TreeMap<String, Object>(); + TreeMap<String, Object> userIdentities = new TreeMap<>(); userIdentities.put("shared", userSharedIdentity); - USER_MAP = new TreeMap<String, Object>(); + USER_MAP = new TreeMap<>(); USER_MAP.put("properties", userProperties); USER_MAP.put(AbstractKerberosDescriptor.Type.CONFIGURATION.getDescriptorPluralName(), userConfigurations.values()); USER_MAP.put(AbstractKerberosDescriptor.Type.IDENTITY.getDescriptorPluralName(), userIdentities.values()); - COMPOSITE_MAP = new TreeMap<String, Object>(); + COMPOSITE_MAP = new TreeMap<>(); COMPOSITE_MAP.putAll(STACK_MAP); COMPOSITE_MAP.putAll(USER_MAP); } @@ -483,7 +483,7 @@ public class ClusterKerberosDescriptorResourceProviderTest extends EasyMockSuppo expect(managementController.getClusters()).andReturn(clusters).atLeastOnce(); expect(managementController.getKerberosHelper()).andReturn(kerberosHelper).atLeastOnce(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(ClusterKerberosDescriptorResourceProvider.DIRECTIVE_EVALUATE_WHEN_CLAUSE, "true"); requestInfoProperties.put(ClusterKerberosDescriptorResourceProvider.DIRECTIVE_ADDITIONAL_SERVICES, "HIVE, TEZ,PIG"); http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java index 7e5969d..4f1ad48 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterPrivilegeResourceProviderTest.java @@ -171,7 +171,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { ClusterEntity clusterEntity = createMockClusterEntity("c1", clusterResourceEntity); UserEntity userEntity = createMockUserEntity(principalEntity, "User1"); - Set<PrivilegeEntity> privilegeEntities = new HashSet<PrivilegeEntity>(); + Set<PrivilegeEntity> privilegeEntities = new HashSet<>(); privilegeEntities.add(privilegeEntity); expect(principalEntity.getPrivileges()).andReturn(privilegeEntities).atLeastOnce(); @@ -204,7 +204,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { SecurityContextHolder.getContext().setAuthentication(authentication); // add the property map to a set for the request. - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(PrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID, "CLUSTER.OPERATOR"); properties.put(PrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID, "User1"); properties.put(PrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID, "USER"); @@ -231,19 +231,19 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { ClusterEntity clusterEntity = createMockClusterEntity("c1", resourceEntity); UserEntity userEntity = createMockUserEntity(principalEntity, "joe"); - List<PrincipalEntity> principalEntities = new LinkedList<PrincipalEntity>(); + List<PrincipalEntity> principalEntities = new LinkedList<>(); principalEntities.add(principalEntity); - List<UserEntity> userEntities = new LinkedList<UserEntity>(); + List<UserEntity> userEntities = new LinkedList<>(); userEntities.add(userEntity); - List<PrivilegeEntity> privilegeEntities = new LinkedList<PrivilegeEntity>(); + List<PrivilegeEntity> privilegeEntities = new LinkedList<>(); privilegeEntities.add(privilegeEntity); PrivilegeDAO privilegeDAO = injector.getInstance(PrivilegeDAO.class); expect(privilegeDAO.findAll()).andReturn(privilegeEntities); - List<ClusterEntity> clusterEntities = new LinkedList<ClusterEntity>(); + List<ClusterEntity> clusterEntities = new LinkedList<>(); clusterEntities.add(clusterEntity); ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class); @@ -283,19 +283,19 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { ClusterEntity clusterEntity = createMockClusterEntity("c1", resourceEntity); UserEntity userEntity = createMockUserEntity(principalEntity, requestedUsername); - List<PrincipalEntity> principalEntities = new LinkedList<PrincipalEntity>(); + List<PrincipalEntity> principalEntities = new LinkedList<>(); principalEntities.add(principalEntity); - List<UserEntity> userEntities = new LinkedList<UserEntity>(); + List<UserEntity> userEntities = new LinkedList<>(); userEntities.add(userEntity); - List<PrivilegeEntity> privilegeEntities = new LinkedList<PrivilegeEntity>(); + List<PrivilegeEntity> privilegeEntities = new LinkedList<>(); privilegeEntities.add(privilegeEntity); PrivilegeDAO privilegeDAO = injector.getInstance(PrivilegeDAO.class); expect(privilegeDAO.findAll()).andReturn(privilegeEntities); - List<ClusterEntity> clusterEntities = new LinkedList<ClusterEntity>(); + List<ClusterEntity> clusterEntities = new LinkedList<>(); clusterEntities.add(clusterEntity); ClusterDAO clusterDAO = injector.getInstance(ClusterDAO.class); @@ -335,7 +335,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { ResourceEntity resourceEntity = createMockResourceEntity(2L, resourceTypeEntity); ClusterEntity clusterEntity = createMockClusterEntity("c1", resourceEntity); - List<ClusterEntity> clusterEntities = new LinkedList<ClusterEntity>(); + List<ClusterEntity> clusterEntities = new LinkedList<>(); clusterEntities.add(clusterEntity); PrincipalTypeEntity principalTypeEntity = createMockPrincipalTypeEntity("USER"); @@ -343,7 +343,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { UserEntity userEntity = createMockUserEntity(principalEntity, requestedUsername); PrivilegeEntity privilegeEntity = createMockPrivilegeEntity(1, resourceEntity, principalEntity, permissionEntity); - List<PrivilegeEntity> privilegeEntities = new ArrayList<PrivilegeEntity>(); + List<PrivilegeEntity> privilegeEntities = new ArrayList<>(); privilegeEntities.add(privilegeEntity); UserDAO userDAO = injector.getInstance(UserDAO.class); @@ -365,7 +365,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { SecurityContextHolder.getContext().setAuthentication(authentication); - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(PrivilegeResourceProvider.PERMISSION_NAME_PROPERTY_ID, "CLUSTER.OPERATOR"); properties.put(PrivilegeResourceProvider.PRINCIPAL_NAME_PROPERTY_ID, requestedUsername); properties.put(PrivilegeResourceProvider.PRINCIPAL_TYPE_PROPERTY_ID, "USER"); @@ -389,7 +389,7 @@ public class ClusterPrivilegeResourceProviderTest extends EasyMockSupport { PrivilegeEntity privilegeEntity1 = createMockPrivilegeEntity(1, clusterResourceEntity, principalEntity1, permissionEntity); - Set<PrivilegeEntity> privilege1Entities = new HashSet<PrivilegeEntity>(); + Set<PrivilegeEntity> privilege1Entities = new HashSet<>(); privilege1Entities.add(privilegeEntity1); expect(principalEntity1.getPrivileges()).andReturn(privilege1Entities).atLeastOnce(); http://git-wip-us.apache.org/repos/asf/ambari/blob/edbb5492/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java index 9948bf8..49127d8 100644 --- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java +++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterResourceProviderTest.java @@ -145,7 +145,7 @@ public class ClusterResourceProviderTest { Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map<String, Object> properties = requestProperties.iterator().next(); properties.put(BaseClusterRequest.PROVISION_ACTION_PROPERTY, "INSTALL_ONLY"); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}"); // set expectations @@ -174,7 +174,7 @@ public class ClusterResourceProviderTest { public void testCreateResource_blueprint_withInvalidSecurityConfiguration() throws Exception { Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map<String, Object> properties = requestProperties.iterator().next(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\" : \"NONE\"," + "\n\"kerberos_descriptor_reference\" : " + "\"testRef\"\n}}"); SecurityConfiguration blueprintSecurityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS, "testRef", @@ -203,7 +203,7 @@ public class ClusterResourceProviderTest { Map<String, Object> properties = requestProperties.iterator().next(); SecurityConfiguration securityConfiguration = new SecurityConfiguration(SecurityType.KERBEROS, "testRef", null); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{\"security\" : {\n\"type\" : \"KERBEROS\",\n\"kerberos_descriptor_reference\" : " + "\"testRef\"\n}}"); @@ -284,10 +284,10 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); // add the property map to a set for the request. add more maps for multiple creates - Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); + Set<Map<String, Object>> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); // add the cluster name to the properties map properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); @@ -332,17 +332,17 @@ public class ClusterResourceProviderTest { AmbariManagementController managementController = createMock(AmbariManagementController.class); Clusters clusters = createMock(Clusters.class); - Set<ClusterResponse> allResponse = new HashSet<ClusterResponse>(); + Set<ClusterResponse> allResponse = new HashSet<>(); allResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, null, null, null)); allResponse.add(new ClusterResponse(101L, "Cluster101", State.INSTALLED, SecurityType.NONE, null, null, null, null)); allResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, null, null, null)); allResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, null, null, null)); allResponse.add(new ClusterResponse(104L, "Cluster104", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>(); + Set<ClusterResponse> nameResponse = new HashSet<>(); nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - Set<ClusterResponse> idResponse = new HashSet<ClusterResponse>(); + Set<ClusterResponse> idResponse = new HashSet<>(); idResponse.add(new ClusterResponse(103L, "Cluster103", State.INSTALLED, SecurityType.NONE, null, null, null, null)); // set expectations @@ -365,7 +365,7 @@ public class ClusterResourceProviderTest { PropertyHelper.getKeyPropertyIds(type), managementController); - Set<String> propertyIds = new HashSet<String>(); + Set<String> propertyIds = new HashSet<>(); propertyIds.add(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID); propertyIds.add(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID); @@ -452,40 +452,40 @@ public class ClusterResourceProviderTest { //todo: configuration properties are not being added to props private Set<Map<String, Object>> createBlueprintRequestProperties(String clusterName, String blueprintName) { - Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Set<Map<String, Object>> propertySet = new LinkedHashSet<>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, clusterName); properties.put(ClusterResourceProvider.BLUEPRINT_PROPERTY_ID, blueprintName); propertySet.add(properties); - Collection<Map<String, Object>> hostGroups = new ArrayList<Map<String, Object>>(); - Map<String, Object> hostGroupProperties = new HashMap<String, Object>(); + Collection<Map<String, Object>> hostGroups = new ArrayList<>(); + Map<String, Object> hostGroupProperties = new HashMap<>(); hostGroups.add(hostGroupProperties); hostGroupProperties.put("name", "group1"); - Collection<Map<String, String>> hostGroupHosts = new ArrayList<Map<String, String>>(); + Collection<Map<String, String>> hostGroupHosts = new ArrayList<>(); hostGroupProperties.put("hosts", hostGroupHosts); - Map<String, String> hostGroupHostProperties = new HashMap<String, String>(); + Map<String, String> hostGroupHostProperties = new HashMap<>(); hostGroupHostProperties.put("fqdn", "host.domain"); hostGroupHosts.add(hostGroupHostProperties); properties.put("host_groups", hostGroups); - Map<String, String> mapGroupConfigProperties = new HashMap<String, String>(); + Map<String, String> mapGroupConfigProperties = new HashMap<>(); mapGroupConfigProperties.put("myGroupProp", "awesomeValue"); // blueprint core-site cluster configuration properties - Map<String, String> blueprintCoreConfigProperties = new HashMap<String, String>(); + Map<String, String> blueprintCoreConfigProperties = new HashMap<>(); blueprintCoreConfigProperties.put("property1", "value2"); blueprintCoreConfigProperties.put("new.property", "new.property.value"); - Map<String, String> blueprintGlobalConfigProperties = new HashMap<String, String>(); + Map<String, String> blueprintGlobalConfigProperties = new HashMap<>(); blueprintGlobalConfigProperties.put("hive_database", "New MySQL Database"); - Map<String, String> oozieEnvConfigProperties = new HashMap<String, String>(); + Map<String, String> oozieEnvConfigProperties = new HashMap<>(); oozieEnvConfigProperties.put("property1","value2"); - Map<String, String> hbaseEnvConfigProperties = new HashMap<String, String>(); + Map<String, String> hbaseEnvConfigProperties = new HashMap<>(); hbaseEnvConfigProperties.put("property1","value2"); - Map<String, String> falconEnvConfigProperties = new HashMap<String, String>(); + Map<String, String> falconEnvConfigProperties = new HashMap<>(); falconEnvConfigProperties.put("property1","value2"); return propertySet; @@ -494,7 +494,7 @@ public class ClusterResourceProviderTest { private void testCreateResource_blueprint(Authentication authentication) throws Exception { Set<Map<String, Object>> requestProperties = createBlueprintRequestProperties(CLUSTER_NAME, BLUEPRINT_NAME); Map<String, Object> properties = requestProperties.iterator().next(); - Map<String, String> requestInfoProperties = new HashMap<String, String>(); + Map<String, String> requestInfoProperties = new HashMap<>(); requestInfoProperties.put(Request.REQUEST_INFO_BODY_PROPERTY, "{}"); // set expectations @@ -545,10 +545,10 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); // add the property map to a set for the request. add more maps for multiple creates - Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); + Set<Map<String, Object>> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); // add the cluster name to the properties map properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); @@ -559,7 +559,7 @@ public class ClusterResourceProviderTest { propertySet.add(properties); // Cluster 2: create a map of properties for the request - properties = new LinkedHashMap<String, Object>(); + properties = new LinkedHashMap<>(); // add the cluster id to the properties map properties.put(ClusterResourceProvider.CLUSTER_ID_PROPERTY_ID, 99L); @@ -593,10 +593,10 @@ public class ClusterResourceProviderTest { AmbariManagementController managementController = createMock(AmbariManagementController.class); RequestStatusResponse response = createNiceMock(RequestStatusResponse.class); - Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>(); + Set<ClusterResponse> nameResponse = new HashSet<>(); nameResponse.add(new ClusterResponse(102L, "Cluster102", State.INIT, SecurityType.NONE, null, null, null, null)); - Map<String, String> mapRequestProps = new HashMap<String, String>(); + Map<String, String> mapRequestProps = new HashMap<>(); mapRequestProps.put("context", "Called from a test"); // set expectations @@ -628,7 +628,7 @@ public class ClusterResourceProviderTest { ((ObservableResourceProvider)provider).addObserver(observer); - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1"); @@ -661,10 +661,10 @@ public class ClusterResourceProviderTest { Clusters clusters = createMock(Clusters.class); RequestStatusResponse response = createNiceMock(RequestStatusResponse.class); - Set<ClusterResponse> nameResponse = new HashSet<ClusterResponse>(); + Set<ClusterResponse> nameResponse = new HashSet<>(); nameResponse.add(new ClusterResponse(100L, "Cluster100", State.INSTALLED, SecurityType.NONE, null, null, null, null)); - Map<String, String> mapRequestProps = new HashMap<String, String>(); + Map<String, String> mapRequestProps = new HashMap<>(); mapRequestProps.put("context", "Called from a test"); // set expectations @@ -680,7 +680,7 @@ public class ClusterResourceProviderTest { SecurityContextHolder.getContext().setAuthentication(authentication); - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "global"); @@ -689,7 +689,7 @@ public class ClusterResourceProviderTest { properties.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "x"), "y"); - Map<String, Object> properties2 = new LinkedHashMap<String, Object>(); + Map<String, Object> properties2 = new LinkedHashMap<>(); properties2.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config", "type"), "mapred-site"); @@ -697,7 +697,7 @@ public class ClusterResourceProviderTest { properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "foo"), "A1"); properties2.put(PropertyHelper.getPropertyId("Clusters.desired_config.properties", "bar"), "B2"); - Set<Map<String, Object>> propertySet = new HashSet<Map<String, Object>>(); + Set<Map<String, Object>> propertySet = new HashSet<>(); propertySet.add(properties); propertySet.add(properties2); @@ -806,10 +806,10 @@ public class ClusterResourceProviderTest { managementController); // add the property map to a set for the request. add more maps for multiple creates - Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>(); + Set<Map<String, Object>> propertySet = new LinkedHashSet<>(); // Cluster 1: create a map of properties for the request - Map<String, Object> properties = new LinkedHashMap<String, Object>(); + Map<String, Object> properties = new LinkedHashMap<>(); properties.put(ClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID, "Cluster100"); properties.put(ClusterResourceProvider.CLUSTER_VERSION_PROPERTY_ID, "HDP-0.1"); properties.put(ClusterResourceProvider.CLUSTER_REPO_VERSION, "2.1.1");