Skip to content

Commit

Permalink
Merge pull request #1397 from llorllale/1390
Browse files Browse the repository at this point in the history
(#1390) Fixed Release.Smart.prerelease()
  • Loading branch information
amihaiemil committed Apr 23, 2018
2 parents 5d8c7e6 + eb76cf3 commit 54ac983
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
7 changes: 6 additions & 1 deletion src/main/java/com/jcabi/github/Release.java
Expand Up @@ -37,6 +37,7 @@
import java.util.Date;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonValue;
import lombok.EqualsAndHashCode;
import lombok.ToString;

Expand Down Expand Up @@ -349,7 +350,11 @@ public void draft(final boolean draft) throws IOException {
* @throws IOException If there is any I/O problem
*/
public boolean prerelease() throws IOException {
return this.json().getBoolean("prerelease", Boolean.FALSE);
return Boolean.parseBoolean(
this.json()
.getOrDefault("prerelease", JsonValue.FALSE)
.toString().replace("\"", "")
);
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/test/java/com/jcabi/github/mock/MkReleaseTest.java
Expand Up @@ -33,11 +33,11 @@
import com.jcabi.github.Release;
import com.jcabi.github.Releases;
import java.io.IOException;
import javax.json.Json;
import javax.json.JsonString;
import javax.json.JsonValue;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
import org.junit.Test;

/**
Expand Down Expand Up @@ -194,18 +194,15 @@ public void canGetCreatedAt() throws Exception {
/**
* Smart decorator returns prerelease.
* @throws Exception If some problem inside
* @todo #1363:30min Release.Smart().prerelease() was refactored and unit
* tests written. However, this test still fails because the MkStorage
* holds the value as String instead of Boolean. Let's fix this.
*/
@Test
@Ignore
public void prerelease() throws Exception {
final Release release = MkReleaseTest.release();
final Release.Smart smart = new Release.Smart(release);
smart.prerelease(true);
release.patch(
Json.createObjectBuilder().add("prerelease", true).build()
);
MatcherAssert.assertThat(
smart.prerelease(),
new Release.Smart(release).prerelease(),
Matchers.is(true)
);
}
Expand Down

1 comment on commit 54ac983

@0pdd
Copy link

@0pdd 0pdd commented on 54ac983 Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 1363-762aa75e disappeared from src/test/java/com/jcabi/github/mock/MkReleaseTest.java, that's why I closed #1390. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.