### Question:
MultiHostgroupDownscaleFlowEventChainFactory implements FlowEventChainFactory<MultiHostgroupClusterAndStackDownscaleTriggerEvent> { @Override public Queue<Selectable> createFlowTriggerEventQueue(MultiHostgroupClusterAndStackDownscaleTriggerEvent event) { Queue<Selectable> flowEventChain = new ConcurrentLinkedQueue<>(); for (Entry<String, Set<Long>> entry : event.getInstanceIdsByHostgroupMap().entrySet()) { ClusterScaleTriggerEvent cste; cste = new ClusterDownscaleTriggerEvent(DECOMMISSION_EVENT.event(), event.getResourceId(), entry.getKey(), entry.getValue(), event.accepted(), event.getDetails()); flowEventChain.add(cste); if (event.getScalingType() == ScalingType.DOWNSCALE_TOGETHER) { StackScaleTriggerEvent sste; sste = new StackDownscaleTriggerEvent(STACK_DOWNSCALE_EVENT.event(), event.getResourceId(), entry.getKey(), entry.getValue()); flowEventChain.add(sste); } } return flowEventChain; }  @Override String initEvent(); @Override Queue<Selectable> createFlowTriggerEventQueue(MultiHostgroupClusterAndStackDownscaleTriggerEvent event);  }### Answer:
@Test public void testCreateFlowWithTwoHostgroup() { Map<String, Set<Long>> instanceIdsByHostgroupMap = new HashMap<>(); instanceIdsByHostgroupMap.put("firstGroup", Sets.newHashSet(1L, 2L)); instanceIdsByHostgroupMap.put("secondGroup", Sets.newHashSet(3L, 4L)); ClusterDownscaleDetails details = new ClusterDownscaleDetails(); MultiHostgroupClusterAndStackDownscaleTriggerEvent event = new MultiHostgroupClusterAndStackDownscaleTriggerEvent("selector", 1L, instanceIdsByHostgroupMap, details, ScalingType.DOWNSCALE_TOGETHER, new Promise<>()); Queue<Selectable> queue = underTest.createFlowTriggerEventQueue(event); assertEquals(4L, queue.size()); assertEquals(DECOMMISSION_EVENT.event(), queue.poll().selector()); assertEquals(STACK_DOWNSCALE_EVENT.event(), queue.poll().selector()); assertEquals(DECOMMISSION_EVENT.event(), queue.poll().selector()); assertEquals(STACK_DOWNSCALE_EVENT.event(), queue.poll().selector()); }