Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

(#138) TimeTrackEntry: description should not be optional #139

Merged
merged 1 commit into from
Jan 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ final class EntrySpec {
*
* @param date the date when the entry was worked
* @param duration the duration for the work
* @param description description for the work (may be {@code null})
* @param description description for the work
* @param type the work type (eg. "Development") (may be {@code null})
* @since 0.4.0
*/
Expand Down Expand Up @@ -182,7 +182,7 @@ public Xml asXml() {
.append(String.valueOf(this.duration.toMinutes()))
.append("</duration>")
.append("<description>")
.append(Optional.ofNullable(this.description).orElse(""))
.append(this.description)
.append("</description>");

Optional.ofNullable(this.type).ifPresent(t ->
Expand All @@ -207,7 +207,7 @@ public Xml asXml() {
public int hashCode() {
return this.duration.hashCode()
^ this.date.hashCode()
^ Optional.ofNullable(this.description).hashCode()
^ this.description.hashCode()
^ Optional.ofNullable(this.type).hashCode();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/llorllale/youtrack/api/TimeTrackEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public interface TimeTrackEntry {
/**
* The item's description.
*
* @return the item's description (if any was entered)
* @return the item's description
* @since 0.4.0
*/
Optional<String> description();
String description();

/**
* The entry's {@link TimeTrackEntryType type}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ public Duration duration() {
}

@Override
public Optional<String> description() {
return this.xml.textOf("description");
public String description() {
return this.xml.textOf("description").get();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.time.Duration;
import java.time.Instant;
import java.time.ZoneId;
import static org.hamcrest.CoreMatchers.is;
import org.junit.Test;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -76,7 +75,7 @@ public void testDuration() {
@Test
public void testDescription() {
assertThat(
new XmlTimeTrackEntry(issue(), xml).description().get(),
new XmlTimeTrackEntry(issue(), xml).description(),
is("first work item")
);
}
Expand Down