use of org.sonar.server.ce.queue.BranchSupport.ComponentKey in project sonarqube by SonarSource.
the class BranchSupportTest method createComponentKey_delegates_to_delegate_if_characteristics_is_not_empty.
@Test
public void createComponentKey_delegates_to_delegate_if_characteristics_is_not_empty() {
String projectKey = randomAlphanumeric(12);
Map<String, String> nonEmptyMap = newRandomNonEmptyMap();
ComponentKey expected = mock(ComponentKey.class);
when(branchSupportDelegate.createComponentKey(projectKey, nonEmptyMap)).thenReturn(expected);
ComponentKey componentKey = underTestWithBranch.createComponentKey(projectKey, nonEmptyMap);
assertThat(componentKey).isSameAs(expected);
}
use of org.sonar.server.ce.queue.BranchSupport.ComponentKey in project sonarqube by SonarSource.
the class BranchSupportTest method createBranchComponent_fails_with_ISE_if_delegate_is_null.
@Test
public void createBranchComponent_fails_with_ISE_if_delegate_is_null() {
DbSession dbSession = mock(DbSession.class);
ComponentKey componentKey = mock(ComponentKey.class);
ComponentDto mainComponentDto = new ComponentDto();
BranchDto mainComponentBranchDto = new BranchDto();
assertThatThrownBy(() -> underTestNoBranch.createBranchComponent(dbSession, componentKey, mainComponentDto, mainComponentBranchDto)).isInstanceOf(IllegalStateException.class).hasMessage("Current edition does not support branch feature");
}
use of org.sonar.server.ce.queue.BranchSupport.ComponentKey in project sonarqube by SonarSource.
the class BranchSupportTest method createComponentKey_of_main_branch.
@Test
public void createComponentKey_of_main_branch() {
String projectKey = randomAlphanumeric(12);
ComponentKey componentKey = underTestNoBranch.createComponentKey(projectKey, NO_CHARACTERISTICS);
assertThat(componentKey).isEqualTo(underTestWithBranch.createComponentKey(projectKey, NO_CHARACTERISTICS));
assertThat(componentKey.getKey()).isEqualTo(projectKey);
assertThat(componentKey.getDbKey()).isEqualTo(projectKey);
assertThat(componentKey.getMainBranchComponentKey()).isSameAs(componentKey);
assertThat(componentKey.getBranchName()).isEmpty();
assertThat(componentKey.getPullRequestKey()).isEmpty();
}
use of org.sonar.server.ce.queue.BranchSupport.ComponentKey in project sonarqube by SonarSource.
the class BranchSupportTest method createBranchComponent_delegates_to_delegate.
@Test
public void createBranchComponent_delegates_to_delegate() {
DbSession dbSession = mock(DbSession.class);
ComponentKey componentKey = mock(ComponentKey.class);
ComponentDto mainComponentDto = new ComponentDto();
ComponentDto expected = new ComponentDto();
BranchDto mainComponentBranchDto = new BranchDto();
when(branchSupportDelegate.createBranchComponent(dbSession, componentKey, mainComponentDto, mainComponentBranchDto)).thenReturn(expected);
ComponentDto dto = underTestWithBranch.createBranchComponent(dbSession, componentKey, mainComponentDto, mainComponentBranchDto);
assertThat(dto).isSameAs(expected);
}
Aggregations