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

Commit

Permalink
(#138) TimeTrackEntry: description should not be optional
Browse files Browse the repository at this point in the history
(REF) TimeTrackEntry.description: now returns String instead of
      Optional<String>
(REF) EntrySpec: no longer assuming that user provided 'null' value for
      description
(REF) refactor: XmlTimeTrackEntry, XmlTimeTrackEntryTest
  • Loading branch information
llorllale committed Jan 10, 2018
1 parent d32cac2 commit 4059f41
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
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
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
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
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

0 comments on commit 4059f41

Please sign in to comment.