{"action":"created","comment":{"url":"https://api.github.com/repos/smolamarcin/wypok/pulls/comments/184314581","pull_request_review_id":115480235,"id":184314581,"diff_hunk":"@@ -0,0 +1,119 @@\n+package com.smola.transport.service.reports.logic;\n+\n+import com.smola.transport.model.common.Distance;\n+import com.smola.transport.model.common.Transit;\n+import com.smola.transport.model.reports.DailyReport;\n+import com.smola.transport.model.reports.MonthlyReport;\n+import com.smola.transport.model.reports.Report;\n+import com.smola.transport.repository.TransitRepository;\n+import org.junit.Before;\n+import org.junit.Test;\n+\n+import java.math.BigDecimal;\n+import java.time.LocalDate;\n+import java.util.ArrayList;\n+import java.util.List;\n+import java.util.Set;\n+\n+import static org.junit.Assert.assertEquals;\n+import static org.junit.Assert.assertTrue;\n+import static org.mockito.Mockito.mock;\n+import static org.mockito.Mockito.when;\n+\n+public class MonthlyReportGeneratorTest {\n+    private static final BigDecimal SAMPLE_PRICE_PER_DAY = BigDecimal.valueOf(10);\n+    private static final Distance SAMPLE_DISTANCE_PER_DAY = new Distance(100);\n+    private TransitRepository transitRepository;\n+    private MonthlyReportGenerator monthlyReportGenerator;\n+\n+    @Before\n+    public void setUp() {\n+        transitRepository = mock(TransitRepository.class);\n+        monthlyReportGenerator = new MonthlyReportGenerator(transitRepository);\n+    }\n+\n+    @Test\n+    public void shouldReturn_reportsFromFirstOfMonth_toDayEarlier() {\n+        //given\n+        LocalDate today = LocalDate.of(2017, 12, 5);\n+        LocalDate firstDayOfMonth = today.withDayOfMonth(1);\n+        when(transitRepository.findByDateBetween(firstDayOfMonth, today)).thenReturn(dummyDataWithDifferentDates());\n+\n+        //when\n+        MonthlyReport reports = monthlyReportGenerator.calculate(today);\n+\n+        //then\n+        List<DailyReport> dailyReports = reports.getDailyReports();\n+        assertEquals(4, dailyReports.size());\n+        assertTrue(dailyReports.contains(new DailyReport(LocalDate.of(2017, 12, 1))));\n+        assertTrue(dailyReports.contains(new DailyReport(LocalDate.of(2017, 12, 2))));\n+        assertTrue(dailyReports.contains(new DailyReport(LocalDate.of(2017, 12, 3))));\n+        assertTrue(dailyReports.contains(new DailyReport(LocalDate.of(2017, 12, 4))));\n+    }\n+\n+    @Test\n+    public void shouldReturn_summaryPriceAndDistance_forEveryDayInMonth() {\n+        //given\n+        LocalDate date = LocalDate.of(2017, 12, 5);\n+        LocalDate firstDayOfMonth = date.withDayOfMonth(1);\n+        when(transitRepository.findByDateBetween(firstDayOfMonth, date)).thenReturn(dummyDataWithDifferentDates());\n+\n+        //when\n+        MonthlyReport reports = monthlyReportGenerator.calculate(date);\n+\n+        //then\n+        List<DailyReport> dailyReports = reports.getDailyReports();\n+        for (DailyReport dailyReport : dailyReports) {\n+            assertEquals(SAMPLE_DISTANCE_PER_DAY, dailyReport.getDistance());\n+            assertEquals(SAMPLE_PRICE_PER_DAY, dailyReport.getPrice());\n+        }\n+    }\n+\n+    @Test\n+    public void shouldReturn_summaryPriceAndDistance_forEveryDayInMont_whenAllTransitsHasSameDate() {\n+        //given\n+        LocalDate date = LocalDate.of(2017, 12, 5);\n+        LocalDate firstDayOfMonth = date.withDayOfMonth(1);\n+        when(transitRepository.findByDateBetween(firstDayOfMonth, date)).thenReturn(dummyDataWithSameDates());\n+\n+        //when\n+        MonthlyReport reports = monthlyReportGenerator.calculate(date);\n+\n+        //then\n+        List<DailyReport> dailyReports = reports.getDailyReports();\n+        assertEquals(1, dailyReports.size());\n+        for (DailyReport dailyReport : dailyReports) {\n+            assertEquals(SAMPLE_PRICE_PER_DAY.multiply(BigDecimal.valueOf(4)), dailyReport.getPrice());\n+        }\n+    }\n+\n+    private List<Transit> dummyDataWithDifferentDates() {\n+        List<Transit> transits = new ArrayList<>();\n+        transits.add(new Transit());\n+        transits.add(new Transit());\n+        transits.add(new Transit());\n+        transits.add(new Transit());\n+        for (Transit transit : transits) {\n+            transit.setDistance(SAMPLE_DISTANCE_PER_DAY);\n+            transit.setPrice(SAMPLE_PRICE_PER_DAY);\n+        }\n+        for (int i = 0; i < transits.size(); i++) {\n+            transits.get(i).setDate(LocalDate.of(2017, 12, i + 1));\n+        }","path":"src/test/java/com/smola/transport/service/reports/logic/MonthlyReportGeneratorTest.java","position":102,"original_position":102,"commit_id":"c074a48caabac5faa38b18255258b2598c5b936e","original_commit_id":"c074a48caabac5faa38b18255258b2598c5b936e","user":{"login":"Mats30","id":15916417,"avatar_url":"https://avatars1.githubusercontent.com/u/15916417?v=4","gravatar_id":"","url":"https://api.github.com/users/Mats30","html_url":"https://github.com/Mats30","followers_url":"https://api.github.com/users/Mats30/followers","following_url":"https://api.github.com/users/Mats30/following{/other_user}","gists_url":"https://api.github.com/users/Mats30/gists{/gist_id}","starred_url":"https://api.github.com/users/Mats30/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mats30/subscriptions","organizations_url":"https://api.github.com/users/Mats30/orgs","repos_url":"https://api.github.com/users/Mats30/repos","events_url":"https://api.github.com/users/Mats30/events{/privacy}","received_events_url":"https://api.github.com/users/Mats30/received_events","type":"User","site_admin":false},"body":"Why don't you merge above loops in one?","created_at":"2018-04-26T08:50:12Z","updated_at":"2018-04-26T08:52:39Z","html_url":"https://github.com/smolamarcin/wypok/pull/1#discussion_r184314581","pull_request_url":"https://api.github.com/repos/smolamarcin/wypok/pulls/1","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/comments/184314581"},"html":{"href":"https://github.com/smolamarcin/wypok/pull/1#discussion_r184314581"},"pull_request":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/smolamarcin/wypok/pulls/1","id":184257971,"html_url":"https://github.com/smolamarcin/wypok/pull/1","diff_url":"https://github.com/smolamarcin/wypok/pull/1.diff","patch_url":"https://github.com/smolamarcin/wypok/pull/1.patch","issue_url":"https://api.github.com/repos/smolamarcin/wypok/issues/1","number":1,"state":"open","locked":false,"title":"Ft/daily reports","user":{"login":"smolamarcin","id":27737154,"avatar_url":"https://avatars2.githubusercontent.com/u/27737154?v=4","gravatar_id":"","url":"https://api.github.com/users/smolamarcin","html_url":"https://github.com/smolamarcin","followers_url":"https://api.github.com/users/smolamarcin/followers","following_url":"https://api.github.com/users/smolamarcin/following{/other_user}","gists_url":"https://api.github.com/users/smolamarcin/gists{/gist_id}","starred_url":"https://api.github.com/users/smolamarcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolamarcin/subscriptions","organizations_url":"https://api.github.com/users/smolamarcin/orgs","repos_url":"https://api.github.com/users/smolamarcin/repos","events_url":"https://api.github.com/users/smolamarcin/events{/privacy}","received_events_url":"https://api.github.com/users/smolamarcin/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-04-26T08:10:25Z","updated_at":"2018-04-26T08:52:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bc6f2c894f0965a347281e65405706b5ab7d278","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/smolamarcin/wypok/pulls/1/commits","review_comments_url":"https://api.github.com/repos/smolamarcin/wypok/pulls/1/comments","review_comment_url":"https://api.github.com/repos/smolamarcin/wypok/pulls/comments{/number}","comments_url":"https://api.github.com/repos/smolamarcin/wypok/issues/1/comments","statuses_url":"https://api.github.com/repos/smolamarcin/wypok/statuses/c074a48caabac5faa38b18255258b2598c5b936e","head":{"label":"smolamarcin:ft/daily-reports","ref":"ft/daily-reports","sha":"c074a48caabac5faa38b18255258b2598c5b936e","user":{"login":"smolamarcin","id":27737154,"avatar_url":"https://avatars2.githubusercontent.com/u/27737154?v=4","gravatar_id":"","url":"https://api.github.com/users/smolamarcin","html_url":"https://github.com/smolamarcin","followers_url":"https://api.github.com/users/smolamarcin/followers","following_url":"https://api.github.com/users/smolamarcin/following{/other_user}","gists_url":"https://api.github.com/users/smolamarcin/gists{/gist_id}","starred_url":"https://api.github.com/users/smolamarcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolamarcin/subscriptions","organizations_url":"https://api.github.com/users/smolamarcin/orgs","repos_url":"https://api.github.com/users/smolamarcin/repos","events_url":"https://api.github.com/users/smolamarcin/events{/privacy}","received_events_url":"https://api.github.com/users/smolamarcin/received_events","type":"User","site_admin":false},"repo":{"id":129762012,"name":"wypok","full_name":"smolamarcin/wypok","owner":{"login":"smolamarcin","id":27737154,"avatar_url":"https://avatars2.githubusercontent.com/u/27737154?v=4","gravatar_id":"","url":"https://api.github.com/users/smolamarcin","html_url":"https://github.com/smolamarcin","followers_url":"https://api.github.com/users/smolamarcin/followers","following_url":"https://api.github.com/users/smolamarcin/following{/other_user}","gists_url":"https://api.github.com/users/smolamarcin/gists{/gist_id}","starred_url":"https://api.github.com/users/smolamarcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolamarcin/subscriptions","organizations_url":"https://api.github.com/users/smolamarcin/orgs","repos_url":"https://api.github.com/users/smolamarcin/repos","events_url":"https://api.github.com/users/smolamarcin/events{/privacy}","received_events_url":"https://api.github.com/users/smolamarcin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smolamarcin/wypok","description":null,"fork":false,"url":"https://api.github.com/repos/smolamarcin/wypok","forks_url":"https://api.github.com/repos/smolamarcin/wypok/forks","keys_url":"https://api.github.com/repos/smolamarcin/wypok/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smolamarcin/wypok/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smolamarcin/wypok/teams","hooks_url":"https://api.github.com/repos/smolamarcin/wypok/hooks","issue_events_url":"https://api.github.com/repos/smolamarcin/wypok/issues/events{/number}","events_url":"https://api.github.com/repos/smolamarcin/wypok/events","assignees_url":"https://api.github.com/repos/smolamarcin/wypok/assignees{/user}","branches_url":"https://api.github.com/repos/smolamarcin/wypok/branches{/branch}","tags_url":"https://api.github.com/repos/smolamarcin/wypok/tags","blobs_url":"https://api.github.com/repos/smolamarcin/wypok/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smolamarcin/wypok/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smolamarcin/wypok/git/refs{/sha}","trees_url":"https://api.github.com/repos/smolamarcin/wypok/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smolamarcin/wypok/statuses/{sha}","languages_url":"https://api.github.com/repos/smolamarcin/wypok/languages","stargazers_url":"https://api.github.com/repos/smolamarcin/wypok/stargazers","contributors_url":"https://api.github.com/repos/smolamarcin/wypok/contributors","subscribers_url":"https://api.github.com/repos/smolamarcin/wypok/subscribers","subscription_url":"https://api.github.com/repos/smolamarcin/wypok/subscription","commits_url":"https://api.github.com/repos/smolamarcin/wypok/commits{/sha}","git_commits_url":"https://api.github.com/repos/smolamarcin/wypok/git/commits{/sha}","comments_url":"https://api.github.com/repos/smolamarcin/wypok/comments{/number}","issue_comment_url":"https://api.github.com/repos/smolamarcin/wypok/issues/comments{/number}","contents_url":"https://api.github.com/repos/smolamarcin/wypok/contents/{+path}","compare_url":"https://api.github.com/repos/smolamarcin/wypok/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smolamarcin/wypok/merges","archive_url":"https://api.github.com/repos/smolamarcin/wypok/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smolamarcin/wypok/downloads","issues_url":"https://api.github.com/repos/smolamarcin/wypok/issues{/number}","pulls_url":"https://api.github.com/repos/smolamarcin/wypok/pulls{/number}","milestones_url":"https://api.github.com/repos/smolamarcin/wypok/milestones{/number}","notifications_url":"https://api.github.com/repos/smolamarcin/wypok/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smolamarcin/wypok/labels{/name}","releases_url":"https://api.github.com/repos/smolamarcin/wypok/releases{/id}","deployments_url":"https://api.github.com/repos/smolamarcin/wypok/deployments","created_at":"2018-04-16T15:06:21Z","updated_at":"2018-04-23T09:36:33Z","pushed_at":"2018-04-26T08:42:40Z","git_url":"git://github.com/smolamarcin/wypok.git","ssh_url":"git@github.com:smolamarcin/wypok.git","clone_url":"https://github.com/smolamarcin/wypok.git","svn_url":"https://github.com/smolamarcin/wypok","homepage":null,"size":118,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dev"}},"base":{"label":"smolamarcin:dev","ref":"dev","sha":"8ea277dd28e495562b200f9b11a068dc42596a31","user":{"login":"smolamarcin","id":27737154,"avatar_url":"https://avatars2.githubusercontent.com/u/27737154?v=4","gravatar_id":"","url":"https://api.github.com/users/smolamarcin","html_url":"https://github.com/smolamarcin","followers_url":"https://api.github.com/users/smolamarcin/followers","following_url":"https://api.github.com/users/smolamarcin/following{/other_user}","gists_url":"https://api.github.com/users/smolamarcin/gists{/gist_id}","starred_url":"https://api.github.com/users/smolamarcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolamarcin/subscriptions","organizations_url":"https://api.github.com/users/smolamarcin/orgs","repos_url":"https://api.github.com/users/smolamarcin/repos","events_url":"https://api.github.com/users/smolamarcin/events{/privacy}","received_events_url":"https://api.github.com/users/smolamarcin/received_events","type":"User","site_admin":false},"repo":{"id":129762012,"name":"wypok","full_name":"smolamarcin/wypok","owner":{"login":"smolamarcin","id":27737154,"avatar_url":"https://avatars2.githubusercontent.com/u/27737154?v=4","gravatar_id":"","url":"https://api.github.com/users/smolamarcin","html_url":"https://github.com/smolamarcin","followers_url":"https://api.github.com/users/smolamarcin/followers","following_url":"https://api.github.com/users/smolamarcin/following{/other_user}","gists_url":"https://api.github.com/users/smolamarcin/gists{/gist_id}","starred_url":"https://api.github.com/users/smolamarcin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolamarcin/subscriptions","organizations_url":"https://api.github.com/users/smolamarcin/orgs","repos_url":"https://api.github.com/users/smolamarcin/repos","events_url":"https://api.github.com/users/smolamarcin/events{/privacy}","received_events_url":"https://api.github.com/users/smolamarcin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/smolamarcin/wypok","description":null,"fork":false,"url":"https://api.github.com/repos/smolamarcin/wypok","forks_url":"https://api.github.com/repos/smolamarcin/wypok/forks","keys_url":"https://api.github.com/repos/smolamarcin/wypok/keys{/key_id}","collaborators_url":"https://api.github.com/repos/smolamarcin/wypok/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/smolamarcin/wypok/teams","hooks_url":"https://api.github.com/repos/smolamarcin/wypok/hooks","issue_events_url":"https://api.github.com/repos/smolamarcin/wypok/issues/events{/number}","events_url":"https://api.github.com/repos/smolamarcin/wypok/events","assignees_url":"https://api.github.com/repos/smolamarcin/wypok/assignees{/user}","branches_url":"https://api.github.com/repos/smolamarcin/wypok/branches{/branch}","tags_url":"https://api.github.com/repos/smolamarcin/wypok/tags","blobs_url":"https://api.github.com/repos/smolamarcin/wypok/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/smolamarcin/wypok/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/smolamarcin/wypok/git/refs{/sha}","trees_url":"https://api.github.com/repos/smolamarcin/wypok/git/trees{/sha}","statuses_url":"https://api.github.com/repos/smolamarcin/wypok/statuses/{sha}","languages_url":"https://api.github.com/repos/smolamarcin/wypok/languages","stargazers_url":"https://api.github.com/repos/smolamarcin/wypok/stargazers","contributors_url":"https://api.github.com/repos/smolamarcin/wypok/contributors","subscribers_url":"https://api.github.com/repos/smolamarcin/wypok/subscribers","subscription_url":"https://api.github.com/repos/smolamarcin/wypok/subscription","commits_url":"https://api.github.com/repos/smolamarcin/wypok/commits{/sha}","git_commits_url":"https://api.github.com/repos/smolamarcin/wypok/git/commits{/sha}","comments_url":"https://api.github.com/repos/smolamarcin/wypok/comments{/number}","issue_comment_url":"https://api.github.com/repos/smolamarcin/wypok/issues/comments{/number}","contents_url":"https://api.github.com/repos/smolamarcin/wypok/contents/{+path}","compare_url":"https://api.github.com/repos/smolamarcin/wypok/compare/{base}...{head}","merges_url":"https://api.github.com/repos/smolamarcin/wypok/merges","archive_url":"https://api.github.com/repos/smolamarcin/wypok/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/smolamarcin/wypok/downloads","issues_url":"https://api.github.com/repos/smolamarcin/wypok/issues{/number}","pulls_url":"https://api.github.com/repos/smolamarcin/wypok/pulls{/number}","milestones_url":"https://api.github.com/repos/smolamarcin/wypok/milestones{/number}","notifications_url":"https://api.github.com/repos/smolamarcin/wypok/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/smolamarcin/wypok/labels{/name}","releases_url":"https://api.github.com/repos/smolamarcin/wypok/releases{/id}","deployments_url":"https://api.github.com/repos/smolamarcin/wypok/deployments","created_at":"2018-04-16T15:06:21Z","updated_at":"2018-04-23T09:36:33Z","pushed_at":"2018-04-26T08:42:40Z","git_url":"git://github.com/smolamarcin/wypok.git","ssh_url":"git@github.com:smolamarcin/wypok.git","clone_url":"https://github.com/smolamarcin/wypok.git","svn_url":"https://github.com/smolamarcin/wypok","homepage":null,"size":118,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":null,"forks":0,"open_issues":1,"watchers":0,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/1"},"html":{"href":"https://github.com/smolamarcin/wypok/pull/1"},"issue":{"href":"https://api.github.com/repos/smolamarcin/wypok/issues/1"},"comments":{"href":"https://api.github.com/repos/smolamarcin/wypok/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/smolamarcin/wypok/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/smolamarcin/wypok/statuses/c074a48caabac5faa38b18255258b2598c5b936e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"Mats30"}}