@Test public void hash_fallback_first_section() { OrganizationSection section1 = new OrganizationSection(OrgSectionType.UNKNOWN, new String[]{"unknown1"}, -1); OrganizationSection section2 = new OrganizationSection(OrgSectionType.UNKNOWN, new String[]{"unknown2"}, -1); OrganizationSection section3 = new OrganizationSection(OrgSectionType.UNKNOWN, new String[]{"unknown3"}, -1); String section1_hash = "section1_hash"; when(sectionsSplitter.splitToSectionsDetailed(organizationName)).thenReturn(ImmutableList.of(section1, section2, section3)); when(sectionHasher.hash(section1)).thenReturn(section1_hash); String retHash = mainSectionBucketHasher.hash(organizationName); assertEquals(section1_hash, retHash); verify(sectionsSplitter).splitToSectionsDetailed(organizationName); verify(sectionHasher).hash(section1); }
public String hash(String organizationName) { List<OrganizationSection> sections = sectionsSplitter.splitToSectionsDetailed(organizationName); if (sections.isEmpty()) { return ""; } OrganizationSection mainSection = pickMainSection(sections); return sectionHasher.hash((mainSection != null) ? mainSection : pickFallbackSection(sections)); }
MainSectionBucketHasher implements BucketHasher<String> { public String hash(String organizationName) { List<OrganizationSection> sections = sectionsSplitter.splitToSectionsDetailed(organizationName); if (sections.isEmpty()) { return ""; } OrganizationSection mainSection = pickMainSection(sections); return sectionHasher.hash((mainSection != null) ? mainSection : pickFallbackSection(sections)); } }
MainSectionBucketHasher implements BucketHasher<String> { public String hash(String organizationName) { List<OrganizationSection> sections = sectionsSplitter.splitToSectionsDetailed(organizationName); if (sections.isEmpty()) { return ""; } OrganizationSection mainSection = pickMainSection(sections); return sectionHasher.hash((mainSection != null) ? mainSection : pickFallbackSection(sections)); }  }
MainSectionBucketHasher implements BucketHasher<String> { public String hash(String organizationName) { List<OrganizationSection> sections = sectionsSplitter.splitToSectionsDetailed(organizationName); if (sections.isEmpty()) { return ""; } OrganizationSection mainSection = pickMainSection(sections); return sectionHasher.hash((mainSection != null) ? mainSection : pickFallbackSection(sections)); }  String hash(String organizationName); void setSectionsSplitter(OrganizationSectionsSplitter sectionsSplitter); void setSectionHasher(OrganizationSectionHasher sectionHasher); void setMainSectionType(OrgSectionType mainSectionType); void setFallbackSectionPickStrategy(FallbackSectionPickStrategy fallbackSectionPickStrategy); }
MainSectionBucketHasher implements BucketHasher<String> { public String hash(String organizationName) { List<OrganizationSection> sections = sectionsSplitter.splitToSectionsDetailed(organizationName); if (sections.isEmpty()) { return ""; } OrganizationSection mainSection = pickMainSection(sections); return sectionHasher.hash((mainSection != null) ? mainSection : pickFallbackSection(sections)); }  String hash(String organizationName); void setSectionsSplitter(OrganizationSectionsSplitter sectionsSplitter); void setSectionHasher(OrganizationSectionHasher sectionHasher); void setMainSectionType(OrgSectionType mainSectionType); void setFallbackSectionPickStrategy(FallbackSectionPickStrategy fallbackSectionPickStrategy);  }