Skip to content
This repository has been archived by the owner on Oct 7, 2022. It is now read-only.

(#181) Fixed more checkstyle issues #182

Merged
merged 1 commit into from
Apr 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
<violationSeverity>info</violationSeverity>
<!--
@todo #179 <sourceDirectory> should be '${basedir}/src' in order to include
test sources in the checks, but there are MANY failures triggered there.
Will need to fix those step by step. Keep going.
-->
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
</configuration>
<reportSets>
Expand Down Expand Up @@ -427,6 +422,11 @@
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
<violationSeverity>info</violationSeverity>
<!--
@todo #181 <sourceDirectory> should be '${basedir}/src' in order to include
test sources in the checks, but there are MANY failures triggered there.
Will need to fix those step by step. Keep going.
-->
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@
* Mock implementation of {@link AssignedField} suitable for tests.
*
* <p>Note: the {@link #change()} operation is not supported.
*
* @author George Aristy (george.aristy@gmail.com)
* @since 1.0.0
*/
public class MockAssignedField implements AssignedField {
public final class MockAssignedField implements AssignedField {
private final String name;
private final Issue issue;
private final String value;

/**
* Primary ctor.
*
* @param name this field's name
* @param issue the issue this field is assigned to
* @param value this field's {@link MockFieldValue value}
Expand Down Expand Up @@ -70,7 +68,7 @@ public String name() {

@Override
public boolean equals(Object object) {
if(!(object instanceof AssignedField)) {
if (!(object instanceof AssignedField)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@

/**
* Mock implementation of {@link FieldValue} suitable for tests.
*
* @author George Aristy (george.aristy@gmail.com)
* @since 1.0.0
*/
public class MockFieldValue implements FieldValue {
public final class MockFieldValue implements FieldValue {
private final Field field;
private final String value;

/**
* Primary ctor.
*
* @param field the {@link #field() field}
* @param value the {@link #asString() value}
* @since 1.0.0
Expand Down
136 changes: 80 additions & 56 deletions src/test/java/org/llorllale/youtrack/api/mock/MockIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,22 @@
import org.llorllale.youtrack.api.AssignedField;
import org.llorllale.youtrack.api.Comments;
import org.llorllale.youtrack.api.Issue;
import org.llorllale.youtrack.api.IssueTimeTracking;
import org.llorllale.youtrack.api.Project;
import org.llorllale.youtrack.api.UpdateIssue;
import org.llorllale.youtrack.api.UsersOfIssue;
import org.llorllale.youtrack.api.session.UnauthorizedException;
import org.llorllale.youtrack.api.IssueTimeTracking;
import org.llorllale.youtrack.api.UpdateIssue;

/**
* Mock implementation of {@link Issue} suitable for unit tests.
*
*
* @author George Aristy (george.aristy@gmail.com)
* @since 0.4.0
*/
public class MockIssue implements Issue {
@SuppressWarnings(
{"checkstyle:MethodCount", "checkstyle:MultipleStringLiterals", "checkstyle:MethodName"}
)
public final class MockIssue implements Issue {
private final Project project;
private final String id;
private final Instant creationDate;
Expand All @@ -45,20 +48,21 @@ public class MockIssue implements Issue {

/**
* Primary ctor.
*
* @param project
* @param id
* @param creationDate
* @param summary
* @param description
*
* @param project the project
* @param id the issue's id
* @param creationDate issue's creation date
* @param summary issue's summary
* @param description issue's description
* @since 0.4.0
*/
@SuppressWarnings("checkstyle:ParameterNumber")
public MockIssue(
Project project,
String id,
Instant creationDate,
String summary,
String description
Project project,
String id,
Instant creationDate,
String summary,
String description
) {
this.project = project;
this.id = id;
Expand All @@ -68,57 +72,77 @@ public MockIssue(
}

/**
*
* @param project
* Ctor.
* @param project the project
* @since 0.4.0
*/
public MockIssue(Project project) {
this(
project,
"",
Instant.now(),
"",
""
project,
"",
Instant.now(),
"",
""
);
}

public MockIssue withId(String id) {
/**
* Sets this issue's id.
* @param issueId id for this issue
* @return this issue
*/
public MockIssue withId(String issueId) {
return new MockIssue(
this.project,
id,
this.creationDate,
this.summary,
this.description
this.project,
issueId,
this.creationDate,
this.summary,
this.description
);
}

public MockIssue withCreationDate(Instant creationDate) {
/**
* Sets this issue's creation date.
* @param date creation date
* @return this issue
*/
public MockIssue withCreationDate(Instant date) {
return new MockIssue(
this.project,
this.id,
creationDate,
this.summary,
this.description
this.project,
this.id,
date,
this.summary,
this.description
);
}

public MockIssue withSummary(String summary) {
/**
* Sets this issue's summary.
* @param text summary text
* @return this issue
*/
public MockIssue withSummary(String text) {
return new MockIssue(
this.project,
this.id,
this.creationDate,
summary,
this.description
this.project,
this.id,
this.creationDate,
text,
this.description
);
}

public MockIssue withDescription(String description) {
/**
* Sets this issue's description.
* @param text descriptive text
* @return this issue
*/
public MockIssue withDescription(String text) {
return new MockIssue(
this.project,
this.id,
this.creationDate,
this.summary,
description
this.project,
this.id,
this.creationDate,
this.summary,
text
);
}

Expand All @@ -142,42 +166,42 @@ public boolean equals(Object object) {

@Override
public Project project() {
return project;
return this.project;
}

@Override
public String id() {
return id;
return this.id;
}

@Override
public Instant creationDate() {
return creationDate;
return this.creationDate;
}

@Override
public String summary() {
return summary;
return this.summary;
}

@Override
public Optional<String> description() {
return Optional.of(description);
return Optional.ofNullable(this.description);
}

@Override
public Comments comments() {
throw new UnsupportedOperationException("Not supported yet."); //TODO implement
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public IssueTimeTracking timetracking() {
throw new UnsupportedOperationException("Not supported yet."); //TODO implement
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public UsersOfIssue users() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
Expand All @@ -187,11 +211,11 @@ public Issue refresh() throws IOException, UnauthorizedException {

@Override
public List<AssignedField> fields() {
throw new UnsupportedOperationException("Not supported yet."); //TODO implement
throw new UnsupportedOperationException("Not supported yet.");
}

@Override
public UpdateIssue update() {
throw new UnsupportedOperationException("Not supported yet."); //TODO implement
throw new UnsupportedOperationException("Not supported yet.");
}
}
18 changes: 9 additions & 9 deletions src/test/java/org/llorllale/youtrack/api/mock/MockUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,36 +23,36 @@
* @author George Aristy (george.aristy@gmail.com)
* @since 0.5.0
*/
public class MockUser implements User {
public final class MockUser implements User {
private final String name;
private final String email;
private final String loginName;

/**
* Ctor.
* @param name
* @param email
* @param loginName
* @param name username
* @param email user's email
* @param login user's login
* @since 0.5.0
*/
public MockUser(String name, String email, String loginName) {
public MockUser(String name, String email, String login) {
this.name = name;
this.email = email;
this.loginName = loginName;
this.loginName = login;
}

@Override
public String name() {
return name;
return this.name;
}

@Override
public String email() {
return email;
return this.email;
}

@Override
public String loginName() {
return loginName;
return this.loginName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
* @author George Aristy (george.aristy@gmail.com)
* @since 0.4.0
*/
public class MockSession implements Session {
public final class MockSession implements Session {
@Override
public URL baseUrl() {
try{
try {
return new URL("http://some.url");
}catch(MalformedURLException e){
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2017 George Aristy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Mock implementations suitable for tests.
* @since 1.0.0
*/
package org.llorllale.youtrack.api.mock.http;