Search in sources :

Example 1 with ComponentKey

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);
}
Also used : ComponentKey(org.sonar.server.ce.queue.BranchSupport.ComponentKey) Test(org.junit.Test)

Example 2 with ComponentKey

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");
}
Also used : DbSession(org.sonar.db.DbSession) BranchDto(org.sonar.db.component.BranchDto) ComponentKey(org.sonar.server.ce.queue.BranchSupport.ComponentKey) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 3 with ComponentKey

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();
}
Also used : ComponentKey(org.sonar.server.ce.queue.BranchSupport.ComponentKey) Test(org.junit.Test)

Example 4 with ComponentKey

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);
}
Also used : DbSession(org.sonar.db.DbSession) BranchDto(org.sonar.db.component.BranchDto) ComponentKey(org.sonar.server.ce.queue.BranchSupport.ComponentKey) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 ComponentKey (org.sonar.server.ce.queue.BranchSupport.ComponentKey)4 DbSession (org.sonar.db.DbSession)2 BranchDto (org.sonar.db.component.BranchDto)2 ComponentDto (org.sonar.db.component.ComponentDto)2