import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.utils.System2;
-import org.sonar.core.util.Uuids;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.component.SnapshotDto;
@Override
public void visitView(Component view, Path<SnapshotDtoHolder> path) {
- SnapshotDto snapshot = createAnalysis(Uuids.create(), view, false);
+ SnapshotDto snapshot = createAnalysis(analysisMetadataHolder.getUuid(), view, false);
updateSnapshotPeriods(snapshot);
persist(snapshot, dbSession);
}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.sonar.core.config.CorePropertyDefinitions.TIMEMACHINE_MODE_DATE;
-import static org.sonar.db.component.ComponentTesting.newProjectCopy;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.db.component.ComponentTesting.newSubView;
import static org.sonar.db.component.ComponentTesting.newView;
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
-
@Rule
public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
-
@Rule
public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
-
@Rule
public PeriodsHolderRule periodsHolder = new PeriodsHolderRule();
@Test
public void persist_analysis() {
ComponentDto viewDto = save(newView("UUID_VIEW").setKey("KEY_VIEW"));
- ComponentDto subViewDto = save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
- ComponentDto projectDto = save(newProjectDto("proj"));
- ComponentDto projectViewDto = save(newProjectCopy("UUID_PROJECT_COPY", projectDto, subViewDto).setKey("KEY_PROJECT_COPY"));
+ save(newSubView(viewDto, "UUID_SUBVIEW", "KEY_SUBVIEW"));
+ save(newProjectDto("proj"));
dbTester.getSession().commit();
Component projectView = ViewsComponent.builder(PROJECT_VIEW, "KEY_PROJECT_COPY").setUuid("UUID_PROJECT_COPY").build();
assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1);
SnapshotDto viewSnapshot = getUnprocessedSnapshot(viewDto.uuid());
+ assertThat(viewSnapshot.getUuid()).isEqualTo(ANALYSIS_UUID);
assertThat(viewSnapshot.getComponentUuid()).isEqualTo(view.getUuid());
assertThat(viewSnapshot.getVersion()).isNull();
assertThat(viewSnapshot.getLast()).isFalse();