-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
17 changed files
with
248 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 107 additions & 1 deletion
108
src/test/java/dev/iakunin/codexiabot/github/cron/stat/LinesOfCodeIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,119 @@ | ||
package dev.iakunin.codexiabot.github.cron.stat; | ||
|
||
import com.github.database.rider.core.api.dataset.DataSet; | ||
import com.github.database.rider.core.api.dataset.ExpectedDataSet; | ||
import com.github.tomakehurst.wiremock.client.WireMock; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.ok; | ||
import dev.iakunin.codexiabot.AbstractIntegrationTest; | ||
import dev.iakunin.codexiabot.util.WireMockServer; | ||
import org.cactoos.io.ResourceOf; | ||
import org.cactoos.text.TextOf; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.util.TestPropertyValues; | ||
import org.springframework.context.ApplicationContextInitializer; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration(initializers = LinesOfCodeIntegrationTest.Initializer.class) | ||
public class LinesOfCodeIntegrationTest extends AbstractIntegrationTest { | ||
|
||
@Autowired | ||
private LinesOfCode linesOfCode; | ||
|
||
// @todo #10 Implement LinesOfCodeIntegrationTest | ||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/lines-of-code/initial/emptyDatabase.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/emptyDatabase.yml") | ||
public void emptyDatabase() { | ||
linesOfCode.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/lines-of-code/initial/processedRepo.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/processedRepo.yml") | ||
public void processedRepo() { | ||
linesOfCode.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/lines-of-code/initial/happyPath.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/happyPath.yml") | ||
public void happyPath() { | ||
WireMockServer.getInstance().stubFor( | ||
get(WireMock.urlPathEqualTo("/loc")) | ||
.willReturn(ok() | ||
.withHeader("Content-Type", "application/json") | ||
.withBody( | ||
new TextOf( | ||
new ResourceOf( | ||
"wiremock/github/cron/stat/lines-of-code/happyPath.json" | ||
) | ||
).toString() | ||
) | ||
) | ||
); | ||
|
||
linesOfCode.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/lines-of-code/initial/tooManyRequests.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/tooManyRequests.yml") | ||
public void tooManyRequests() { | ||
WireMockServer.getInstance().stubFor( | ||
get(WireMock.urlPathEqualTo("/loc")) | ||
.willReturn(aResponse() | ||
.withStatus(429) | ||
) | ||
); | ||
|
||
linesOfCode.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/github/cron/stat/lines-of-code/initial/codetabsException.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/github/cron/stat/lines-of-code/expected/codetabsException.yml") | ||
public void codetabsException() { | ||
WireMockServer.getInstance().stubFor( | ||
get(WireMock.urlPathEqualTo("/loc")) | ||
.willReturn(aResponse() | ||
.withStatus(500) | ||
) | ||
); | ||
|
||
linesOfCode.run(); | ||
} | ||
|
||
@AfterEach | ||
void after() { | ||
WireMockServer.getInstance().resetAll(); | ||
} | ||
|
||
static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | ||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
TestPropertyValues.of( | ||
"app.codetabs.base-url=" + WireMockServer.getInstance().baseUrl(), | ||
"app.cron.github.stat.lines-of-code.delay=0" | ||
).applyTo(applicationContext.getEnvironment()); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/resources/db-rider/github/cron/stat/lines-of-code/expected/codetabsException.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: | ||
- | ||
github_repo_id: 1 | ||
type: "LINES_OF_CODE" | ||
stat: '{"itemList":null,"type":"LINES_OF_CODE"}' |
3 changes: 3 additions & 0 deletions
3
src/test/resources/db-rider/github/cron/stat/lines-of-code/expected/emptyDatabase.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github_repo: [] | ||
|
||
github_repo_stat: [] |
11 changes: 11 additions & 0 deletions
11
src/test/resources/db-rider/github/cron/stat/lines-of-code/expected/happyPath.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: | ||
- | ||
github_repo_id: 1 | ||
type: "LINES_OF_CODE" | ||
stat: '{"itemList":[{"language":"TypeScript","files":84,"lines":9415,"blanks":1200,"comments":682,"linesOfCode":3533},{"language":"Total","files":173,"lines":31482,"blanks":1446,"comments":706,"linesOfCode":29330}],"type":"LINES_OF_CODE"}' |
12 changes: 12 additions & 0 deletions
12
src/test/resources/db-rider/github/cron/stat/lines-of-code/expected/processedRepo.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: | ||
- | ||
id: 1 | ||
github_repo_id: 1 | ||
type: "LINES_OF_CODE" | ||
stat: '{"itemList":null,"type":"LINES_OF_CODE"}' |
7 changes: 7 additions & 0 deletions
7
src/test/resources/db-rider/github/cron/stat/lines-of-code/expected/tooManyRequests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: [] |
8 changes: 8 additions & 0 deletions
8
src/test/resources/db-rider/github/cron/stat/lines-of-code/initial/codetabsException.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: [] |
3 changes: 3 additions & 0 deletions
3
src/test/resources/db-rider/github/cron/stat/lines-of-code/initial/emptyDatabase.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
github_repo: [] | ||
|
||
github_repo_stat: [] |
8 changes: 8 additions & 0 deletions
8
src/test/resources/db-rider/github/cron/stat/lines-of-code/initial/happyPath.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: [] |
14 changes: 14 additions & 0 deletions
14
src/test/resources/db-rider/github/cron/stat/lines-of-code/initial/processedRepo.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
type: "LINES_OF_CODE" | ||
stat: '{"itemList":null,"type":"LINES_OF_CODE"}' |
8 changes: 8 additions & 0 deletions
8
src/test/resources/db-rider/github/cron/stat/lines-of-code/initial/tooManyRequests.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: "150713223" | ||
full_name: "test-project1/test-repo1" | ||
|
||
github_repo_stat: [] |
18 changes: 18 additions & 0 deletions
18
src/test/resources/wiremock/github/cron/stat/lines-of-code/happyPath.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"language": "TypeScript", | ||
"files": 84, | ||
"lines": 9415, | ||
"blanks": 1200, | ||
"comments": 682, | ||
"linesOfCode": 3533 | ||
}, | ||
{ | ||
"language": "Total", | ||
"files": 173, | ||
"lines": 31482, | ||
"blanks": 1446, | ||
"comments": 706, | ||
"linesOfCode": 29330 | ||
} | ||
] |
9aa5350
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Puzzle
10-6d9090eb
disappeared fromsrc/test/java/dev/iakunin/codexiabot/github/cron/stat/LinesOfCodeIntegrationTest.java
, that's why I closed #58. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.