### Question:
CodeGenerator { public String next() { this.intSeed++; if(this.intSeed > 9999) { throw new IndexOutOfBoundsException(); } return String.format("%04d", this.intSeed); } CodeGenerator(String seed); String next();  }### Answer:
@Test public void next_seed_is_null() { CodeGenerator generator = new CodeGenerator(null); assertThat(generator.next()).isEqualTo("0001"); assertThat(generator.next()).isEqualTo("0002"); }
@Test public void next_seed_is_blank_string() { CodeGenerator generator = new CodeGenerator(" "); assertThat(generator.next()).isEqualTo("0001"); assertThat(generator.next()).isEqualTo("0002"); }
@Test public void next_seed_all_is_zero() { CodeGenerator generator = new CodeGenerator("0000"); assertThat(generator.next()).isEqualTo("0001"); assertThat(generator.next()).isEqualTo("0002"); }
@Test public void next_seed_is_valid() { CodeGenerator generator = new CodeGenerator("0003"); assertThat(generator.next()).isEqualTo("0004"); assertThat(generator.next()).isEqualTo("0005"); generator = new CodeGenerator("0009"); assertThat(generator.next()).isEqualTo("0010"); assertThat(generator.next()).isEqualTo("0011"); }
@Test public void next_seed_out_of_bound() { CodeGenerator generator = new CodeGenerator("9999"); Assertions.assertThrows(IndexOutOfBoundsException.class, () -> generator.next()); }