Skip to content

update to User interface to see an accept invitations#1514

Open
ShalomGottesman wants to merge 4 commits into
jcabi:masterfrom
ShalomGottesman:master
Open

update to User interface to see an accept invitations#1514
ShalomGottesman wants to merge 4 commits into
jcabi:masterfrom
ShalomGottesman:master

Conversation

@ShalomGottesman

Copy link
Copy Markdown
Contributor

This request is a correction to a previous one that had extra code and missed annotations. see #1513

@0crat 0crat added the scope label Jan 20, 2020
@0crat

0crat commented Jan 20, 2020

Copy link
Copy Markdown

Job #1514 is now in scope, role is REV

@ShalomGottesman

Copy link
Copy Markdown
Contributor Author

I learned that if I push more updates to the same branch that already has a pull request, then the new commits are added to that request. My apologies for making two requests into one. Next time I will open a separate branch if I want to request two commits be added.

@amihaiemil

Copy link
Copy Markdown
Member

@ShalomGottesman I don't really understand, this PR looks almost the same as the initial one :D
You can just fix that PR and it's ok.

@edmoffo edmoffo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The change adds two interface methods and an implementation on the Smart inner class, but several issues block merging. Four inline notes below cover a correctness bug in invitations(), a missing test, indentation that does not match the rest of the file, and dead body() calls on GET requests.

coordsSet.add(
new Coordinates.Simple(
invite.getString("name"),
invite.getJsonObject("owner").getString("login")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Arguments are swapped. Coordinates.Simple takes (user, repo), so this should be (owner.login, name), not (name, owner.login). The current order yields coordinates whose user() returns the repo name.

@Override
public boolean acceptInvitation(final Coordinates coords) throws IOException {
Iterator<JsonValue> iter = this.github().entry().uri().path("/user/repository_invitations").back().method(Request.GET)
.body().back()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

body().back() on a GET adds nothing. Drop the body() call here and in invitations() above; the request is already a GET and the body builder is no longer setting any payload.

.back();
}

public Iterable<String> invitees() throws IOException {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No test covers RtRepo.invitees(). Add an RtRepoTest case that mocks the /invitations endpoint with MkContainer and asserts the parsed login set, otherwise the parsing of invitee.login is unverified.

Set<String> invitees = new HashSet<String>();
while (iter.hasNext()) {
JsonObject val = (JsonObject) iter.next();
invitees.add(val.getJsonObject("invitee").getString("login"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Indentation in this method mixes tabs and spaces. The rest of the file uses four-space indent only; please normalize to match before merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants