use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class ComponentBuilderTest method testBuildComponents_AllGood_BehavesAsExpected.
@Test
public void testBuildComponents_AllGood_BehavesAsExpected() throws ClassNotFoundException, InvocationTargetException, NoSuchFieldException, InstantiationException, IllegalAccessException {
BeanDefinition beanDefinition = new BeanDefinition();
final String id = "bean";
beanDefinition.setId(id);
BeanDefinition beanDefinition1 = new BeanDefinition();
final String id1 = "bean1";
beanDefinition1.setId(id1);
List<BeanDefinition> componentDefinitions = new ArrayList<>();
componentDefinitions.add(beanDefinition);
componentDefinitions.add(beanDefinition1);
EcoTopologyDefinition ecoTopologyDefinition = new EcoTopologyDefinition();
ecoTopologyDefinition.setComponents(componentDefinitions);
Object object = new Object();
Object object1 = new Object();
when(mockContext.getTopologyDefinition()).thenReturn(ecoTopologyDefinition);
when(mockObjectBuilder.buildObject(eq(beanDefinition), eq(mockContext))).thenReturn(object);
when(mockObjectBuilder.buildObject(eq(beanDefinition1), eq(mockContext))).thenReturn(object1);
subject.buildComponents(mockContext, mockObjectBuilder);
verify(mockContext).getTopologyDefinition();
verify(mockObjectBuilder).buildObject(same(beanDefinition), same(mockContext));
verify(mockObjectBuilder).buildObject(same(beanDefinition1), same(mockContext));
verify(mockContext).addComponent(eq(id), anyObject());
verify(mockContext).addComponent(eq(id1), anyObject());
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues.
@Test
public void testBuildConfig_SpecifyingComponentResources_ReturnsCorrectValues() throws Exception {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(YAML_PROPERTIES.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
Config config = subject.buildConfig(ecoTopologyDefinition);
assertThat(config.get(Config.TOPOLOGY_COMPONENT_RAMMAP), is(equalTo("spout-1:256000000,bolt-1:256000000")));
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow.
@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectGBResourceFormat_ExceptionThrow() throws Exception {
Config config = null;
try {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(INCORRECT_GB_FORMAT_YAML.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
config = subject.buildConfig(ecoTopologyDefinition);
} finally {
assertNull(config);
}
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class ConfigBuilderTest method testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow.
@Test(expected = IllegalArgumentException.class)
public void testBuildConfig_IncorrectMBResourceFormat_ExceptionThrow() throws Exception {
Config config = null;
try {
EcoParser ecoParser = new EcoParser();
InputStream inputStream = new ByteArrayInputStream(INCORRECT_MB_FORMAT_YAML.getBytes());
FileInputStream mockPropsStream = PowerMockito.mock(FileInputStream.class);
EcoTopologyDefinition ecoTopologyDefinition = ecoParser.parseFromInputStream(inputStream, mockPropsStream, false);
config = subject.buildConfig(ecoTopologyDefinition);
} finally {
assertNull(config);
}
}
use of com.twitter.heron.eco.definition.EcoTopologyDefinition in project incubator-heron by apache.
the class EcoBuilderTest method setUpForEachTestCase.
@Before
public void setUpForEachTestCase() {
configMap = new HashMap<>();
ecoTopologyDefinition = new EcoTopologyDefinition();
ecoTopologyDefinition.setConfig(configMap);
}
Aggregations