Utils { public static String buildKeyIndexForEvent(Event event, List<String> groupBy) { StringBuffer stringBuffer = new StringBuffer(); if (groupBy == null || groupBy.size() == 0) return stringBuffer.toString(); for (String groupField : groupBy) { Collection<Tuple> tuples = event.getAll(groupField); SortedSet<String> values = new TreeSet<String>(); if (tuples == null) { values.add(""); } else { for (Tuple tuple : tuples) values.add(registry.encode(tuple.getValue())); } stringBuffer.append(groupField + join(values, "") + "|"); } try { return stringBuffer.toString(); } catch (Exception e) { return null; } } private  Utils(); static String buildKeyIndexForEvent(Event event, List<String> groupBy); static String buildKeyIndexForEvent(String flowId, Event event, List<String> groupBy); static String getNextStreamFromFlowInfo(Flow flow, String streamName, int idx); static boolean hasNextOutput(Flow flow, String streamName, String nextStream); static boolean exportsToOtherStreams(Flow flow, String streamName, String nextStream); static T getFlowOpFromStream(Flow flow, String stream, int idx); static T getFlowOpFromStream(Map<String, Flow> flows, String flowId, String stream, int idx); static void flowsMap(backtype.storm.tuple.Tuple tuple, Map<String,Flow> flows);  }
@Test public void test_buildKeyIndexForEvent_noGroupBy() { String hash = buildKeyIndexForEvent("one", buildTestEvent(), EMPTY_LIST); assertEquals("one", hash); }
@Test public void test_buildKeyIndexForEvent_groupBySingleField() { String hash = buildKeyIndexForEvent("one", buildTestEvent(), Collections.singletonList("key2")); assertEquals("onekey2val2|", hash); }
@Test public void test_buildKeyIndexForEvent_groupByMultiField() { String hash = buildKeyIndexForEvent("one", buildTestEvent(), Arrays.asList(new String[]{"key1", "key2"})); assertEquals("onekey1val1val5|key2val2|", hash); }