### Question:
SegmentNameBuilder { String createSegmentName(String uuid) { if (distribution == 16) { return prefix + uuid.substring(0, length); } else { return prefix + buildSegmentName(uuid.substring(0, length).toCharArray()); } } SegmentNameBuilder(SegmentSize partition);   }### Answer:
@Test public void shouldCreateOneSegment() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(ONE); assertThat(nameBuilder.createSegmentName("abc"), equalTo("seg1-0")); assertThat(nameBuilder.createSegmentName("f0e"), equalTo("seg1-0")); assertThat(nameBuilder.createSegmentName("329"), equalTo("seg1-0")); }
@Test public void shouldCreateFourSegments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(FOUR); assertThat(nameBuilder.createSegmentName("f9cc"), equalTo("seg4-3")); assertThat(nameBuilder.createSegmentName("84c9"), equalTo("seg4-2")); assertThat(nameBuilder.createSegmentName("3799"), equalTo("seg4-0")); }
@Test public void shouldCreateEightSegments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(EIGHT); assertThat(nameBuilder.createSegmentName("fc9c"), equalTo("seg8-7")); assertThat(nameBuilder.createSegmentName("90ad"), equalTo("seg8-4")); assertThat(nameBuilder.createSegmentName("35e4"), equalTo("seg8-1")); assertThat(nameBuilder.createSegmentName("a39f"), equalTo("seg8-5")); }
@Test public void shouldCreateSixteenSegments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(SIXTEEN); assertThat(nameBuilder.createSegmentName("fc9a054"), equalTo("seg16-f")); assertThat(nameBuilder.createSegmentName("b0a945e"), equalTo("seg16-b")); assertThat(nameBuilder.createSegmentName("7afebab"), equalTo("seg16-7")); }
@Test public void shouldCreateThirtyTwoSegments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(THIRTY_TWO); assertThat(nameBuilder.createSegmentName("f890c9"), equalTo("seg32-11101")); assertThat(nameBuilder.createSegmentName("49c39a"), equalTo("seg32-01101")); assertThat(nameBuilder.createSegmentName("b75d09"), equalTo("seg32-10010")); }
@Test public void shouldCreateSixtyFourSegments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(SIXTY_FOUR); assertThat(nameBuilder.createSegmentName("82f"), equalTo("seg64-203")); assertThat(nameBuilder.createSegmentName("9b4"), equalTo("seg64-221")); assertThat(nameBuilder.createSegmentName("068"), equalTo("seg64-012")); }
@Test public void shouldCreate256Segments() { SegmentNameBuilder nameBuilder = new SegmentNameBuilder(TWO_FIFTY); assertThat(nameBuilder.createSegmentName("a813c"), equalTo("seg256-a8")); assertThat(nameBuilder.createSegmentName("b4d01"), equalTo("seg256-b4")); assertThat(nameBuilder.createSegmentName("7122f"), equalTo("seg256-71")); }