Skip to content

Commit

Permalink
style check corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
ShalomGottesman committed May 27, 2020
1 parent 609921b commit 739f7bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
15 changes: 8 additions & 7 deletions src/main/java/com/jcabi/github/Collaborators.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,22 @@ public interface Collaborators {
void add(String user) throws IOException;

/**
* Different permission levels a user can be granted in an organization repository.
* Permission levels a user can be granted in an organization repository.
*
* @see <a href="https://developer.github.com/v3/repos/collaborators/#parameters-1">Add user with permissions</a>
*/
static enum Permission {PULL, PUSH, ADMIN, MAINTAIN, TRIAGE};
static enum Permission { PULL, PUSH, ADMIN, MAINTAIN, TRIAGE };

/**
* Add user as a collaborator with specific permissions. Only works on an organization repository
* @param user User to add
* Add user with specific permissions. Only works on an organization repository
*
* @param User User to add
* @param permission permission level to grant
* @throws IOException if there is an I/O problem
* @see <a href=https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator">Add user as a collaborator</a>
*/
void addWithPermission(String user, Permission permission) throws IOException;



/**
* Remove user as a collaborator.
*
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/com/jcabi/github/RtCollaborators.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.jcabi.http.response.RestResponse;
import java.io.IOException;
import java.net.HttpURLConnection;

import javax.json.Json;
import javax.json.JsonObject;
import lombok.EqualsAndHashCode;
Expand Down Expand Up @@ -118,18 +117,20 @@ public void add(
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_NO_CONTENT);
}

@Override
public void addWithPermission(
String user, Permission permission)
throws IOException {
JsonObject obj = Json.createObjectBuilder().add("permission", permission.toString().toLowerCase()).build();
this.request.method(Request.PUT)
.body().set(obj).back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_CREATED);
}
public void addWithPermission(
final String user, final Permission permission
) throws IOException {
JsonObject obj = Json.createObjectBuilder()
.add("permission", permission.toString().toLowerCase())
.build();
this.request.method(Request.PUT)
.body().set(obj).back()
.fetch()
.as(RestResponse.class)
.assertStatus(HttpURLConnection.HTTP_CREATED);
}

@Override
public void remove(
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/com/jcabi/github/mock/MkCollaborators.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.jcabi.github.User;
import com.jcabi.xml.XML;
import java.io.IOException;

import org.apache.commons.lang3.NotImplementedException;
import org.xembly.Directives;

Expand Down Expand Up @@ -171,8 +170,10 @@ private String xpath() {
);
}

@Override
public void addWithPermission(String user, Permission permission) throws IOException {
throw new NotImplementedException("");
}
@Override
public void addWithPermission(
final String user, final Permission permission
) throws IOException {
throw new NotImplementedException("");
}
}

0 comments on commit 739f7bd

Please sign in to comment.