-
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
#6 74 - AllItemsIntegrationTest
- Loading branch information
Showing
16 changed files
with
253 additions
and
2 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
88 changes: 87 additions & 1 deletion
88
...test/java/dev/iakunin/codexiabot/hackernews/cron/healthcheck/AllItemsIntegrationTest.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,99 @@ | ||
package dev.iakunin.codexiabot.hackernews.cron.healthcheck; | ||
|
||
import com.github.database.rider.core.api.dataset.DataSet; | ||
import com.github.database.rider.core.api.dataset.ExpectedDataSet; | ||
import dev.iakunin.codexiabot.AbstractIntegrationTest; | ||
import dev.iakunin.codexiabot.util.WireMockServer; | ||
import dev.iakunin.codexiabot.util.wiremock.Response; | ||
import dev.iakunin.codexiabot.util.wiremock.Stub; | ||
import org.cactoos.io.ResourceOf; | ||
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.http.HttpStatus; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration(initializers = AllItemsIntegrationTest.Initializer.class) | ||
public class AllItemsIntegrationTest extends AbstractIntegrationTest { | ||
|
||
@Autowired | ||
private AllItems allItems; | ||
|
||
// @todo #66 Implement AllItemsIntegrationTest | ||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/health-check/all-items/initial/emptyDatabase.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/emptyDatabase.yml") | ||
public void emptyDatabase() { | ||
allItems.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/health-check/all-items/initial/oneActiveItem.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/oneActiveItem.yml") | ||
public void oneActiveItem() { | ||
WireMockServer.stub( | ||
new Stub( | ||
"/item/2222.json", | ||
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/oneActiveItem.json") | ||
) | ||
); | ||
|
||
allItems.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/health-check/all-items/initial/oneDeletedItem.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/oneDeletedItem.yml") | ||
public void oneDeletedItem() { | ||
WireMockServer.stub( | ||
new Stub( | ||
"/item/2222.json", | ||
new ResourceOf("wiremock/hackernews/cron/health-check/all-items/oneDeletedItem.json") | ||
) | ||
); | ||
|
||
allItems.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/health-check/all-items/initial/hackernewsException.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/health-check/all-items/expected/hackernewsException.yml") | ||
public void hackernewsException() { | ||
WireMockServer.stub( | ||
new Stub( | ||
"/item/2222.json", | ||
new Response(HttpStatus.INTERNAL_SERVER_ERROR.value()) | ||
) | ||
); | ||
|
||
allItems.run(); | ||
} | ||
|
||
@AfterEach | ||
void after() { | ||
WireMockServer.getInstance().resetAll(); | ||
} | ||
|
||
static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | ||
@Override | ||
public void initialize(ConfigurableApplicationContext applicationContext) { | ||
TestPropertyValues.of( | ||
"app.hackernews.base-url=" + WireMockServer.getInstance().baseUrl() | ||
).applyTo(applicationContext.getEnvironment()); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...test/resources/db-rider/hackernews/cron/health-check/all-items/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_source: [] | ||
|
||
hackernews_item: [] |
15 changes: 15 additions & 0 deletions
15
...esources/db-rider/hackernews/cron/health-check/all-items/expected/hackernewsException.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,15 @@ | ||
github_repo_source: | ||
- | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
hackernews_item: | ||
- | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2020-02-14 18:43:33 | ||
deleted: false |
15 changes: 15 additions & 0 deletions
15
...test/resources/db-rider/hackernews/cron/health-check/all-items/expected/oneActiveItem.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,15 @@ | ||
github_repo_source: | ||
- | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
hackernews_item: | ||
- | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2020-02-14 18:43:33 | ||
deleted: false |
16 changes: 16 additions & 0 deletions
16
...est/resources/db-rider/hackernews/cron/health-check/all-items/expected/oneDeletedItem.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,16 @@ | ||
github_repo_source: | ||
- | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
deleted_at: regex:^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{1,6}$ | ||
|
||
hackernews_item: | ||
- | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2009-01-15 05:56:02 | ||
deleted: true |
5 changes: 5 additions & 0 deletions
5
src/test/resources/db-rider/hackernews/cron/health-check/all-items/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,5 @@ | ||
github_repo: [] | ||
|
||
github_repo_source: [] | ||
|
||
hackernews_item: [] |
26 changes: 26 additions & 0 deletions
26
...resources/db-rider/hackernews/cron/health-check/all-items/initial/hackernewsException.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,26 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 202275988 | ||
full_name: casbin/casbin | ||
html_url: https://github.com/casbin/casbin | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
hackernews_item: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2020-02-14 18:43:33 | ||
deleted: false |
26 changes: 26 additions & 0 deletions
26
src/test/resources/db-rider/hackernews/cron/health-check/all-items/initial/oneActiveItem.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,26 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 202275988 | ||
full_name: casbin/casbin | ||
html_url: https://github.com/casbin/casbin | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
hackernews_item: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2020-02-14 18:43:33 | ||
deleted: false |
26 changes: 26 additions & 0 deletions
26
...test/resources/db-rider/hackernews/cron/health-check/all-items/initial/oneDeletedItem.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,26 @@ | ||
github_repo: | ||
- | ||
id: 1 | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 202275988 | ||
full_name: casbin/casbin | ||
html_url: https://github.com/casbin/casbin | ||
repo_created_at: 2019-08-14 04:42:36 | ||
|
||
github_repo_source: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
github_repo_id: 1 | ||
source: "HACKERNEWS" | ||
external_id: "2222" | ||
|
||
hackernews_item: | ||
- | ||
uuid: "groovy: UUID.randomUUID().toString()" | ||
external_id: 2222 | ||
type: story | ||
by: smartmic | ||
title: Title for casbin | ||
url: https://github.com/casbin/casbin | ||
time: 2020-02-14 18:43:33 | ||
deleted: false |
11 changes: 11 additions & 0 deletions
11
src/test/resources/wiremock/hackernews/cron/health-check/all-items/oneActiveItem.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,11 @@ | ||
{ | ||
"by": "smartmic", | ||
"id": 2222, | ||
"text": "Some awesome text.", | ||
"title": "Title for casbin", | ||
"url": "https://github.com/casbin/casbin", | ||
"time": 1231998962, | ||
"type": "story", | ||
"descendants": 0, | ||
"score": 2 | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/resources/wiremock/hackernews/cron/health-check/all-items/oneDeletedItem.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,12 @@ | ||
{ | ||
"by": "smartmic", | ||
"id": 2222, | ||
"text": "Some awesome text.", | ||
"title": "Title for casbin", | ||
"url": "https://github.com/casbin/casbin", | ||
"time": 1231998962, | ||
"type": "story", | ||
"descendants": 0, | ||
"score": 2, | ||
"deleted": true | ||
} |
497e15b
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
66-1eb62372
disappeared fromsrc/test/java/dev/iakunin/codexiabot/hackernews/cron/healthcheck/AllItemsIntegrationTest.java
, that's why I closed #74. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.497e15b
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
74-721dfe5c
discovered insrc/main/java/dev/iakunin/codexiabot/hackernews/cron/healthcheck/AllItems.java
and submitted as #167. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.497e15b
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
74-fdc38b44
discovered insrc/main/java/dev/iakunin/codexiabot/hackernews/cron/GapsFiller.java
and submitted as #168. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.