From ecb1f8e8fe2b48ebbb10cb05f28c52ad8a2769a5 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:02:57 -0700 Subject: [PATCH 01/12] RtStatusesTest: fix JavaDoc descriptions --- src/test/java/com/jcabi/github/RtStatusesTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/jcabi/github/RtStatusesTest.java b/src/test/java/com/jcabi/github/RtStatusesTest.java index e853cf43a..1c4b06227 100644 --- a/src/test/java/com/jcabi/github/RtStatusesTest.java +++ b/src/test/java/com/jcabi/github/RtStatusesTest.java @@ -38,7 +38,7 @@ import org.junit.Test; /** - * Testcase for RtCommits. + * Testcase for {@link RtStatuses}. * * @author Marcin Cylke (marcin.cylke+github@gmail.com) * @version $Id$ @@ -48,7 +48,7 @@ public class RtStatusesTest { /** - * Tests creating a Commit. + * Tests creating a Status. * * @throws Exception when an Error occurs */ From 1626224527871c39cdde825732531bfdf6fc8be2 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:12:36 -0700 Subject: [PATCH 02/12] fix @NotNull message for Statuses.Smart ctor param --- src/main/java/com/jcabi/github/Statuses.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index 7b3bc3bd6..2bc0d701d 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -111,7 +111,7 @@ final class Smart implements Statuses { * @param stats Status */ public Smart( - @NotNull(message = "cmt can't be NULL") + @NotNull(message = "statuses can't be NULL") final Statuses stats ) { this.statuses = stats; From 2a0a9fe0f143af180ea5e92dfe8f262aca5cabf2 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:13:53 -0700 Subject: [PATCH 03/12] Make Statuses.Smart.message's @throws more uniform --- src/main/java/com/jcabi/github/Statuses.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index 2bc0d701d..b4868bbda 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -120,7 +120,7 @@ public Smart( /** * Get its message. * @return Message of commit - * @throws java.io.IOException If there is any I/O problem + * @throws IOException If there is any I/O problem */ @NotNull(message = "message is never NULL") public String message() throws IOException { From ffddd405ff8954933d23493a6711dfb711da9f51 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:36:16 -0700 Subject: [PATCH 04/12] add stub MkStatuses with @todo to implement it --- .../java/com/jcabi/github/mock/MkCommits.java | 2 +- .../com/jcabi/github/mock/MkStatuses.java | 97 +++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/jcabi/github/mock/MkStatuses.java diff --git a/src/main/java/com/jcabi/github/mock/MkCommits.java b/src/main/java/com/jcabi/github/mock/MkCommits.java index f9766ab0d..927109f07 100644 --- a/src/main/java/com/jcabi/github/mock/MkCommits.java +++ b/src/main/java/com/jcabi/github/mock/MkCommits.java @@ -118,6 +118,6 @@ public Commit get( public Statuses statuses( @NotNull(message = "sha can't be NULL") final String sha ) { - throw new UnsupportedOperationException("Not implemented"); + return new MkStatuses(this.get(sha)); } } diff --git a/src/main/java/com/jcabi/github/mock/MkStatuses.java b/src/main/java/com/jcabi/github/mock/MkStatuses.java new file mode 100644 index 000000000..ed9925cc4 --- /dev/null +++ b/src/main/java/com/jcabi/github/mock/MkStatuses.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2013-2015, jcabi.com + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: 1) Redistributions of source code must retain the above + * copyright notice, this list of conditions and the following + * disclaimer. 2) Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. 3) Neither the name of the jcabi.com nor + * the names of its contributors may be used to endorse or promote + * products derived from this software without specific prior written + * permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT + * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.jcabi.github.mock; + +import com.jcabi.aspects.Immutable; +import com.jcabi.aspects.Loggable; +import com.jcabi.github.Commit; +import com.jcabi.github.Status; +import com.jcabi.github.Statuses; +import java.io.IOException; +import javax.json.JsonObject; +import javax.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; + +/** + * Mock of GitHub commit statuses. + * @author Chris Rebert (github@rebertia.com) + * @version $Id$ + * @since 0.24 + * @todo Finish implementing this class (MkStatuses), a mock of GitHub's + * commits statuses (the "Statuses" interface). + */ +@Immutable +@Loggable(Loggable.DEBUG) +@EqualsAndHashCode(of = { "cmmt" }) +final class MkStatuses implements Statuses { + /** + * Commit whose statuses this represents. + */ + private final transient Commit cmmt; + + /** + * Ctor. + * @param cmt Commit whose statuses this represents + */ + MkStatuses( + @NotNull(message = "commit can't be NULL") + final Commit cmt + ) { + this.cmmt = cmt; + } + + @Override + @NotNull(message = "commit is never NULL") + public Commit commit() { + return this.cmmt; + } + + @Override + public Status create( + @NotNull(message = "status creation data can't be NULL") + final StatusCreate status + ) throws IOException { + throw new UnsupportedOperationException("Not yet implemented"); + } + + @Override + @NotNull(message = "iterable of statuses is never NULL") + public Iterable list( + @NotNull(message = "ref can't be NULL") final String ref + ) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + @Override + @NotNull(message = "JSON is never NULL") + public JsonObject json() { + throw new UnsupportedOperationException("Yet to be implemented"); + } +} From 8dcb119bf451b07b4a536d8b6350f7f70a95a0ad Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:36:37 -0700 Subject: [PATCH 05/12] add missing @NotNull annotation to MkCommits.statuses --- src/main/java/com/jcabi/github/mock/MkCommits.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/jcabi/github/mock/MkCommits.java b/src/main/java/com/jcabi/github/mock/MkCommits.java index 927109f07..7af196f2b 100644 --- a/src/main/java/com/jcabi/github/mock/MkCommits.java +++ b/src/main/java/com/jcabi/github/mock/MkCommits.java @@ -115,6 +115,7 @@ public Commit get( } @Override + @NotNull(message = "statuses is never NULL") public Statuses statuses( @NotNull(message = "sha can't be NULL") final String sha ) { From 9865cae33d8f59d3ed872615e900b20118982854 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 16 Jun 2015 23:59:35 -0700 Subject: [PATCH 06/12] add missing @NotNull annotations to Statuses.create & RtStatuses.create --- src/main/java/com/jcabi/github/RtStatuses.java | 1 + src/main/java/com/jcabi/github/Statuses.java | 1 + 2 files changed, 2 insertions(+) diff --git a/src/main/java/com/jcabi/github/RtStatuses.java b/src/main/java/com/jcabi/github/RtStatuses.java index 7b8acbb9d..9ba46a89b 100644 --- a/src/main/java/com/jcabi/github/RtStatuses.java +++ b/src/main/java/com/jcabi/github/RtStatuses.java @@ -100,6 +100,7 @@ public final Commit commit() { * @throws IOException In case of any I/O problems */ @Override + @NotNull(message = "status is never NULL") public final Status create( @NotNull(message = "status can't be NULL") final StatusCreate status ) throws IOException { diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index b4868bbda..48a68fd9e 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -74,6 +74,7 @@ public interface Statuses extends JsonReadable { * @return The added status * @see Create a Status */ + @NotNull(message = "status is never NULL") Status create( @NotNull(message = "status creation data can't be NULL") final StatusCreate status From 99b54716cbcf9bddbcea683601c9dc27dbac42f6 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 00:01:56 -0700 Subject: [PATCH 07/12] Fix @NotNull message for {,Rt}Commits.statuses --- src/main/java/com/jcabi/github/Commits.java | 2 +- src/main/java/com/jcabi/github/RtCommits.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jcabi/github/Commits.java b/src/main/java/com/jcabi/github/Commits.java index 164d00ef9..f230b260c 100644 --- a/src/main/java/com/jcabi/github/Commits.java +++ b/src/main/java/com/jcabi/github/Commits.java @@ -77,6 +77,6 @@ Commit create( * @since 0.23 * @return Status */ - @NotNull(message = "status is never NULL") + @NotNull(message = "statuses is never NULL") Statuses statuses(@NotNull(message = "sha can't be NULL") final String ref); } diff --git a/src/main/java/com/jcabi/github/RtCommits.java b/src/main/java/com/jcabi/github/RtCommits.java index c47dc36db..786d53fbc 100644 --- a/src/main/java/com/jcabi/github/RtCommits.java +++ b/src/main/java/com/jcabi/github/RtCommits.java @@ -111,7 +111,7 @@ public Commit get( } @Override - @NotNull(message = "status is never NULL") + @NotNull(message = "statuses is never NULL") public Statuses statuses( @NotNull(message = "ref can't be NULL") final String ref ) { From 03bee4165d1f9749fb0f2095efced0b11e1bcf28 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 00:28:00 -0700 Subject: [PATCH 08/12] Remove absurd Statuses.Smart.message method --- src/main/java/com/jcabi/github/Statuses.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index 48a68fd9e..7b16cd226 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -118,15 +118,6 @@ public Smart( this.statuses = stats; this.jsn = new SmartJson(this.statuses); } - /** - * Get its message. - * @return Message of commit - * @throws IOException If there is any I/O problem - */ - @NotNull(message = "message is never NULL") - public String message() throws IOException { - return this.jsn.text("message"); - } /** * Get its URL. * @return URL of comment From 2392f70904fefd1572bfd93b40a10be24318819b Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 00:42:38 -0700 Subject: [PATCH 09/12] Remove broken Statuses.Smart.url method --- src/main/java/com/jcabi/github/Statuses.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index 7b16cd226..783d8914c 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -118,15 +118,7 @@ public Smart( this.statuses = stats; this.jsn = new SmartJson(this.statuses); } - /** - * Get its URL. - * @return URL of comment - * @throws IOException If there is any I/O problem - */ - @NotNull(message = "URL is never NULL") - public URL url() throws IOException { - return new URL(this.jsn.text("url")); - } + @Override @NotNull(message = "commit is never NULL") public Commit commit() { From d288364af5028c72e2a2c91c29343bae11fffcbe Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 00:50:28 -0700 Subject: [PATCH 10/12] Remove Statuses.Smart class since it adds no functionality --- src/main/java/com/jcabi/github/Statuses.java | 57 -------------------- 1 file changed, 57 deletions(-) diff --git a/src/main/java/com/jcabi/github/Statuses.java b/src/main/java/com/jcabi/github/Statuses.java index 783d8914c..1477d9d0c 100644 --- a/src/main/java/com/jcabi/github/Statuses.java +++ b/src/main/java/com/jcabi/github/Statuses.java @@ -33,7 +33,6 @@ import com.jcabi.aspects.Immutable; import com.jcabi.aspects.Loggable; import java.io.IOException; -import java.net.URL; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; @@ -91,62 +90,6 @@ Iterable list( @NotNull(message = "ref can't be NULL") final String ref ); - /** - * Smart commit. - */ - @Immutable - @ToString - @Loggable(Loggable.DEBUG) - @EqualsAndHashCode(of = { "statuses", "jsn" }) - final class Smart implements Statuses { - /** - * Encapsulated status. - */ - private final transient Statuses statuses; - /** - * SmartJson object for convenient JSON parsing. - */ - private final transient SmartJson jsn; - /** - * Public ctor. - * @param stats Status - */ - public Smart( - @NotNull(message = "statuses can't be NULL") - final Statuses stats - ) { - this.statuses = stats; - this.jsn = new SmartJson(this.statuses); - } - - @Override - @NotNull(message = "commit is never NULL") - public Commit commit() { - return this.statuses.commit(); - } - - @Override - public Status create( - @NotNull(message = "status can't be NULL") - final StatusCreate status - ) throws IOException { - return this.statuses.create(status); - } - - @Override - public Iterable list( - @NotNull(message = "ref can't be NULL") final String ref - ) { - return this.statuses.list(ref); - } - - @Override - @NotNull(message = "JSON is never NULL") - public JsonObject json() throws IOException { - return this.statuses.json(); - } - } - /** * Data to use when creating a new GitHub commit status. * From 2c625833ed2e6436152834a0c554c96ae276d378 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 16:42:46 -0700 Subject: [PATCH 11/12] MkCommits.statuses: dedent sha param --- src/main/java/com/jcabi/github/mock/MkCommits.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jcabi/github/mock/MkCommits.java b/src/main/java/com/jcabi/github/mock/MkCommits.java index 7af196f2b..9449696be 100644 --- a/src/main/java/com/jcabi/github/mock/MkCommits.java +++ b/src/main/java/com/jcabi/github/mock/MkCommits.java @@ -117,7 +117,7 @@ public Commit get( @Override @NotNull(message = "statuses is never NULL") public Statuses statuses( - @NotNull(message = "sha can't be NULL") final String sha + @NotNull(message = "sha can't be NULL") final String sha ) { return new MkStatuses(this.get(sha)); } From c7045ebaa9b0a5ba03d39de3f47564dd99a0804f Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Wed, 17 Jun 2015 16:44:14 -0700 Subject: [PATCH 12/12] add issue number and duration to MkStatuses @todo --- src/main/java/com/jcabi/github/mock/MkStatuses.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jcabi/github/mock/MkStatuses.java b/src/main/java/com/jcabi/github/mock/MkStatuses.java index ed9925cc4..c8e491778 100644 --- a/src/main/java/com/jcabi/github/mock/MkStatuses.java +++ b/src/main/java/com/jcabi/github/mock/MkStatuses.java @@ -44,8 +44,8 @@ * @author Chris Rebert (github@rebertia.com) * @version $Id$ * @since 0.24 - * @todo Finish implementing this class (MkStatuses), a mock of GitHub's - * commits statuses (the "Statuses" interface). + * @todo #1129:30min Finish implementing this class (MkStatuses), a mock of + * GitHub's commits statuses (the "Statuses" interface). */ @Immutable @Loggable(Loggable.DEBUG)