Search in sources :

Example 1 with EcoTopologyDefinition

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());
}
Also used : ArrayList(java.util.ArrayList) Matchers.anyObject(org.mockito.Matchers.anyObject) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) BeanDefinition(com.twitter.heron.eco.definition.BeanDefinition) Test(org.junit.Test)

Example 2 with EcoTopologyDefinition

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")));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Config(com.twitter.heron.api.Config) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 3 with EcoTopologyDefinition

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 4 with EcoTopologyDefinition

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Config(com.twitter.heron.api.Config) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) EcoParser(com.twitter.heron.eco.parser.EcoParser) EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 5 with EcoTopologyDefinition

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);
}
Also used : EcoTopologyDefinition(com.twitter.heron.eco.definition.EcoTopologyDefinition) Before(org.junit.Before)

Aggregations

EcoTopologyDefinition (com.twitter.heron.eco.definition.EcoTopologyDefinition)26 Test (org.junit.Test)19 FileInputStream (java.io.FileInputStream)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 InputStream (java.io.InputStream)13 Config (com.twitter.heron.api.Config)12 EcoParser (com.twitter.heron.eco.parser.EcoParser)8 BoltDefinition (com.twitter.heron.eco.definition.BoltDefinition)4 StreamDefinition (com.twitter.heron.eco.definition.StreamDefinition)3 ArrayList (java.util.ArrayList)3 ObjectBuilder (com.twitter.heron.eco.builder.ObjectBuilder)2 BeanDefinition (com.twitter.heron.eco.definition.BeanDefinition)2 EcoExecutionContext (com.twitter.heron.eco.definition.EcoExecutionContext)2 GroupingDefinition (com.twitter.heron.eco.definition.GroupingDefinition)2 ObjectDefinition (com.twitter.heron.eco.definition.ObjectDefinition)2 SpoutDefinition (com.twitter.heron.eco.definition.SpoutDefinition)2 HashMap (java.util.HashMap)2 Matchers.anyObject (org.mockito.Matchers.anyObject)2 BuilderUtility (com.twitter.heron.eco.builder.BuilderUtility)1 BeanReference (com.twitter.heron.eco.definition.BeanReference)1