From 691e008c57fe286af77152f2ef05fec6169793d6 Mon Sep 17 00:00:00 2001 From: George Aristy Date: Sat, 31 Mar 2018 13:15:00 -0400 Subject: [PATCH] (#164) updated checkstyle.xml (#167) * Fixed checkstyle issues in src/main/java --- checkstyle.xml | 14 ++- pom.xml | 5 + .../youtrack/api/DefaultComments.java | 32 +++--- .../llorllale/youtrack/api/DefaultFields.java | 34 +++---- .../api/DefaultIssueTimeTracking.java | 28 +++--- .../llorllale/youtrack/api/DefaultIssues.java | 98 +++++++++---------- .../youtrack/api/DefaultProjects.java | 52 +++++----- .../youtrack/api/DefaultUpdateIssue.java | 74 +++++++------- .../org/llorllale/youtrack/api/XmlIssue.java | 23 +++-- .../youtrack/api/XmlProjectField.java | 65 ++++++------ .../youtrack/api/XmlUsersOfProject.java | 32 +++--- 11 files changed, 236 insertions(+), 221 deletions(-) diff --git a/checkstyle.xml b/checkstyle.xml index 4c1a930..10537a2 100644 --- a/checkstyle.xml +++ b/checkstyle.xml @@ -75,6 +75,11 @@ + + + + + ${project.build.sourceDirectory} diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultComments.java b/src/main/java/org/llorllale/youtrack/api/DefaultComments.java index 2e4cfab..37bc0f2 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultComments.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultComments.java @@ -72,25 +72,25 @@ final class DefaultComments implements Comments { @Override public Stream stream() throws IOException, UnauthorizedException { return new StreamOf<>( - new MappedCollection<>( - xml -> new XmlComment(this.issue(), this.session, xml), - new XmlsOf( - "//comment", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString() - .concat(BASE_PATH) - .concat(this.issue().id()) - .concat("/comment") - ) - ) - ) + new MappedCollection<>( + xml -> new XmlComment(this.issue(), this.session, xml), + new XmlsOf( + "//comment", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString() + .concat(BASE_PATH) + .concat(this.issue().id()) + .concat("/comment") ) + ) ) + ) ) + ) ); } diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultFields.java b/src/main/java/org/llorllale/youtrack/api/DefaultFields.java index 31efb41..5fe64d0 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultFields.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultFields.java @@ -68,25 +68,25 @@ public Project project() { @Override public Stream stream() throws IOException, UnauthorizedException { return new StreamOf<>( - new MappedCollection<>( - x -> new XmlProjectField(x, this.project(), this.session), - new XmlsOf( - "/projectCustomFieldRefs/projectCustomField", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString() - .concat("/admin/project/") - .concat(this.project().id()) - .concat("/customfield") - ) - ) - ) - ) + new MappedCollection<>( + x -> new XmlProjectField(x, this.project(), this.session), + new XmlsOf( + "/projectCustomFieldRefs/projectCustomField", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString() + .concat("/admin/project/") + .concat(this.project().id()) + .concat("/customfield") + ) + ) ) + ) ) + ) ); } } diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultIssueTimeTracking.java b/src/main/java/org/llorllale/youtrack/api/DefaultIssueTimeTracking.java index f47ffe8..d304f74 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultIssueTimeTracking.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultIssueTimeTracking.java @@ -75,23 +75,23 @@ final class DefaultIssueTimeTracking implements IssueTimeTracking { @Override public Stream stream() throws IOException, UnauthorizedException { return new StreamOf<>( - new MappedCollection<>( - xml -> new XmlTimeTrackEntry(this.issue, xml), - new XmlsOf( - "/workItems/workItem", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString() - .concat(String.format(PATH_TEMPLATE, this.issue.id())) - ) - ) - ) + new MappedCollection<>( + xml -> new XmlTimeTrackEntry(this.issue, xml), + new XmlsOf( + "/workItems/workItem", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString() + .concat(String.format(PATH_TEMPLATE, this.issue.id())) ) + ) ) + ) ) + ) ); } diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultIssues.java b/src/main/java/org/llorllale/youtrack/api/DefaultIssues.java index 801bafb..2220bac 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultIssues.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultIssues.java @@ -76,26 +76,26 @@ public Project project() { public Stream stream() throws IOException, UnauthorizedException { final int pageSize = 10; return new StreamOf<>( - new Pagination<>( - pageSize, - n -> new HttpRequestWithSession( - this.session, - new HttpGet( - new UncheckedUriBuilder( - this.session.baseUrl().toString() - .concat("/issue/byproject/") - .concat(this.project().id()) - ).param("after", String.valueOf(n)) - .build() - ) - ), - resp -> - new MappedCollection<>( - xml -> new XmlIssue(this.project(), this.session, xml), - new XmlsOf("/issues/issue", resp) - ), - this.httpClient - ) + new Pagination<>( + pageSize, + n -> new HttpRequestWithSession( + this.session, + new HttpGet( + new UncheckedUriBuilder( + this.session.baseUrl().toString() + .concat("/issue/byproject/") + .concat(this.project().id()) + ).param("after", String.valueOf(n)) + .build() + ) + ), + resp -> + new MappedCollection<>( + xml -> new XmlIssue(this.project(), this.session, xml), + new XmlsOf("/issues/issue", resp) + ), + this.httpClient + ) ); } @@ -104,20 +104,20 @@ public Optional get(String issueId) throws IOException, UnauthorizedExcep //when the issueId does not exist, YouTrack returns a 404 response with an error XML //in the payload return Optional.of( - new XmlOf( - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString().concat("/issue/").concat(issueId) - ) - ) - ) + new XmlOf( + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString().concat("/issue/").concat(issueId) + ) ) + ) ) + ) ).filter(x -> !x.child("//error").isPresent()) - .map(x -> new XmlIssue(this.project(), this.session, x)); + .map(x -> new XmlIssue(this.project(), this.session, x)); } @Override @@ -130,24 +130,24 @@ public Issue create(String summary, String description) public Issue create(String summary, String description, Map fields) throws IOException, UnauthorizedException { return this.get( - new SubstringAfterLast( - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpPut( - new UncheckedUriBuilder( - this.session.baseUrl().toString().concat("/issue") - ).param("project", this.project().id()) - .param("summary", summary) - .paramIfPresent("description", Optional.ofNullable(description)) - .build() - ) - ) - ) - ).httpResponse().getFirstHeader("Location").getValue(), - "/" - ).get() + new SubstringAfterLast( + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpPut( + new UncheckedUriBuilder( + this.session.baseUrl().toString().concat("/issue") + ).param("project", this.project().id()) + .param("summary", summary) + .paramIfPresent("description", Optional.ofNullable(description)) + .build() + ) + ) + ) + ).httpResponse().getFirstHeader("Location").getValue(), + "/" + ).get() ).get().update().fields(fields); } } diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultProjects.java b/src/main/java/org/llorllale/youtrack/api/DefaultProjects.java index cc01912..9484064 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultProjects.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultProjects.java @@ -68,44 +68,44 @@ final class DefaultProjects implements Projects { @Override public Stream stream() throws IOException, UnauthorizedException { return new StreamOf<>( - new MappedCollection<>( - xml -> new XmlProject(this.youtrack, this.session, xml), - new XmlsOf( - "/projects/project", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString().concat("/project/all") - ) - ) - ) + new MappedCollection<>( + xml -> new XmlProject(this.youtrack, this.session, xml), + new XmlsOf( + "/projects/project", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString().concat("/project/all") ) + ) ) + ) ) + ) ); } @Override public Optional get(String id) throws IOException, UnauthorizedException { return new MappedCollection( - xml -> new XmlProject(this.youtrack, this.session, xml), - new XmlsOf( - "/project", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString() - .concat("/admin/project/") - .concat(id) - ) - ) + xml -> new XmlProject(this.youtrack, this.session, xml), + new XmlsOf( + "/project", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString() + .concat("/admin/project/") + .concat(id) ) ) + ) ) + ) ).stream().findAny(); } } diff --git a/src/main/java/org/llorllale/youtrack/api/DefaultUpdateIssue.java b/src/main/java/org/llorllale/youtrack/api/DefaultUpdateIssue.java index e19b15d..6c3948a 100644 --- a/src/main/java/org/llorllale/youtrack/api/DefaultUpdateIssue.java +++ b/src/main/java/org/llorllale/youtrack/api/DefaultUpdateIssue.java @@ -82,34 +82,34 @@ public Issue field(Field field, FieldValue value) throws IOException, Unauthoriz public Issue fields(Map fields) throws IOException, UnauthorizedException { final String separator = " "; new HttpResponseAsResponse( - HttpClients.createDefault().execute( - new HttpRequestWithSession( - this.session, - new HttpRequestWithEntity( - new UrlEncodedFormEntity( - Arrays.asList( - new BasicNameValuePair( - "command", - fields.entrySet().stream() - .map( - e -> String.join( - separator, - e.getKey().name(), - e.getValue().asString() - ) - ).collect(Collectors.joining(separator)) - ) - ), - StandardCharsets.UTF_8 - ), - new HttpPost( - this.session.baseUrl().toString() - .concat(String.format(PATH_TEMPLATE, this.issue.id())) - .concat("/execute") - ) + HttpClients.createDefault().execute( + new HttpRequestWithSession( + this.session, + new HttpRequestWithEntity( + new UrlEncodedFormEntity( + Arrays.asList( + new BasicNameValuePair( + "command", + fields.entrySet().stream() + .map( + e -> String.join( + separator, + e.getKey().name(), + e.getValue().asString() + ) + ).collect(Collectors.joining(separator)) ) + ), + StandardCharsets.UTF_8 + ), + new HttpPost( + this.session.baseUrl().toString() + .concat(String.format(PATH_TEMPLATE, this.issue.id())) + .concat("/execute") ) + ) ) + ) ).httpResponse(); return this.issue.refresh(); @@ -127,19 +127,19 @@ public Issue fields(Map fields) throws IOException, Unauthori private Issue updateSmmryDesc(String summary, String description) throws IOException, UnauthorizedException { new HttpResponseAsResponse( - HttpClients.createDefault().execute( - new HttpRequestWithSession( - this.session, - new HttpPost( - new UncheckedUriBuilder( - this.session.baseUrl().toString() - .concat(String.format(PATH_TEMPLATE, this.issue.id())) - ).param("summary", summary) - .paramIfPresent("description", Optional.ofNullable(description)) - .build() - ) - ) + HttpClients.createDefault().execute( + new HttpRequestWithSession( + this.session, + new HttpPost( + new UncheckedUriBuilder( + this.session.baseUrl().toString() + .concat(String.format(PATH_TEMPLATE, this.issue.id())) + ).param("summary", summary) + .paramIfPresent("description", Optional.ofNullable(description)) + .build() + ) ) + ) ).httpResponse(); return this.issue.refresh(); diff --git a/src/main/java/org/llorllale/youtrack/api/XmlIssue.java b/src/main/java/org/llorllale/youtrack/api/XmlIssue.java index 4c92db1..59f5afe 100644 --- a/src/main/java/org/llorllale/youtrack/api/XmlIssue.java +++ b/src/main/java/org/llorllale/youtrack/api/XmlIssue.java @@ -63,9 +63,9 @@ public String id() { @Override public Instant creationDate() { return Instant.ofEpochMilli( - Long.parseLong( - this.xml.textOf("//field[@name = 'created']/value").get() - ) + Long.parseLong( + this.xml.textOf("//field[@name = 'created']/value").get() + ) ); } @@ -102,8 +102,8 @@ public UsersOfIssue users() { @Override public Issue refresh() throws IOException, UnauthorizedException { return this.project().issues() - .get(this.id()) - .get(); + .get(this.id()) + .get(); } @Override @@ -114,13 +114,12 @@ public UpdateIssue update() { @Override public Collection fields() { return new MappedCollection<>( - x -> - new XmlAssignedField( - new BasicField(x.textOf("@name").get(), this.project()), - this, - x - ), - this.xml.children("//field[count(valueId) > 0]") + x -> new XmlAssignedField( + new BasicField(x.textOf("@name").get(), this.project()), + this, + x + ), + this.xml.children("//field[count(valueId) > 0]") ); } diff --git a/src/main/java/org/llorllale/youtrack/api/XmlProjectField.java b/src/main/java/org/llorllale/youtrack/api/XmlProjectField.java index d4d9616..7f20e7b 100644 --- a/src/main/java/org/llorllale/youtrack/api/XmlProjectField.java +++ b/src/main/java/org/llorllale/youtrack/api/XmlProjectField.java @@ -66,47 +66,46 @@ public String name() { @Override public Stream values() throws IOException, UnauthorizedException { final String bundleName = new XmlsOf( - "/projectCustomField/param", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString() - .concat("/admin/project/") - .concat(this.project().id()) - .concat("/customfield/") - .concat(new SubstringAfterLast( - this.xml.textOf("@url").get(), - "/" - ).get() - ) - ) - ) + "/projectCustomField/param", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString() + .concat("/admin/project/") + .concat(this.project().id()) + .concat("/customfield/") + .concat(new SubstringAfterLast( + this.xml.textOf("@url").get(), + "/" + ).get()) ) + ) ) + ) ).stream().findAny().get().textOf("@value").get(); return new StreamOf<>( - new MappedCollection<>( - x -> new XmlFieldValue(x, new XmlProjectField(this.xml, this.project, this.session)), - new XmlsOf( - "/enumeration/value", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - new UncheckedUriBuilder( - this.session.baseUrl(), - "/admin/customfield/bundle/".concat(bundleName) - ).build() - ) - ) - ) + new MappedCollection<>( + x -> new XmlFieldValue(x, new XmlProjectField(this.xml, this.project, this.session)), + new XmlsOf( + "/enumeration/value", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + new UncheckedUriBuilder( + this.session.baseUrl(), + "/admin/customfield/bundle/".concat(bundleName) + ).build() ) + ) ) + ) ) + ) ); } diff --git a/src/main/java/org/llorllale/youtrack/api/XmlUsersOfProject.java b/src/main/java/org/llorllale/youtrack/api/XmlUsersOfProject.java index 23a2ce6..e84b19e 100644 --- a/src/main/java/org/llorllale/youtrack/api/XmlUsersOfProject.java +++ b/src/main/java/org/llorllale/youtrack/api/XmlUsersOfProject.java @@ -74,29 +74,29 @@ public Project project() { @Override public User user(String login) throws IOException, UnauthorizedException { return new XmlUser( - new XmlsOf( - "/user", - new HttpResponseAsResponse( - this.httpClient.execute( - new HttpRequestWithSession( - this.session, - new HttpGet( - this.session.baseUrl().toString().concat("/user/").concat(login) - ) - ) - ) + new XmlsOf( + "/user", + new HttpResponseAsResponse( + this.httpClient.execute( + new HttpRequestWithSession( + this.session, + new HttpGet( + this.session.baseUrl().toString().concat("/user/").concat(login) + ) ) - ).stream().findAny().get() + ) + ) + ).stream().findAny().get() ); } @Override public Stream assignees() throws IOException, UnauthorizedException { return new StreamOf<>( - new MappedCollection<>( - () -> x -> this.user(x.textOf("@value").get()), - this.xml.children("//assigneesLogin/sub") - ) + new MappedCollection<>( + () -> x -> this.user(x.textOf("@value").get()), + this.xml.children("//assigneesLogin/sub") + ) ); } }