@@ -0,0 +1,3173 @@
+package backtype.storm.utils;%0A%0Aimport backtype.storm.generated.*;%0Aimport backtype.storm.hooks.BaseWorkerHook;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport com.google.common.collect.ImmutableSet;%0Aimport junit.framework.TestCase;%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0Aimport java.nio.ByteBuffer;%0Aimport java.util.Set;%0A%0Apublic class ThriftTopologyUtilsTest extends TestCase %7B%0A    @Test%0A    public void testIsWorkerHook() %7B%0A        Assert.assertEquals(false, ThriftTopologyUtils.isWorkerHook(StormTopology._Fields.BOLTS));%0A        Assert.assertEquals(false, ThriftTopologyUtils.isWorkerHook(StormTopology._Fields.SPOUTS));%0A        Assert.assertEquals(false, ThriftTopologyUtils.isWorkerHook(StormTopology._Fields.STATE_SPOUTS));%0A        Assert.assertEquals(true, ThriftTopologyUtils.isWorkerHook(StormTopology._Fields.WORKER_HOOKS));%0A    %7D%0A%0A    @Test%0A    public void testGetComponentIdsWithWorkerHook() %7B%0A        StormTopology stormTopology = genereateStormTopology(true);%0A        Set%3CString%3E componentIds = ThriftTopologyUtils.getComponentIds(stormTopology);%0A        Assert.assertEquals(%0A                %22We expect to get the IDs of the components sans the Worker Hook%22,%0A                ImmutableSet.of(%22bolt-1%22, %22spout-1%22),%0A                componentIds);%0A    %7D%0A%0A    @Test%0A    public void testGetComponentIdsWithoutWorkerHook() %7B%0A        StormTopology stormTopology = genereateStormTopology(false);%0A        Set%3CString%3E componentIds = ThriftTopologyUtils.getComponentIds(stormTopology);%0A        Assert.assertEquals(%0A                %22We expect to get the IDs of the components sans the Worker Hook%22,%0A                ImmutableSet.of(%22bolt-1%22, %22spout-1%22),%0A                componentIds);%0A    %7D%0A%0A    @Test%0A    public void testGetComponentCommonWithWorkerHook() %7B%0A        StormTopology stormTopology = genereateStormTopology(true);%0A        ComponentCommon componentCommon = ThriftTopologyUtils.getComponentCommon(stormTopology, %22bolt-1%22);%0A        Assert.assertEquals(%0A                %22We expect to get bolt-1's common%22,%0A                new Bolt().get_common(),%0A                componentCommon);%0A    %7D%0A%0A    @Test%0A    public void testGetComponentCommonWithoutWorkerHook() %7B%0A        StormTopology stormTopology = genereateStormTopology(false);%0A        ComponentCommon componentCommon = ThriftTopologyUtils.getComponentCommon(stormTopology, %22bolt-1%22);%0A        Assert.assertEquals(%0A                %22We expect to get bolt-1's common%22,%0A                new Bolt().get_common(),%0A                componentCommon);%0A    %7D%0A%0A    private StormTopology genereateStormTopology(boolean withWorkerHook) %7B%0A        ImmutableMap%3CString,SpoutSpec%3E spouts = ImmutableMap.of(%22spout-1%22, new SpoutSpec());%0A        ImmutableMap%3CString,Bolt%3E bolts = ImmutableMap.of(%22bolt-1%22, new Bolt());%0A        ImmutableMap%3CString,StateSpoutSpec%3E state_spouts = ImmutableMap.of();%0A%0A        StormTopology stormTopology = new StormTopology(spouts, bolts, state_spouts);%0A%0A        if(withWorkerHook) %7B%0A            BaseWorkerHook workerHook = new BaseWorkerHook();%0A            stormTopology.add_to_worker_hooks(ByteBuffer.wrap(Utils.javaSerialize(workerHook)));%0A        %7D%0A%0A        return stormTopology;%0A    %7D%0A%7D%0A

add tests for ThriftTopologyUtils