use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class TrackerTargetBranchInputFactoryTest method gets_nothing_when_there_is_no_matching_component.
@Test
public void gets_nothing_when_there_is_no_matching_component() {
Component component = mock(Component.class);
when(component.getDbKey()).thenReturn(COMPONENT_KEY);
when(component.getType()).thenReturn(Component.Type.FILE);
Input<DefaultIssue> input = underTest.createForTargetBranch(component);
assertThat(input.getIssues()).isEmpty();
assertThat(input.getLineHashSequence().length()).isZero();
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SourceLinesHashCacheTest method get_throws_ISE_if_not_cached.
@Test
public void get_throws_ISE_if_not_cached() {
Component component = createComponent(1);
assertThatThrownBy(() -> underTest.get(component)).isInstanceOf(IllegalStateException.class).hasMessage("Source line hashes for component ReportComponent{ref=1, key='FILE_KEY', type=FILE} not cached");
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SourceLinesHashCacheTest method should_computeIfAbsent.
@Test
public void should_computeIfAbsent() {
Component component = createComponent(1);
Function<Component, List<String>> f = mock(Function.class);
List<String> list = Collections.singletonList("hash1");
when(f.apply(component)).thenReturn(list);
assertThat(underTest.contains(component)).isFalse();
List<String> returned = underTest.computeIfAbsent(component, f);
assertThat(returned).isEqualTo(list);
assertThat(underTest.contains(component)).isTrue();
returned = underTest.computeIfAbsent(component, f);
assertThat(returned).isEqualTo(list);
verify(f).apply(component);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class SourceLinesHashCacheTest method get_returns_value_if_cached.
@Test
public void get_returns_value_if_cached() {
List<String> list = Collections.singletonList("hash1");
Component component = createComponent(1);
underTest.computeIfAbsent(component, c -> list);
assertThat(underTest.get(component)).isEqualTo(list);
}
use of org.sonar.ce.task.projectanalysis.component.Component in project sonarqube by SonarSource.
the class DbLineHashVersionTest method hasLineHashWithSignificantCode_should_return_true.
@Test
public void hasLineHashWithSignificantCode_should_return_true() {
ComponentDto project = db.components().insertPublicProject();
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(project));
db.fileSources().insertFileSource(file, dto -> dto.setLineHashesVersion(LineHashVersion.WITH_SIGNIFICANT_CODE.getDbValue()));
Component component = ReportComponent.builder(Component.Type.FILE, 1).setKey("key").setUuid(file.uuid()).build();
assertThat(underTest.hasLineHashesWithSignificantCode(component)).isTrue();
}
Aggregations