Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jul 11, 2019
2 parents 897d70a + 7133b56 commit b445787
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>org.cactoos</groupId>
<artifactId>cactoos</artifactId>
<version>0.41</version>
<version>0.42</version>
</dependency>
<!-- logging -->
<dependency>
Expand Down Expand Up @@ -124,7 +124,7 @@
<dependency>
<groupId>org.llorllale</groupId>
<artifactId>cactoos-matchers</artifactId>
<version>0.15</version>
<version>0.17</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
14 changes: 8 additions & 6 deletions src/main/java/com/g4s8/ghman/data/SimpleDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.cactoos.Scalar;
import org.cactoos.scalar.IoChecked;
import org.cactoos.scalar.Solid;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;

/**
* Simple data source.
Expand Down Expand Up @@ -64,10 +66,10 @@ private static DataSource fromEnv(final Map<String, String> env) {
final org.postgresql.jdbc2.optional.SimpleDataSource source =
new org.postgresql.jdbc2.optional.SimpleDataSource();
source.setUrl(
String.format(
"jdbc:postgresql://%s:%s/%s",
new FormattedText(
new TextOf("jdbc:postgresql://%s:%s/%s"),
env.get("DB_HOST"), env.get("DB_PORT"), env.get("DB_NAME")
)
).toString()
);
source.setUser(env.get("DB_USER"));
if (env.containsKey("DB_PASSWORD")) {
Expand All @@ -92,10 +94,10 @@ private static void check(
for (final String var : req) {
if (!env.containsKey(var)) {
throw new IllegalArgumentException(
String.format(
"Environment variable '%s' is required",
new FormattedText(
new TextOf("Environment variable '%s' is required"),
var
)
).toString()
);
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/g4s8/ghman/user/GhUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.io.IOException;
import javax.json.JsonValue;
import org.cactoos.iterable.Mapped;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;

/**
* Github user.
Expand Down Expand Up @@ -67,7 +69,7 @@ public GhThread thread(final String tid) throws IOException {
return new GhThread(
this.ghb.entry()
.uri()
.path(String.format("/notifications/threads/%s", tid))
.path(new FormattedText(new TextOf("/notifications/threads/%s"), tid).toString())
.back()
.fetch().as(JsonResponse.class)
.json().readObject()
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/g4s8/ghman/user/ThreadIssue.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@
import org.cactoos.scalar.IoChecked;
import org.cactoos.scalar.SolidScalar;
import org.cactoos.scalar.Unchecked;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;

/**
* Issue for thread.
* @since 1.0
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
@SuppressWarnings("PMD.TooManyMethods")
public final class ThreadIssue implements Issue {
Expand All @@ -58,10 +61,10 @@ public ThreadIssue(final Github ghb, final Thread thread) {
final String type = subj.getString("type");
if (!type.equals("Issue")) {
throw new UnsupportedThreadException(
String.format(
"Thread subject type is `%s` - not supported yet",
new FormattedText(
new TextOf("Thread subject type is `%s` - not supported yet"),
type
)
).toString()
);
}
// @checkstyle LineLengthCheck (1 line)
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/g4s8/ghman/web/FkGitHubAuthRedirection.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.io.IOException;
import org.apache.http.client.utils.URIBuilder;
import org.cactoos.scalar.IoChecked;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;
import org.takes.Request;
import org.takes.Response;
import org.takes.Take;
Expand All @@ -30,8 +32,6 @@
/**
* Github Authorization Redirection.
* @since 1.0
* @todo #4:30min Replace the call to static method String.format
* with the use of cactoos' text.Formatted class in all files.
* @todo #4:30min Implement unit tests for FkGitHubAuthRedirection. Refer
* to takes framework Unit testing guide @ https://github.com/yegor256/takes#unit-testing
*/
Expand All @@ -48,7 +48,9 @@ public FkGitHubAuthRedirection() {
() -> new URIBuilder("https://github.com/login/oauth/authorize")
.addParameter(
"redirect_uri",
String.format("https://%s/auth", System.getenv("APP_HOST"))
new FormattedText(
new TextOf("https://%s/auth"), System.getenv("APP_HOST")
).toString()
)
.addParameter("client_id", System.getenv("GH_CLIENT"))
.addParameter("scope", "notifications")
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/g4s8/ghman/web/PsUserById.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.g4s8.ghman.web;

import java.io.IOException;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;
import org.takes.Request;
import org.takes.Response;
import org.takes.facets.auth.Identity;
Expand Down Expand Up @@ -56,7 +58,9 @@ final class PsUserById implements Pass {
public Opt<Identity> enter(final Request req) throws IOException {
return new Opt.Single<>(
new Identity.Simple(
String.format("urn:uid:%s", new RqHref.Smart(req).single(this.flag))
new FormattedText(
new TextOf("urn:uid:%s"), new RqHref.Smart(req).single(this.flag)
).toString()
)
);
}
Expand Down
9 changes: 6 additions & 3 deletions src/test/java/com/g4s8/ghman/bot/TkCloseIssueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.jcabi.github.mock.MkGithub;
import com.jcabi.matchers.XhtmlMatchers;
import java.io.IOException;
import org.cactoos.text.FormattedText;
import org.cactoos.text.TextOf;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.Throws;
Expand All @@ -32,6 +34,7 @@
/**
* Test for {@link TkCloseIssue}.
* @since 1.0
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
final class TkCloseIssueTest {

Expand All @@ -46,9 +49,9 @@ void closesIssue() throws IOException {
.issues().create("illuminate traffic", "");
Mockito.when(clbq.getMessage()).thenReturn(Mockito.mock(Message.class));
Mockito.when(clbq.getData()).thenReturn(
String.format(
new FormattedText(
"click:notification.close?repo=%s/%s&issue=%d", user, repo, 1
)
).toString()
);
Mockito.when(upd.getCallbackQuery()).thenReturn(clbq);
new Assertion<>(
Expand All @@ -71,7 +74,7 @@ void throwsExceptionWhenRequestIsInvalid() {
"Should throw IllegalArgumentException",
() -> new TkCloseIssue(new Users.Fake(new MkGithub())).act(upd),
new Throws<>(
String.format("Illegal request: %s", data),
new FormattedText(new TextOf("Illegal request: %s"), data).toString(),
IllegalArgumentException.class
)
).affirm();
Expand Down

1 comment on commit b445787

@0pdd
Copy link

@0pdd 0pdd commented on b445787 Jul 11, 2019

Choose a reason for hiding this comment

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

Puzzle 4-ff388267 disappeared from src/main/java/com/g4s8/ghman/web/FkGitHubAuthRedirection.java, that's why I closed #40. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

Please sign in to comment.