Skip to content

Commit

Permalink
#64 - Increasing code-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
iakunin committed May 13, 2020
1 parent 245f400 commit 1e6cd6b
Show file tree
Hide file tree
Showing 15 changed files with 142 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public class IncrementedParserIntegrationTest extends AbstractIntegrationTest {

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabaseWithoutHackernews.yml",
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabaseWithoutHackernews.yml")
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabase.yml")
public void emptyDatabaseWithoutHackernews() {
incrementedParser.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabaseItemWithoutUrl.yml",
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabaseItemWithoutUrl.yml")
Expand All @@ -53,7 +53,62 @@ public void emptyDatabaseItemWithoutUrl() {

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabaseAndTwoItemsAtHackernews.yml",
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabaseItemWithGithubUrl.yml")
public void emptyDatabaseItemWithGithubUrl() {
WireMockServer.stub(
new Stub(
new Request("/item/1.json"),
new Response(
new ResourceOf("wiremock/hackernews/cron/incremented-parser/itemWithGithubUrl.json")
)
)
);

incrementedParser.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabaseItemWithGistUrl.yml")
public void emptyDatabaseItemWithGistUrl() {
WireMockServer.stub(
new Stub(
new Request("/item/1.json"),
new Response(
new ResourceOf("wiremock/hackernews/cron/incremented-parser/itemWithGistUrl.json")
)
)
);

incrementedParser.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabase.yml")
public void emptyDatabaseEmptyResponse() {
WireMockServer.stub(
new Stub(
new Request("/item/1.json"),
new Response("")
)
);

incrementedParser.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/emptyDatabase.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/emptyDatabaseAndTwoItemsAtHackernews.yml")
Expand Down Expand Up @@ -88,6 +143,25 @@ public void notEmptyDatabaseWithoutHackernews() {
incrementedParser.run();
}

@Test
@DataSet(
value = "db-rider/hackernews/cron/incremented-parser/initial/notEmptyDatabaseExistsInRepo.yml",
cleanBefore = true, cleanAfter = true
)
@ExpectedDataSet("db-rider/hackernews/cron/incremented-parser/expected/notEmptyDatabaseExistsInRepo.yml")
public void notEmptyDatabaseExistsInRepo() {
WireMockServer.stub(
new Stub(
new Request("/item/2.json"),
new Response(
new ResourceOf("wiremock/hackernews/cron/incremented-parser/itemWithoutUrl.json")
)
)
);

incrementedParser.run();
}

@AfterEach
void after() {
WireMockServer.getInstance().resetAll();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ hackernews_item:
type: story
by: test2author
title: Title for test2
url: https://github.com/test2/test2
url: https://example.com
time: 2009-01-15 05:42:03
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hackernews_item:
-
external_id: 1
type: story
by: test1author
title: Title for item with gist
url: https://gist.github.com/iakunin/test123123
time: 2009-01-15 05:56:17
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hackernews_item:
-
external_id: 1
type: story
by: test1author
title: Title for test1
url: https://github.com/test-user/test-repo
time: 2009-01-15 05:56:17
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hackernews_item:
-
external_id: 1
type: story
by: test1author
title: Title for test1
url: https://test1.com
time: 2009-01-15 05:56:17
deleted: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ hackernews_item:
type: story
by: test1author
title: Title for test1
url: https://github.com/test1/test1
url: https://test1.com
time: 2009-01-15 05:56:17
deleted: false
-
external_id: 2
type: story
by: test2author
title: Title for test2
url: https://github.com/test2/test2
url: https://test2.com
time: 2009-01-15 05:42:03
deleted: false

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
hackernews_item:
-
external_id: 1
type: story
by: test1author
title: Title for test1
url: https://test1.com
time: 2009-01-15 05:56:17
deleted: false
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ hackernews_item:
type: story
by: test1author
title: Title for test1
url: https://github.com/test1/test1
url: https://test1.com
time: 2009-01-15 05:56:17
deleted: false
-
external_id: 2
type: story
by: test2author
title: Title for test2
url: https://github.com/test2/test2
url: https://test2.com
time: 2009-01-15 05:42:03
deleted: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"by": "test1author",
"id": 1,
"text": "Some awesome text for test 1.",
"title": "Title for item with gist",
"url": "https://gist.github.com/iakunin/test123123",
"time": 1231998977,
"type": "story",
"descendants": 0,
"score": 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"by": "test1author",
"id": 1,
"text": "Some awesome text for test 1.",
"title": "Title for test1",
"url": "https://github.com/test-user/test-repo",
"time": 1231998977,
"type": "story",
"descendants": 0,
"score": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"id": 2,
"text": "Some awesome text for test 2.",
"title": "Title for test2",
"url": "https://github.com/test2/test2",
"url": "https://example.com",
"time": 1231998123,
"type": "story",
"descendants": 2,
Expand Down

0 comments on commit 1e6cd6b

Please sign in to comment.