Search in sources :

Example 1 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetHostGroupConfiguration.

@Test
public void testGetHostGroupConfiguration() throws IOException {
    init();
    HostgroupView hostGroup = new HostgroupView("hostGroup", 10, InstanceGroupType.CORE, 1);
    Set<String> components = singleton("component");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Map<String, String>> properties = new HashMap<>();
    properties.put("key", singletonMap("propKey", "propValue"));
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    when(blueprintTextProcessor.getComponentsInHostGroup(hostGroup.getName())).thenReturn(components);
    when(configUtils.getProperties(any(ServiceConfig.class), eq(false), eq(10), eq(components))).thenReturn(properties);
    Map<String, Map<String, Map<String, String>>> actual = underTest.getHostGroupConfiguration(blueprintTextProcessor, singletonList(hostGroup));
    Map<String, Map<String, Map<String, String>>> expected = new HashMap<>();
    expected.put("hostGroup", properties);
    Assert.assertEquals(actual, expected);
}
Also used : HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 2 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetHostGroupConfigurationWhenConfigUpdateIsNotNeed.

@Test
public void testGetHostGroupConfigurationWhenConfigUpdateIsNotNeed() throws IOException {
    HostgroupView hostGroup = new HostgroupView("hostGroupName");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(false);
    Map<String, Map<String, Map<String, String>>> actual = underTest.getHostGroupConfiguration(blueprintTextProcessor, singletonList(hostGroup));
    Assert.assertEquals(actual, emptyMap());
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 3 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetHostGroupConfigurationWhenTemplateIsNull.

@Test
public void testGetHostGroupConfigurationWhenTemplateIsNull() throws IOException {
    init();
    HostgroupView hostGroup = new HostgroupView("hostGroup");
    Set<String> components = singleton("component");
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Map<String, String>> properties = new HashMap<>();
    properties.put("key", singletonMap("propKey", "propValue"));
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    when(blueprintTextProcessor.getComponentsInHostGroup(hostGroup.getName())).thenReturn(components);
    when(configUtils.getProperties(any(ServiceConfig.class), eq(false), eq(-1), eq(components))).thenReturn(properties);
    Map<String, Map<String, Map<String, String>>> actual = underTest.getHostGroupConfiguration(blueprintTextProcessor, singletonList(hostGroup));
    Map<String, Map<String, Map<String, String>>> expected = new HashMap<>();
    expected.put("hostGroup", properties);
    Assert.assertEquals(actual, expected);
}
Also used : HashMap(java.util.HashMap) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 4 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigServiceTest method testGetHostGroupConfigurationWhenConfigServiceIsEmpty.

@Test
public void testGetHostGroupConfigurationWhenConfigServiceIsEmpty() throws IOException {
    ArrayNode rootJsonNode = JsonNodeFactory.instance.arrayNode();
    when(configUtils.readConfigJson("hdp/bp-config.json", "sites")).thenReturn(rootJsonNode);
    rootJsonNode = JsonNodeFactory.instance.arrayNode();
    when(configUtils.readConfigJson("hdp/service-config.json", "services")).thenReturn(rootJsonNode);
    underTest.init();
    HostgroupView hostGroup = new HostgroupView("hostGroup", 1, InstanceGroupType.CORE, 1);
    BlueprintTextProcessor blueprintTextProcessor = mock(BlueprintTextProcessor.class);
    Map<String, Map<String, String>> properties = new HashMap<>();
    when(configUtils.isConfigUpdateNeeded(hostGroup)).thenReturn(true);
    Map<String, Map<String, Map<String, String>>> actual = underTest.getHostGroupConfiguration(blueprintTextProcessor, singletonList(hostGroup));
    Map<String, Map<String, Map<String, String>>> expected = new HashMap<>();
    expected.put("hostGroup", properties);
    Assert.assertEquals(actual, expected);
}
Also used : HashMap(java.util.HashMap) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) HashMap(java.util.HashMap) Map(java.util.Map) Collections.singletonMap(java.util.Collections.singletonMap) Collections.emptyMap(java.util.Collections.emptyMap) Test(org.junit.Test)

Example 5 with HostgroupView

use of com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView in project cloudbreak by hortonworks.

the class ConfigUtilsTest method testIsConfigNeedFalse.

@Test
public void testIsConfigNeedFalse() {
    HostgroupView hostGroup = new HostgroupView("hostGroupName1");
    boolean actual = underTest.isConfigUpdateNeeded(hostGroup);
    Assert.assertFalse(actual);
}
Also used : HostgroupView(com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView) Test(org.junit.Test)

Aggregations

HostgroupView (com.sequenceiq.cloudbreak.blueprint.template.views.HostgroupView)16 Test (org.junit.Test)13 HashMap (java.util.HashMap)10 Map (java.util.Map)10 Collections.emptyMap (java.util.Collections.emptyMap)9 Collections.singletonMap (java.util.Collections.singletonMap)9 Set (java.util.Set)6 Collections.emptySet (java.util.Collections.emptySet)4 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)1 JsonPropertyOrder (com.fasterxml.jackson.annotation.JsonPropertyOrder)1 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 GATEWAY (com.sequenceiq.cloudbreak.api.model.InstanceGroupType.GATEWAY)1 BlueprintComponentConfigProvider (com.sequenceiq.cloudbreak.blueprint.BlueprintComponentConfigProvider)1 BlueprintConfigurationEntry (com.sequenceiq.cloudbreak.blueprint.BlueprintConfigurationEntry)1 BlueprintPreparationObject (com.sequenceiq.cloudbreak.blueprint.BlueprintPreparationObject)1 BlueprintProcessingException (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessingException)1 BlueprintProcessorFactory (com.sequenceiq.cloudbreak.blueprint.BlueprintProcessorFactory)1 BlueprintTextProcessor (com.sequenceiq.cloudbreak.blueprint.BlueprintTextProcessor)1 SmartsenseConfigurationLocator (com.sequenceiq.cloudbreak.blueprint.SmartsenseConfigurationLocator)1