Todo { public static Builder getBuilder(String title) { return new Builder(title); } private  Todo(Builder builder); static Builder getBuilder(String title); Long getId(); LocalDateTime getCreationTime(); String getDescription(); LocalDateTime getModificationTime(); String getTitle(); @Override String toString();  }
@Test public void build_titleIsSet_shouldCreateNewObjectAndSetTitle() { Todo created = Todo.getBuilder(TITLE).build(); assertThatTodo(created) .hasNoDescription() .hasNoId() .hasTitle(TITLE) .creationTimeIsNotSet() .modificationTimeIsNotSet(); }
@Test(expected = IllegalStateException.class) public void build_titleIsNull_ShouldThrowException() { Todo.getBuilder(null).build(); }
@Test(expected = IllegalStateException.class) public void build_titleIsEmpty_ShouldThrowException() { Todo.getBuilder("").build(); }
@Test public void build_setAllValues_shouldCreateNewObjectAndSetAllFields() { Todo created = Todo.getBuilder(TITLE) .creationTime(TIMESTAMP) .description(DESCRIPTION) .id(ID) .modificationTime(TIMESTAMP) .build(); assertThatTodo(created) .hasDescription(DESCRIPTION) .hasId(ID) .hasTitle(TITLE) .wasCreatedAt(TIMESTAMP_STRING) .wasModifiedAt(TIMESTAMP_STRING); }