-
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.
Showing
9 changed files
with
214 additions
and
1 deletion.
There are no files selected for viewing
83 changes: 82 additions & 1 deletion
83
src/test/java/dev/iakunin/codexiabot/hackernews/cron/GapsFillerIntegrationTest.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,94 @@ | ||
package dev.iakunin.codexiabot.hackernews.cron; | ||
|
||
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.Request; | ||
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.test.context.ContextConfiguration; | ||
|
||
@ContextConfiguration(initializers = GapsFillerIntegrationTest.Initializer.class) | ||
public class GapsFillerIntegrationTest extends AbstractIntegrationTest { | ||
|
||
@Autowired | ||
private GapsFiller gapsFiller; | ||
|
||
// @todo #10 Implement GapsFillerIntegrationTest | ||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/gaps-filler/initial/emptyDatabase.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/gaps-filler/expected/emptyDatabase.yml") | ||
public void emptyDatabase() { | ||
gapsFiller.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/gaps-filler/initial/oneMissing.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/gaps-filler/expected/oneMissing.yml") | ||
public void oneMissing() { | ||
WireMockServer.stub( | ||
new Stub( | ||
new Request("/item/2.json"), | ||
new Response( | ||
new ResourceOf("wiremock/hackernews/cron/gaps-filler/2.json") | ||
) | ||
) | ||
); | ||
|
||
gapsFiller.run(); | ||
} | ||
|
||
@Test | ||
@DataSet( | ||
value = "db-rider/hackernews/cron/gaps-filler/initial/twoMissing.yml", | ||
cleanBefore = true, cleanAfter = true | ||
) | ||
@ExpectedDataSet("db-rider/hackernews/cron/gaps-filler/expected/twoMissing.yml") | ||
public void twoMissing() { | ||
WireMockServer.stub( | ||
new Stub( | ||
new Request("/item/2.json"), | ||
new Response( | ||
new ResourceOf("wiremock/hackernews/cron/gaps-filler/2.json") | ||
) | ||
) | ||
); | ||
WireMockServer.stub( | ||
new Stub( | ||
new Request("/item/4.json"), | ||
new Response( | ||
new ResourceOf("wiremock/hackernews/cron/gaps-filler/4.json") | ||
) | ||
) | ||
); | ||
|
||
gapsFiller.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()); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/test/resources/db-rider/hackernews/cron/gaps-filler/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 @@ | ||
hackernews_item: [] |
25 changes: 25 additions & 0 deletions
25
src/test/resources/db-rider/hackernews/cron/gaps-filler/expected/oneMissing.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,25 @@ | ||
hackernews_item: | ||
- | ||
external_id: 1 | ||
type: story | ||
by: test1author | ||
title: Title for test1 | ||
url: test 1 url | ||
time: 2009-01-15 05:56:17 | ||
deleted: false | ||
- | ||
external_id: 3 | ||
type: story | ||
by: test3author | ||
title: Title for test3 | ||
url: test 3 url | ||
time: 2009-01-15 05:58:12 | ||
deleted: false | ||
- | ||
external_id: 2 | ||
type: story | ||
by: test2author | ||
title: Title for test2 | ||
url: test 2 url | ||
time: 2009-01-15 06:12:49 | ||
deleted: false |
41 changes: 41 additions & 0 deletions
41
src/test/resources/db-rider/hackernews/cron/gaps-filler/expected/twoMissing.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,41 @@ | ||
hackernews_item: | ||
- | ||
external_id: 1 | ||
type: story | ||
by: test1author | ||
title: Title for test1 | ||
url: test 1 url | ||
time: 2009-01-15 05:56:17 | ||
deleted: false | ||
- | ||
external_id: 3 | ||
type: story | ||
by: test3author | ||
title: Title for test3 | ||
url: test 3 url | ||
time: 2009-01-15 05:58:12 | ||
deleted: false | ||
- | ||
external_id: 5 | ||
type: story | ||
by: test5author | ||
title: Title for test5 | ||
url: test 5 url | ||
time: 2009-01-15 06:32:52 | ||
deleted: false | ||
- | ||
external_id: 2 | ||
type: story | ||
by: test2author | ||
title: Title for test2 | ||
url: test 2 url | ||
time: 2009-01-15 06:12:49 | ||
deleted: false | ||
- | ||
external_id: 4 | ||
type: story | ||
by: test4author | ||
title: Title for test4 | ||
url: test 4 url | ||
time: 2009-01-15 06:12:53 | ||
deleted: false |
1 change: 1 addition & 0 deletions
1
src/test/resources/db-rider/hackernews/cron/gaps-filler/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 @@ | ||
hackernews_item: [] |
17 changes: 17 additions & 0 deletions
17
src/test/resources/db-rider/hackernews/cron/gaps-filler/initial/oneMissing.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,17 @@ | ||
hackernews_item: | ||
- | ||
external_id: 1 | ||
type: story | ||
by: test1author | ||
title: Title for test1 | ||
url: test 1 url | ||
time: 2009-01-15 05:56:17 | ||
deleted: false | ||
- | ||
external_id: 3 | ||
type: story | ||
by: test3author | ||
title: Title for test3 | ||
url: test 3 url | ||
time: 2009-01-15 05:58:12 | ||
deleted: false |
25 changes: 25 additions & 0 deletions
25
src/test/resources/db-rider/hackernews/cron/gaps-filler/initial/twoMissing.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,25 @@ | ||
hackernews_item: | ||
- | ||
external_id: 1 | ||
type: story | ||
by: test1author | ||
title: Title for test1 | ||
url: test 1 url | ||
time: 2009-01-15 05:56:17 | ||
deleted: false | ||
- | ||
external_id: 3 | ||
type: story | ||
by: test3author | ||
title: Title for test3 | ||
url: test 3 url | ||
time: 2009-01-15 05:58:12 | ||
deleted: false | ||
- | ||
external_id: 5 | ||
type: story | ||
by: test5author | ||
title: Title for test5 | ||
url: test 5 url | ||
time: 2009-01-15 06:32:52 | ||
deleted: false |
11 changes: 11 additions & 0 deletions
11
src/test/resources/wiremock/hackernews/cron/gaps-filler/2.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": "test2author", | ||
"id": 2, | ||
"text": "Some awesome text for test 2.", | ||
"title": "Title for test2", | ||
"url": "test 2 url", | ||
"time": 1231999969, | ||
"type": "story", | ||
"descendants": 0, | ||
"score": 2 | ||
} |
11 changes: 11 additions & 0 deletions
11
src/test/resources/wiremock/hackernews/cron/gaps-filler/4.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": "test4author", | ||
"id": 4, | ||
"text": "Some awesome text for test 4.", | ||
"title": "Title for test4", | ||
"url": "test 4 url", | ||
"time": 1231999973, | ||
"type": "story", | ||
"descendants": 30, | ||
"score": 55 | ||
} |
913957c
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-a0a04470
disappeared fromsrc/test/java/dev/iakunin/codexiabot/hackernews/cron/GapsFillerIntegrationTest.java
, that's why I closed #62. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.