V09Support { static List<String> getAgentRollupIdsV09(String agentId) { List<String> agentRollupIds = new ArrayList<>(); int nextFoundIndex = agentId.lastIndexOf("::", agentId.length() - 3); if (nextFoundIndex == -1) { agentRollupIds.add(agentId); } else { agentRollupIds.add(agentId.substring(agentId.lastIndexOf("::", agentId.length()) + 2)); while (nextFoundIndex != -1) { agentRollupIds.add(agentId.substring(0, nextFoundIndex).replace("::", "/")); nextFoundIndex = agentId.lastIndexOf("::", nextFoundIndex - 1); } } return agentRollupIds; }    }
@Test public void shouldGetAgentRollupIdsV09() { assertThat(V09Support.getAgentRollupIdsV09("aaa")).containsExactly("aaa"); assertThat(V09Support.getAgentRollupIdsV09("aaa::bbb")).containsExactly("bbb", "aaa"); assertThat(V09Support.getAgentRollupIdsV09("aaa::bbb::ccc")).containsExactly("ccc", "aaa/bbb", "aaa"); assertThat(V09Support.getAgentRollupIdsV09("a")).containsExactly("a"); assertThat(V09Support.getAgentRollupIdsV09("a::b")).containsExactly("b", "a"); assertThat(V09Support.getAgentRollupIdsV09("a::b::c")).containsExactly("c", "a/b", "a"); assertThat(V09Support.getAgentRollupIdsV09("a:b:c")).containsExactly("a:b:c"); }