Skip to content

Commit 42f248f

Browse files
feat(#1660): Add test of RepositoryStatistics by using MkGithub
1 parent de7350d commit 42f248f

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/main/java/com/jcabi/github/RepositoryStatistics.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.Map;
66
import java.util.stream.Collectors;
77
import javax.json.JsonObject;
8-
import javax.json.JsonValue;
98
import org.cactoos.map.MapEntry;
109
import org.cactoos.map.MapOf;
1110

@@ -40,13 +39,7 @@ private enum KEY {
4039
}
4140

4241
private MapEntry<String, Object> toEntry(final JsonObject object) {
43-
final String k = this.getKey();
44-
final JsonValue value = object.get(k);
45-
return new MapEntry<>(k, value.toString());
46-
}
47-
48-
public String getKey() {
49-
return key;
42+
return new MapEntry<>(this.key, object.get(this.key).toString());
5043
}
5144
}
5245
}

src/test/java/com/jcabi/github/RepositoryStatisticsTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.jcabi.github;
22

3+
import com.jcabi.github.mock.MkGithub;
34
import java.io.IOException;
4-
import java.util.Map;
55
import org.hamcrest.MatcherAssert;
66
import org.hamcrest.Matchers;
77
import org.junit.Test;
@@ -16,7 +16,13 @@ public class RepositoryStatisticsTest {
1616
public void gathersBasicStatisticsFromRepo() throws IOException {
1717
MatcherAssert.assertThat(
1818
"We expect to have basic statistics from repo",
19-
new RepositoryStatistics(null).toMap(),
19+
new RepositoryStatistics(
20+
new MkGithub()
21+
.repos()
22+
.create(
23+
new Repos.RepoCreate("volodya-lombrozo", false)
24+
)
25+
).toMap(),
2026
Matchers.allOf(
2127
Matchers.hasKey("language"),
2228
Matchers.hasKey("forks_count"),

0 commit comments

Comments
 (0)