RelationIdGenerator { public String generateRelationIdentity( Collection<String> ep1Ids, SourceType ep1SourceType, Collection<String> ep2Ids, SourceType ep2SourceType, RelationType relType, String namespace) { List<String> sortedEp1Ids = Lists.newArrayList(ep1Ids); Collections.sort(sortedEp1Ids); List<String> sortedEp2Ids = Lists.newArrayList(ep2Ids); Collections.sort(sortedEp2Ids); return MD5IdGenerator.generateIdentity(namespace, relType.name(), Joiner.on(",").join(sortedEp1Ids), ep1SourceType.name(), Joiner.on(",").join(sortedEp2Ids), ep2SourceType.name()); }  String generateRelationIdentity(
      Collection<String> ep1Ids, SourceType ep1SourceType,
      Collection<String> ep2Ids, SourceType ep2SourceType,
      RelationType relType, String namespace);  }
@Test public void testGenerateRelationIdentity() { String id = idGenerator.generateRelationIdentity( ImmutableList.of("ep1", "ep11"), SourceType.SDK, ImmutableList.of("ep2", "ep21"), SourceType.PIG, RelationType.DATA_FLOW, "test"); Assert.assertEquals(MD5IdGenerator.generateIdentity("test", RelationType.DATA_FLOW.name(), "ep1,ep11", SourceType.SDK.name(), "ep2,ep21", SourceType.PIG.name()), id); }
@Test public void testSorted() { String result = idGenerator.generateRelationIdentity( ImmutableList.of("ep11", "ep1"), SourceType.SDK, ImmutableList.of("ep21", "ep2"), SourceType.PIG, RelationType.DATA_FLOW, "test"); String expected = idGenerator.generateRelationIdentity( ImmutableList.of("ep1", "ep11"), SourceType.SDK, ImmutableList.of("ep2", "ep21"), SourceType.PIG, RelationType.DATA_FLOW, "test"); assertEquals(expected, result); }