Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
t-8ch committed Nov 8, 2016
1 parent a150d4f commit 250ac06
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ public void setUp() throws Exception {
when(stashRequestFacade.getSonarQubeReviewer(Mockito.anyString(), (StashClient) Mockito.anyObject())).thenReturn(stashUser);
when(stashRequestFacade.getPullRequestDiffReport(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), (StashClient) Mockito.anyObject())).thenReturn(diffReport);
when(stashRequestFacade.getIssueThreshold()).thenReturn(STASH_ISSUE_THRESHOLD);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
}

@Test
public void testExecuteOn() throws Exception {
myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(0)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -119,7 +120,6 @@ public void testExecuteOnWithReachedThreshold() throws Exception {
when(report.countIssues()).thenReturn(101);
when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(0)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -131,7 +131,6 @@ public void testExecuteOnWithReachedThreshold() throws Exception {
public void testExecuteOnWithNoPluginActivation() throws Exception {
when(config.hasToNotifyStash()).thenReturn(false);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(0)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -145,7 +144,6 @@ public void testExecuteOnWithNoPluginActivation() throws Exception {
public void testExecuteOnWithNoStashUserDefined() throws Exception {
when(stashRequestFacade.getSonarQubeReviewer(Mockito.anyString(), (StashClient) Mockito.anyObject())).thenReturn(null);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(0)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -159,7 +157,6 @@ public void testExecuteOnWithNoStashUserDefined() throws Exception {
public void testExecuteOnWithResetCommentActivated() throws Exception {
when(config.resetComments()).thenReturn(true);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(1)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -172,7 +169,6 @@ public void testExecuteOnWithNoDiffReport() throws Exception {
diffReport = null;
when(stashRequestFacade.getPullRequestDiffReport(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), (StashClient) Mockito.anyObject())).thenReturn(diffReport);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(0)).resetComments(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(diffReport), eq(stashUser), (StashClient) Mockito.anyObject());
Expand All @@ -190,7 +186,6 @@ public void testExecuteOnWithPullRequestApprovalAndNoNewIssue() throws Exception
when(report.countIssues()).thenReturn(0);
when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(1)).postCommentPerIssue(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(report), eq(diffReport), (StashClient) Mockito.anyObject());
Expand All @@ -207,7 +202,6 @@ public void testExecuteOnWithPullRequestApprovalAndNewIssues() throws Exception
when(report.countIssues()).thenReturn(10);
when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(1)).postCommentPerIssue(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(report), eq(diffReport), (StashClient) Mockito.anyObject());
Expand All @@ -224,7 +218,6 @@ public void testExecuteOnWithoutPullRequestApproval() throws Exception {
when(report.countIssues()).thenReturn(0);
when(stashRequestFacade.extractIssueReport(projectIssues, inputFileCache)).thenReturn(report);

myJob = new StashIssueReportingPostJob(config, projectIssues, inputFileCache, stashRequestFacade);
myJob.executeOn(project, context);

verify(stashRequestFacade, times(1)).postCommentPerIssue(eq(STASH_PROJECT), eq(STASH_REPOSITORY), eq(STASH_PULLREQUEST_ID), eq(SONARQUBE_URL), eq(report), eq(diffReport), (StashClient) Mockito.anyObject());
Expand Down

0 comments on commit 250ac06

Please sign in to comment.