Skip to content

Commit

Permalink
feat(yegor256#1237): refresh code accoding with qulice suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Mar 23, 2023
1 parent 0fe334a commit 486a74e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
11 changes: 0 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<artifactId>twitter4j-core</artifactId>
<version>4.0.7</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand Down Expand Up @@ -230,11 +224,6 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<version>6.0.20.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-matchers</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-xml</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rultor/agents/github/qtn/QnMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import com.rultor.agents.github.Req;
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
import java.util.ResourceBundle;
import lombok.EqualsAndHashCode;
import lombok.ToString;
Expand Down Expand Up @@ -180,7 +179,8 @@ private static Req pack(final Comment.Smart comment,
* @return True if all checks are successful
* @throws IOException If fails
*/
private static boolean allChecksSuccessful(final Pull pull) throws IOException {
private static boolean allChecksSuccessful(final Pull pull)
throws IOException {
boolean result = true;
for (final Check check : pull.checks().all()) {
if (!check.successful()) {
Expand Down
38 changes: 26 additions & 12 deletions src/test/java/com/rultor/agents/github/qtn/QnMergeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
package com.rultor.agents.github.qtn;

import com.jcabi.github.Check;
import com.jcabi.github.Checks;
import com.jcabi.github.Comment;
import com.jcabi.github.Comments;
import com.jcabi.github.Pull;
Expand All @@ -39,17 +38,14 @@
import com.jcabi.github.mock.MkChecks;
import com.jcabi.github.mock.MkGithub;
import com.jcabi.matchers.XhtmlMatchers;
import com.rultor.agents.github.Req;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ResourceBundle;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.xembly.Directives;
import org.xembly.Xembler;

Expand Down Expand Up @@ -79,7 +75,11 @@ final class QnMergeTest {
* All pull request comments.
*/
private transient Comments comments;
private Pull pull;

/**
* Pull request.
*/
private transient Pull pull;

/**
* Initial phase for all tests.
Expand All @@ -93,15 +93,16 @@ public void setUp() throws IOException {
final String base = "base";
branches.create(head, "abcdef4");
branches.create(base, "abcdef5");
pull = repo.pulls().create("", head, base);
this.pull = repo.pulls().create("", head, base);
this.comments = repo.issues()
.get(pull.number())
.get(this.pull.number())
.comments();
}

/**
* QnMerge can build a request.
* @throws Exception In case of error.
*
* @throws Exception In case of error
*/
@Test
public void buildsRequest() throws Exception {
Expand Down Expand Up @@ -136,10 +137,13 @@ public void buildsRequest() throws Exception {
/**
* QnMerge can not build a request because some GitHub checks
* were failed.
* @throws Exception In case of error
*
* @throws IOException In case of I/O error
* @throws URISyntaxException In case of URI error
*/
@Test
public void stopsBecauseCiChecksFailed() throws Exception {
public void stopsBecauseCiChecksFailed()
throws IOException, URISyntaxException {
final MkChecks checks = (MkChecks) this.pull.checks();
checks.create(Check.Status.IN_PROGRESS, Check.Conclusion.SUCCESS);
this.mergeRequest();
Expand All @@ -155,8 +159,15 @@ public void stopsBecauseCiChecksFailed() throws Exception {
);
}

/**
* QnMerge can build a request because GitHub checks finished successfully.
*
* @throws IOException In case of I/O error
* @throws URISyntaxException In case of URI error
*/
@Test
public void continuesBecauseCiChecksSuccessful() throws Exception {
public void continuesBecauseCiChecksSuccessful()
throws IOException, URISyntaxException {
final MkChecks checks = (MkChecks) this.pull.checks();
checks.create(Check.Status.COMPLETED, Check.Conclusion.SUCCESS);
this.mergeRequest();
Expand All @@ -167,7 +178,10 @@ public void continuesBecauseCiChecksSuccessful() throws Exception {
MatcherAssert.assertThat(
new Comment.Smart(this.comments.get(2)).body(),
Matchers.containsString(
String.format(QnMergeTest.PHRASES.getString("QnMerge.start"), "#")
String.format(
QnMergeTest.PHRASES.getString("QnMerge.start"),
"#"
)
)
);
}
Expand Down

0 comments on commit 486a74e

Please sign in to comment.