Skip to content

Commit

Permalink
#1382 Repo.Smart exists() + IT case
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed Apr 7, 2018
1 parent da1f79f commit 851fa03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/jcabi/github/Existence.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@
* @author Mihai Andronache ([email protected])
* @version $Id$
* @since 0.38
* @todo #1379:30min Use this class to implement Smart.exists() method for all
* Github entities we have (Repo, Issue, User etc).
* @todo #1382:30min Use this class to implement Smart.exists() method for all
* Github entities we have (Comment, Issue, User etc). Maybe we can make
* JsonReadable abstract and have method exists() there.
*/
@Immutable
@Loggable(Loggable.DEBUG)
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/jcabi/github/Repo.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ public Smart(
this.repo = rep;
this.jsn = new SmartJson(rep);
}

/**
* Does this Repo actually exist in Github?
* @return True if it exists, false otherwise.
* @throws IOException If there is any I/O problem.
*/
public boolean exists() throws IOException {
return new Existence(this.repo).check();
}

/**
* Does it have a description.
* @return TRUE if description is present
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/com/jcabi/github/RtRepoITCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,17 @@ public void iteratesEvents() throws Exception {
);
}

/**
* RtRepo can tell if it exists.
* @throws Exception If something goes wrong.
*/
@Test
public void exists() throws Exception {
MatcherAssert.assertThat(
new Repo.Smart(repo).exists(), Matchers.is(Boolean.TRUE)
);
}

/**
* RtRepo can fetch its commits.
* @throws Exception If some problem inside
Expand Down

2 comments on commit 851fa03

@0pdd
Copy link

@0pdd 0pdd commented on 851fa03 Apr 7, 2018

Choose a reason for hiding this comment

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

Puzzle 1379-ca8e6892 disappeared from src/main/java/com/jcabi/github/Existence.java, that's why I closed #1382. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 851fa03 Apr 7, 2018

Choose a reason for hiding this comment

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

Puzzle 1382-3526ef36 discovered in src/main/java/com/jcabi/github/Existence.java and submitted as #1384. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.