Skip to content

Commit

Permalink
Test 16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
C4tWithShell committed Dec 11, 2023
1 parent 49d37f7 commit 982f069
Showing 1 changed file with 0 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,50 +141,6 @@ public void testBranchNameNoMatchingBranch() {
testCase.load(metadata);
}

@Test
public void testBranchNameMatchingBranch() {
BranchDto branchDto = mock(BranchDto.class);
when(branchDto.getBranchType()).thenReturn(BranchType.BRANCH);
when(branchDto.getKey()).thenReturn("branchKey");
when(branchDto.getMergeBranchUuid()).thenReturn("mergeBranchUuid");
when(branchDto.getProjectUuid()).thenReturn("projectUuid");
when(branchDto.getUuid()).thenReturn("branchUuid");

BranchDao branchDao = mock(BranchDao.class);
when(branchDao.selectByBranchKey(any(), eq("projectUuid"), eq("branch"))).thenReturn(Optional.of(branchDto));

ScannerReport.Metadata metadata =
ScannerReport.Metadata.getDefaultInstance().toBuilder().setBranchName("branch")
.setBranchType(ScannerReport.Metadata.BranchType.BRANCH).build();

when(dbClient.branchDao()).thenReturn(branchDao);

when(metadataHolder.getProject()).thenReturn(new Project("projectUuid", "key", "name", "description", new ArrayList<>()));

testCase.load(metadata);

ArgumentCaptor<Branch> branchArgumentCaptor = ArgumentCaptor.forClass(Branch.class);

verify(metadataHolder).setBranch(branchArgumentCaptor.capture());
assertEquals(BranchType.BRANCH, branchArgumentCaptor.getValue().getType());
assertEquals("projectUuid", branchArgumentCaptor.getValue().getReferenceBranchUuid());
assertEquals("branch", branchArgumentCaptor.getValue().getName());
assertFalse(branchArgumentCaptor.getValue().isMain());
assertFalse(branchArgumentCaptor.getValue().supportsCrossProjectCpd());

verify(metadataHolder).getProject();
verify(metadataHolder).setPullRequestKey(anyString());

verifyNoMoreInteractions(metadataHolder);

verify(dbClient).branchDao();
verify(dbClient).openSession(anyBoolean());
verifyNoMoreInteractions(dbClient);

verify(branchDao).selectByBranchKey(any(), any(), any());
verifyNoMoreInteractions(branchDao);
}

@Test
public void testBranchNamePullRequest() {
BranchDto branchDto = mock(BranchDto.class);
Expand Down

0 comments on commit 982f069

Please sign in to comment.