diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2016-07-08 15:46:23 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2016-07-11 18:32:47 +0200 |
commit | 289dff0fdd23e32a3d326ca69a5337368254878d (patch) | |
tree | f7d60c3f0fc0e95392b5c38e809c2c023ee17976 | |
parent | 3731d21239bc7fb9faa9fd7e3652a64cdadc24ab (diff) | |
download | sonarqube-289dff0fdd23e32a3d326ca69a5337368254878d.tar.gz sonarqube-289dff0fdd23e32a3d326ca69a5337368254878d.zip |
SONAR-7700 use "B columns" strategy for update of PROJECTS
B columns are used to keep changes in a "functional" transaction
but not a DB transaction
51 files changed, 1691 insertions, 373 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolder.java new file mode 100644 index 00000000000..3279e1b754b --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolder.java @@ -0,0 +1,28 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.computation.component; + +import java.util.Collection; + +public interface DisabledComponentsHolder { + + Collection<String> getUuids(); + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolderImpl.java new file mode 100644 index 00000000000..2d582d6dbb3 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/DisabledComponentsHolderImpl.java @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.computation.component; + +import java.util.Collection; + +import static com.google.common.base.Preconditions.checkState; + +public class DisabledComponentsHolderImpl implements MutableDisabledComponentsHolder { + + private Collection<String> uuids; + + @Override + public Collection<String> getUuids() { + checkState(uuids != null, "UUIDs have not been set in repository"); + return uuids; + } + + @Override + public void setUuids(Collection<String> uuids) { + checkState(this.uuids == null, "UUIDs have already been set in repository"); + this.uuids = uuids; + } +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/component/MutableDisabledComponentsHolder.java b/server/sonar-server/src/main/java/org/sonar/server/computation/component/MutableDisabledComponentsHolder.java new file mode 100644 index 00000000000..635a89a810b --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/component/MutableDisabledComponentsHolder.java @@ -0,0 +1,28 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.server.computation.component; + +import java.util.Collection; + +public interface MutableDisabledComponentsHolder extends DisabledComponentsHolder { + + void setUuids(Collection<String> uuids); + +} diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java index ab1b9987826..1f447afc1e7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java @@ -31,6 +31,7 @@ import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl; import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl; import org.sonar.server.computation.batch.BatchReportReaderImpl; import org.sonar.server.computation.component.DbIdsRepositoryImpl; +import org.sonar.server.computation.component.DisabledComponentsHolderImpl; import org.sonar.server.computation.component.SettingsRepositoryImpl; import org.sonar.server.computation.component.TreeRootHolderImpl; import org.sonar.server.computation.duplication.CrossProjectDuplicationStatusHolderImpl; @@ -160,6 +161,7 @@ public final class ReportComputeEngineContainerPopulator implements ContainerPop EventRepositoryImpl.class, SettingsRepositoryImpl.class, DbIdsRepositoryImpl.class, + DisabledComponentsHolderImpl.class, QualityGateServiceImpl.class, EvaluationResultTextConverterImpl.class, SourceLinesRepositoryImpl.class, diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/dbcleaner/ProjectCleaner.java b/server/sonar-server/src/main/java/org/sonar/server/computation/dbcleaner/ProjectCleaner.java index 68c18ee5347..5276784ad37 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/dbcleaner/ProjectCleaner.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/dbcleaner/ProjectCleaner.java @@ -19,6 +19,7 @@ */ package org.sonar.server.computation.dbcleaner; +import java.util.Collection; import org.sonar.api.CoreProperties; import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.config.Settings; @@ -53,11 +54,11 @@ public class ProjectCleaner { this.purgeListener = purgeListener; } - public ProjectCleaner purge(DbSession session, IdUuidPair idUuidPair, Settings projectSettings) { + public ProjectCleaner purge(DbSession session, IdUuidPair idUuidPair, Settings projectSettings, Collection<String> disabledComponentUuids) { long start = System.currentTimeMillis(); profiler.reset(); - PurgeConfiguration configuration = newDefaultPurgeConfiguration(projectSettings, idUuidPair); + PurgeConfiguration configuration = newDefaultPurgeConfiguration(projectSettings, idUuidPair, disabledComponentUuids); cleanHistoricalData(session, configuration.rootProjectIdUuid().getUuid(), projectSettings); doPurge(session, configuration); diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java index b009eb7c154..708f7706d76 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/EnableAnalysisStep.java @@ -44,6 +44,7 @@ public class EnableAnalysisStep implements ComputationStep { try { Component project = treeRootHolder.getRoot(); dbClient.snapshotDao().switchIsLastFlagAndSetProcessedStatus(dbSession, project.getUuid(), analysisMetadataHolder.getUuid()); + dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, project.getUuid()); dbSession.commit(); } finally { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java index ed8592dbd93..e096849ab81 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PersistComponentsStep.java @@ -20,22 +20,28 @@ package org.sonar.server.computation.step; import com.google.common.base.Predicate; +import java.util.Collection; import java.util.Date; import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.System2; +import org.sonar.core.util.stream.GuavaCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.component.ComponentDto; +import org.sonar.db.component.ComponentUpdateDto; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.CrawlerDepthLimit; import org.sonar.server.computation.component.DbIdsRepositoryImpl; import org.sonar.server.computation.component.MutableDbIdsRepository; +import org.sonar.server.computation.component.MutableDisabledComponentsHolder; import org.sonar.server.computation.component.PathAwareCrawler; import org.sonar.server.computation.component.PathAwareVisitor; import org.sonar.server.computation.component.PathAwareVisitorAdapter; @@ -44,7 +50,6 @@ import org.sonar.server.computation.component.TreeRootHolder; import static com.google.common.collect.FluentIterable.from; import static org.sonar.db.component.ComponentDto.UUID_PATH_SEPARATOR; import static org.sonar.db.component.ComponentDto.formatUuidPathFromParent; -import static org.sonar.db.component.ComponentDtoFunctions.toKey; import static org.sonar.server.computation.component.ComponentVisitor.Order.PRE_ORDER; /** @@ -56,12 +61,16 @@ public class PersistComponentsStep implements ComputationStep { private final TreeRootHolder treeRootHolder; private final MutableDbIdsRepository dbIdsRepository; private final System2 system2; + private final MutableDisabledComponentsHolder disabledComponentsHolder; - public PersistComponentsStep(DbClient dbClient, TreeRootHolder treeRootHolder, MutableDbIdsRepository dbIdsRepository, System2 system2) { + public PersistComponentsStep(DbClient dbClient, TreeRootHolder treeRootHolder, + MutableDbIdsRepository dbIdsRepository, System2 system2, + MutableDisabledComponentsHolder disabledComponentsHolder) { this.dbClient = dbClient; this.treeRootHolder = treeRootHolder; this.dbIdsRepository = dbIdsRepository; this.system2 = system2; + this.disabledComponentsHolder = disabledComponentsHolder; } @Override @@ -71,20 +80,47 @@ public class PersistComponentsStep implements ComputationStep { @Override public void execute() { - DbSession session = dbClient.openSession(false); + DbSession dbSession = dbClient.openSession(false); try { - Map<String, ComponentDto> existingComponentDtosByKey = indexExistingDtosByKey(session); - new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingComponentDtosByKey, session)) + String projectUuid = treeRootHolder.getRoot().getUuid(); + + // safeguard, reset all rows to b-changed=false + dbClient.componentDao().resetBChangedForRootComponentUuid(dbSession, projectUuid); + + Map<String, ComponentDto> existingDtosByKeys = indexExistingDtosByKey(dbSession); + // Insert or update the components in database. They are removed from existingDtosByKeys + // at the same time. + new PathAwareCrawler<>(new PersistComponentStepsVisitor(existingDtosByKeys, dbSession)) .visit(treeRootHolder.getRoot()); - session.commit(); + + disableRemainingComponents(dbSession, existingDtosByKeys.values()); + + dbSession.commit(); } finally { - dbClient.closeSession(session); + dbClient.closeSession(dbSession); } } + private void disableRemainingComponents(DbSession dbSession, Collection<ComponentDto> dtos) { + dtos.stream() + .filter(ComponentDto::isEnabled) + .forEach(c -> { + ComponentUpdateDto update = ComponentUpdateDto.copyFrom(c) + .setBChanged(true) + .setBEnabled(false); + dbClient.componentDao().update(dbSession, update); + }); + disabledComponentsHolder.setUuids(dtos.stream().map(ComponentDto::uuid).collect(GuavaCollectors.toList(dtos.size()))); + } + + /** + * Returns a mutable map of the components currently persisted in database for the project, including + * disabled components. + */ private Map<String, ComponentDto> indexExistingDtosByKey(DbSession session) { - return from(dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getKey())) - .uniqueIndex(toKey()); + return dbClient.componentDao().selectAllComponentsFromProjectKey(session, treeRootHolder.getRoot().getKey()) + .stream() + .collect(Collectors.toMap(ComponentDto::key, Function.identity())); } private class PersistComponentStepsVisitor extends PathAwareVisitorAdapter<ComponentDtoHolder> { @@ -167,16 +203,30 @@ public class PersistComponentsStep implements ComputationStep { } private ComponentDto persistComponent(ComponentDto componentDto) { - ComponentDto existingComponent = existingComponentDtosByKey.get(componentDto.getKey()); + ComponentDto existingComponent = existingComponentDtosByKey.remove(componentDto.getKey()); if (existingComponent == null) { dbClient.componentDao().insert(dbSession, componentDto); return componentDto; - } else { - if (updateExisting(existingComponent, componentDto)) { - dbClient.componentDao().update(dbSession, existingComponent); - } - return existingComponent; } + Optional<ComponentUpdateDto> update = compareForUpdate(existingComponent, componentDto); + if (update.isPresent()) { + ComponentUpdateDto updateDto = update.get(); + dbClient.componentDao().update(dbSession, updateDto); + + // update the fields in memory in order the PathAwareVisitor.Path + // to be up-to-date + existingComponent.setCopyComponentUuid(updateDto.getBCopyComponentUuid()); + existingComponent.setDescription(updateDto.getBDescription()); + existingComponent.setEnabled(updateDto.isBEnabled()); + existingComponent.setLanguage(updateDto.getBLanguage()); + existingComponent.setLongName(updateDto.getBLongName()); + existingComponent.setModuleUuid(updateDto.getBModuleUuid()); + existingComponent.setModuleUuidPath(updateDto.getBModuleUuidPath()); + existingComponent.setName(updateDto.getBName()); + existingComponent.setPath(updateDto.getBPath()); + existingComponent.setQualifier(updateDto.getBQualifier()); + } + return existingComponent; } private void addToCache(Component component, ComponentDto componentDto) { @@ -335,46 +385,25 @@ public class PersistComponentsStep implements ComputationStep { } - private static boolean updateExisting(ComponentDto existingComponent, ComponentDto newComponent) { - boolean modified = false; - if (!StringUtils.equals(existingComponent.name(), newComponent.name())) { - existingComponent.setName(newComponent.name()); - modified = true; - } - if (!StringUtils.equals(existingComponent.longName(), newComponent.longName())) { - existingComponent.setLongName(newComponent.longName()); - modified = true; - } - if (!StringUtils.equals(existingComponent.description(), newComponent.description())) { - existingComponent.setDescription(newComponent.description()); - modified = true; - } - if (!StringUtils.equals(existingComponent.path(), newComponent.path())) { - existingComponent.setPath(newComponent.path()); - modified = true; - } - if (!StringUtils.equals(existingComponent.moduleUuid(), newComponent.moduleUuid())) { - existingComponent.setModuleUuid(newComponent.moduleUuid()); - modified = true; - } - if (!existingComponent.moduleUuidPath().equals(newComponent.moduleUuidPath())) { - existingComponent.setModuleUuidPath(newComponent.moduleUuidPath()); - modified = true; - } - if (!ObjectUtils.equals(existingComponent.getRootUuid(), newComponent.getRootUuid())) { - existingComponent.setRootUuid(newComponent.getRootUuid()); - modified = true; - } - if (!ObjectUtils.equals(existingComponent.getCopyResourceUuid(), newComponent.getCopyResourceUuid())) { - existingComponent.setCopyComponentUuid(newComponent.getCopyResourceUuid()); - modified = true; - } - if (!existingComponent.isEnabled()) { - // If component was previously removed, re-enable it - existingComponent.setEnabled(true); - modified = true; + private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) { + boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) || + !StringUtils.equals(existing.description(), target.description()) || + !existing.isEnabled() || + !StringUtils.equals(existing.language(), target.language()) || + !StringUtils.equals(existing.longName(), target.longName()) || + !StringUtils.equals(existing.moduleUuid(), target.moduleUuid()) || + !StringUtils.equals(existing.moduleUuidPath(), target.moduleUuidPath()) || + !StringUtils.equals(existing.name(), target.name()) || + !StringUtils.equals(existing.path(), target.path()) || + !StringUtils.equals(existing.qualifier(), target.qualifier()); + + ComponentUpdateDto update = null; + if (hasDifferences) { + update = ComponentUpdateDto + .copyFrom(target) + .setBChanged(true); } - return modified; + return Optional.ofNullable(update); } private static String getFileQualifier(Component component) { diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeDatastoresStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeDatastoresStep.java index 6a012ce1556..f9dd5dfaa85 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeDatastoresStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/PurgeDatastoresStep.java @@ -19,16 +19,17 @@ */ package org.sonar.server.computation.step; -import org.sonar.server.computation.dbcleaner.ProjectCleaner; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.purge.IdUuidPair; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.DbIdsRepository; import org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler; +import org.sonar.server.computation.component.DisabledComponentsHolder; import org.sonar.server.computation.component.SettingsRepository; import org.sonar.server.computation.component.TreeRootHolder; import org.sonar.server.computation.component.TypeAwareVisitorAdapter; +import org.sonar.server.computation.dbcleaner.ProjectCleaner; import static org.sonar.server.computation.component.Component.Type.PROJECT; import static org.sonar.server.computation.component.Component.Type.VIEW; @@ -42,14 +43,16 @@ public class PurgeDatastoresStep implements ComputationStep { private final DbIdsRepository dbIdsRepository; private final TreeRootHolder treeRootHolder; private final SettingsRepository settingsRepository; + private final DisabledComponentsHolder disabledComponentsHolder; public PurgeDatastoresStep(DbClient dbClient, ProjectCleaner projectCleaner, DbIdsRepository dbIdsRepository, TreeRootHolder treeRootHolder, - SettingsRepository settingsRepository) { + SettingsRepository settingsRepository, DisabledComponentsHolder disabledComponentsHolder) { this.projectCleaner = projectCleaner; this.dbClient = dbClient; this.dbIdsRepository = dbIdsRepository; this.treeRootHolder = treeRootHolder; this.settingsRepository = settingsRepository; + this.disabledComponentsHolder = disabledComponentsHolder; } @Override @@ -71,7 +74,8 @@ public class PurgeDatastoresStep implements ComputationStep { private void execute(Component root) { DbSession session = dbClient.openSession(true); try { - projectCleaner.purge(session, new IdUuidPair(dbIdsRepository.getComponentId(root), root.getUuid()), settingsRepository.getSettings(root)); + IdUuidPair idUuidPair = new IdUuidPair(dbIdsRepository.getComponentId(root), root.getUuid()); + projectCleaner.purge(session, idUuidPair, settingsRepository.getSettings(root), disabledComponentsHolder.getUuids()); session.commit(); } finally { dbClient.closeSession(session); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/dbcleaner/ProjectCleanerTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/dbcleaner/ProjectCleanerTest.java index 7886adb6c0c..4bf77a708fb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/dbcleaner/ProjectCleanerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/dbcleaner/ProjectCleanerTest.java @@ -33,6 +33,7 @@ import org.sonar.db.purge.PurgeListener; import org.sonar.db.purge.PurgeProfiler; import org.sonar.db.purge.period.DefaultPeriodCleaner; +import static java.util.Collections.emptyList; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyLong; @@ -59,7 +60,7 @@ public class ProjectCleanerTest { public void no_profiling_when_property_is_false() { settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, false); - underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings); + underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings, emptyList()); verify(profiler, never()).dump(anyLong(), any(Logger.class)); } @@ -68,7 +69,7 @@ public class ProjectCleanerTest { public void profiling_when_property_is_true() { settings.setProperty(CoreProperties.PROFILING_LOG_PROPERTY, true); - underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings); + underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings, emptyList()); verify(profiler).dump(anyLong(), any(Logger.class)); } @@ -77,7 +78,7 @@ public class ProjectCleanerTest { public void call_period_cleaner_index_client_and_purge_dao() { settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5); - underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings); + underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings, emptyList()); verify(periodCleaner).clean(any(DbSession.class), anyString(), any(Settings.class)); verify(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class)); @@ -87,7 +88,7 @@ public class ProjectCleanerTest { public void if_dao_purge_fails_it_should_not_interrupt_program_execution() { doThrow(RuntimeException.class).when(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class)); - underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings); + underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings, emptyList()); verify(dao).purge(any(DbSession.class), any(PurgeConfiguration.class), any(PurgeListener.class), any(PurgeProfiler.class)); } @@ -96,7 +97,7 @@ public class ProjectCleanerTest { public void if_profiler_cleaning_fails_it_should_not_interrupt_program_execution() { doThrow(RuntimeException.class).when(periodCleaner).clean(any(DbSession.class), anyString(), any(Settings.class)); - underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings); + underTest.purge(mock(DbSession.class), mock(IdUuidPair.class), settings, emptyList()); verify(periodCleaner).clean(any(DbSession.class), anyString(), any(Settings.class)); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepTest.java index 7e59ceae161..835d519e14f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/PurgeDatastoresStepTest.java @@ -36,6 +36,7 @@ import org.sonar.db.purge.IdUuidPair; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.MutableDbIdsRepositoryRule; +import org.sonar.server.computation.component.MutableDisabledComponentsHolder; import org.sonar.server.computation.component.ReportComponent; import org.sonar.server.computation.component.SettingsRepository; import org.sonar.server.computation.component.ViewsComponent; @@ -44,6 +45,8 @@ import org.sonar.server.util.WrapInSingleElementArray; import static java.util.Arrays.asList; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.anyList; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -62,10 +65,11 @@ public class PurgeDatastoresStepTest extends BaseStepTest { @Rule public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.standalone(); - ProjectCleaner projectCleaner = mock(ProjectCleaner.class); - SettingsRepository settingsRepository = mock(SettingsRepository.class); + private ProjectCleaner projectCleaner = mock(ProjectCleaner.class); + private SettingsRepository settingsRepository = mock(SettingsRepository.class); + private MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS); - PurgeDatastoresStep underTest = new PurgeDatastoresStep(mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS), projectCleaner, dbIdsRepository, treeRootHolder, settingsRepository); + private PurgeDatastoresStep underTest = new PurgeDatastoresStep(mock(DbClient.class, Mockito.RETURNS_DEEP_STUBS), projectCleaner, dbIdsRepository, treeRootHolder, settingsRepository, disabledComponentsHolder); @Test public void call_purge_method_of_the_purge_task_for_project() { @@ -133,7 +137,7 @@ public class PurgeDatastoresStepTest extends BaseStepTest { underTest.execute(); ArgumentCaptor<IdUuidPair> argumentCaptor = ArgumentCaptor.forClass(IdUuidPair.class); - verify(projectCleaner).purge(any(DbSession.class), argumentCaptor.capture(), any(Settings.class)); + verify(projectCleaner).purge(any(DbSession.class), argumentCaptor.capture(), any(Settings.class), anyList()); assertThat(argumentCaptor.getValue().getId()).isEqualTo(PROJECT_ID); assertThat(argumentCaptor.getValue().getUuid()).isEqualTo(PROJECT_UUID); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java index dbddd340e32..49408590951 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ReportPersistComponentsStepTest.java @@ -35,9 +35,11 @@ import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.Component; import org.sonar.server.computation.component.FileAttributes; import org.sonar.server.computation.component.MutableDbIdsRepositoryRule; +import org.sonar.server.computation.component.MutableDisabledComponentsHolder; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.guava.api.Assertions.assertThat; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.server.computation.component.Component.Type.DIRECTORY; @@ -45,12 +47,11 @@ import static org.sonar.server.computation.component.Component.Type.FILE; import static org.sonar.server.computation.component.Component.Type.PROJECT; import static org.sonar.server.computation.component.ReportComponent.builder; - public class ReportPersistComponentsStepTest extends BaseStepTest { private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); - private static final String PROJECT_KEY = "PROJECT_KEY"; + private static final String MODULE_KEY = "MODULE_KEY"; @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); @@ -59,20 +60,18 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { @Rule public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder); - System2 system2 = mock(System2.class); - - DbClient dbClient = dbTester.getDbClient(); - - Date now; - - PersistComponentsStep underTest; + private System2 system2 = mock(System2.class); + private DbClient dbClient = dbTester.getDbClient(); + private Date now; + private MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS); + private PersistComponentsStep underTest; @Before public void setup() throws Exception { now = DATE_FORMAT.parse("2015-06-02"); when(system2.now()).thenReturn(now.getTime()); - underTest = new PersistComponentsStep(dbClient, treeRootHolder, dbIdsRepository, system2); + underTest = new PersistComponentsStep(dbClient, treeRootHolder, dbIdsRepository, system2, disabledComponentsHolder); } @Override @@ -90,7 +89,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { .setPath("src/main/java/dir") .addChildren(file) .build(); - Component module = builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + Component module = builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setPath("module") .setName("Module") .setDescription("Module description") @@ -120,7 +119,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectDto.getRootUuid()).isEqualTo("ABCD"); assertThat(projectDto.getCreatedAt()).isEqualTo(now); - ComponentDto moduleDto = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); + ComponentDto moduleDto = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get(); assertThat(moduleDto.name()).isEqualTo("Module"); assertThat(moduleDto.description()).isEqualTo("Module description"); assertThat(moduleDto.path()).isEqualTo("module"); @@ -219,7 +218,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { // Project amd module already exists ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module"); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); dbClient.componentDao().insert(dbTester.getSession(), module); dbTester.getSession().commit(); @@ -227,7 +226,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .addChildren( builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir") @@ -248,7 +247,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectReloaded.getId()).isEqualTo(project.getId()); assertThat(projectReloaded.uuid()).isEqualTo(project.uuid()); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); + ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get(); assertThat(moduleReloaded.getId()).isEqualTo(module.getId()); assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid()); assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); @@ -275,7 +274,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .addChildren( builder(Component.Type.MODULE, 3).setUuid("CDEF").setKey("SUB_MODULE_1_KEY") @@ -300,7 +299,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(project).isPresent(); assertThat(project.get().getRootUuid()).isEqualTo("ABCD"); - Optional<ComponentDto> module = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY"); + Optional<ComponentDto> module = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY); assertThat(module).isPresent(); assertThat(module.get().getRootUuid()).isEqualTo(project.get().uuid()); @@ -364,7 +363,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { public void nothing_to_persist() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module"); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); dbClient.componentDao().insert(dbTester.getSession(), module); ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir"); ComponentDto file = ComponentTesting.newFileDto(module, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_KEY:src/main/java/dir/Foo.java"); @@ -375,7 +374,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .addChildren( builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir") @@ -392,7 +391,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get().getId()).isEqualTo(project.getId()); - assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get().getId()).isEqualTo(module.getId()); + assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get().getId()).isEqualTo(module.getId()); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get().getId()).isEqualTo(directory.getId()); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(file.getId()); @@ -404,7 +403,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectReloaded.projectUuid()).isEqualTo(project.projectUuid()); assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); + ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get(); assertThat(moduleReloaded.getId()).isEqualTo(module.getId()); assertThat(moduleReloaded.uuid()).isEqualTo(module.uuid()); assertThat(moduleReloaded.moduleUuid()).isEqualTo(module.moduleUuid()); @@ -432,65 +431,49 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { } @Test - public void update_module_name() { - ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); - dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setPath("path"); - dbClient.componentDao().insert(dbTester.getSession(), module); - dbTester.getSession().commit(); - - treeRootHolder.setRoot( - builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) - .setName("New project name") - .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") - .setName("New module name") - .setPath("New path") - .build()) - .build()); - - underTest.execute(); - - ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get(); - assertThat(projectReloaded.name()).isEqualTo("New project name"); - - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); - assertThat(moduleReloaded.name()).isEqualTo("New module name"); - } - - @Test - public void update_module_description() { + public void update_module_name_and_description() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project").setDescription("Project description"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module"); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); dbClient.componentDao().insert(dbTester.getSession(), module); dbTester.getSession().commit(); treeRootHolder.setRoot( builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) - .setName("Project") + .setName("New Project") .setDescription("New project description") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") - .setName("Module") + builder(Component.Type.MODULE, 2) + .setUuid("BCDE") + .setKey(MODULE_KEY) + .setName("New Module") .setDescription("New module description") .build()) .build()); underTest.execute(); - ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get(); - assertThat(projectReloaded.description()).isEqualTo("New project description"); + // functional transaction not finished, "A-fields" are not updated yet + assertNameAndDescription(PROJECT_KEY, "Project", "Project description"); + assertNameAndDescription(MODULE_KEY, "Module", null); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); - assertThat(moduleReloaded.description()).isEqualTo("New module description"); + // commit functional transaction -> copies B-fields to A-fields + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), "ABCD"); + assertNameAndDescription(PROJECT_KEY, "New Project", "New project description"); + assertNameAndDescription(MODULE_KEY, "New Module", "New module description"); + } + + private void assertNameAndDescription(String key, String expectedName, String expectedDescription) { + ComponentDto dto = dbClient.componentDao().selectByKey(dbTester.getSession(), key).get(); + assertThat(dto.name()).isEqualTo(expectedName); + assertThat(dto.description()).isEqualTo(expectedDescription); } @Test public void update_module_path() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setPath("path"); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path"); dbClient.componentDao().insert(dbTester.getSession(), module); dbTester.getSession().commit(); @@ -498,7 +481,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .setPath("New path") .build()) @@ -506,16 +489,23 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { underTest.execute(); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); - assertThat(moduleReloaded.path()).isEqualTo("New path"); + assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get().path()).isEqualTo("path"); + + // commit the functional transaction + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), project.uuid()); + assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get().path()).isEqualTo("New path"); } @Test public void update_module_uuid_when_moving_a_module() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project).setKey("MODULE_A").setName("Module A"); - ComponentDto moduleB = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_B").setName("Module B"); + ComponentDto moduleA = ComponentTesting.newModuleDto("EDCB", project) + .setKey("MODULE_A") + .setName("Module A"); + ComponentDto moduleB = ComponentTesting.newModuleDto("BCDE", project) + .setKey("MODULE_B") + .setName("Module B"); dbClient.componentDao().insert(dbTester.getSession(), moduleA, moduleB); ComponentDto directory = ComponentTesting.newDirectory(moduleB, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_B:src/main/java/dir"); ComponentDto file = ComponentTesting.newFileDto(moduleB, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java").setKey("MODULE_B:src/main/java/dir/Foo.java"); @@ -545,6 +535,10 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { underTest.execute(); + // commit the functional transaction + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), project.uuid()); + dbTester.commit(); + assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(5); ComponentDto moduleAreloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_A").get(); @@ -579,19 +573,17 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { Date oldDate = DateUtils.parseDate("2015-01-01"); ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project").setCreatedAt(oldDate); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setPath("path").setCreatedAt(oldDate); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module").setPath("path").setCreatedAt(oldDate); dbClient.componentDao().insert(dbTester.getSession(), module); dbTester.getSession().commit(); treeRootHolder.setRoot( builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) - .setName("New project name") .build()); underTest.execute(); Optional<ComponentDto> projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY); - assertThat(projectReloaded.get().name()).isEqualTo("New project name"); assertThat(projectReloaded.get().getCreatedAt()).isNotEqualTo(now); } @@ -599,11 +591,20 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { public void persist_components_that_were_previously_removed() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module").setEnabled(false); + ComponentDto removedModule = ComponentTesting.newModuleDto("BCDE", project) + .setKey(MODULE_KEY) + .setName("Module") + .setEnabled(false); dbClient.componentDao().insert(dbTester.getSession(), removedModule); - ComponentDto removedDirectory = ComponentTesting.newDirectory(removedModule, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir").setEnabled(false); - ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, "DEFG").setPath("src/main/java/dir/Foo.java").setName("Foo.java") - .setKey("MODULE_KEY:src/main/java/dir/Foo.java").setEnabled(false); + ComponentDto removedDirectory = ComponentTesting.newDirectory(removedModule, "src/main/java/dir") + .setUuid("CDEF") + .setKey("MODULE_KEY:src/main/java/dir") + .setEnabled(false); + ComponentDto removedFile = ComponentTesting.newFileDto(removedModule, "DEFG") + .setPath("src/main/java/dir/Foo.java") + .setName("Foo.java") + .setKey("MODULE_KEY:src/main/java/dir/Foo.java") + .setEnabled(false); dbClient.componentDao().insert(dbTester.getSession(), removedDirectory, removedFile); dbTester.getSession().commit(); @@ -611,7 +612,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .addChildren( builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir") @@ -628,9 +629,13 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(4); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get().getId()).isEqualTo(project.getId()); - assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get().getId()).isEqualTo(removedModule.getId()); + assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get().getId()).isEqualTo(removedModule.getId()); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir").get().getId()).isEqualTo(removedDirectory.getId()); assertThat(dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get().getId()).isEqualTo(removedFile.getId()); + assertExistButDisabled(removedModule.key(), removedDirectory.getKey(), removedFile.getKey()); + + // commit the functional transaction + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), project.uuid()); ComponentDto projectReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), PROJECT_KEY).get(); assertThat(projectReloaded.getId()).isEqualTo(project.getId()); @@ -641,7 +646,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(projectReloaded.getRootUuid()).isEqualTo(project.getRootUuid()); assertThat(projectReloaded.isEnabled()).isTrue(); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); + ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get(); assertThat(moduleReloaded.getId()).isEqualTo(removedModule.getId()); assertThat(moduleReloaded.uuid()).isEqualTo(removedModule.uuid()); assertThat(moduleReloaded.moduleUuid()).isEqualTo(removedModule.moduleUuid()); @@ -673,11 +678,18 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.isEnabled()).isTrue(); } + private void assertExistButDisabled(String... keys) { + for (String key : keys) { + ComponentDto dto = dbClient.componentDao().selectByKey(dbTester.getSession(), key).get(); + assertThat(dto.isEnabled()).isFalse(); + } + } + @Test - public void update_uuid_when_reactivating_removed_component() { + public void update_module_uuid_when_reactivating_removed_component() { ComponentDto project = ComponentTesting.newProjectDto("ABCD").setKey(PROJECT_KEY).setName("Project"); dbClient.componentDao().insert(dbTester.getSession(), project); - ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey("MODULE_KEY").setName("Module"); + ComponentDto module = ComponentTesting.newModuleDto("BCDE", project).setKey(MODULE_KEY).setName("Module"); ComponentDto removedModule = ComponentTesting.newModuleDto("EDCD", project).setKey("REMOVED_MODULE_KEY").setName("Removed Module").setEnabled(false); dbClient.componentDao().insert(dbTester.getSession(), module, removedModule); ComponentDto directory = ComponentTesting.newDirectory(module, "src/main/java/dir").setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir"); @@ -691,7 +703,7 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { builder(PROJECT, 1).setUuid("ABCD").setKey(PROJECT_KEY) .setName("Project") .addChildren( - builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey("MODULE_KEY") + builder(Component.Type.MODULE, 2).setUuid("BCDE").setKey(MODULE_KEY) .setName("Module") .addChildren( builder(DIRECTORY, 3).setUuid("CDEF").setKey("MODULE_KEY:src/main/java/dir") @@ -706,10 +718,14 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { underTest.execute(); + // commit the functional transaction + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), project.uuid()); + dbTester.commit(); + // Projects contains 4 components from the report + one removed module assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(5); - ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY").get(); + ComponentDto moduleReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), MODULE_KEY).get(); ComponentDto fileReloaded = dbClient.componentDao().selectByKey(dbTester.getSession(), "MODULE_KEY:src/main/java/dir/Foo.java").get(); assertThat(fileReloaded.getId()).isEqualTo(removedFile.getId()); @@ -717,7 +733,6 @@ public class ReportPersistComponentsStepTest extends BaseStepTest { assertThat(fileReloaded.moduleUuid()).isEqualTo(moduleReloaded.uuid()); assertThat(fileReloaded.moduleUuidPath()).isEqualTo(moduleReloaded.moduleUuidPath()); assertThat(fileReloaded.projectUuid()).isEqualTo(moduleReloaded.projectUuid()); - assertThat(fileReloaded.getRootUuid()).isEqualTo(moduleReloaded.uuid()); assertThat(fileReloaded.name()).isEqualTo(removedFile.name()); assertThat(fileReloaded.path()).isEqualTo(removedFile.path()); assertThat(fileReloaded.isEnabled()).isTrue(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java index 446a24397ac..0abaf7f1e5b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/computation/step/ViewsPersistComponentsStepTest.java @@ -34,10 +34,12 @@ import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; import org.sonar.server.computation.batch.TreeRootHolderRule; import org.sonar.server.computation.component.MutableDbIdsRepositoryRule; +import org.sonar.server.computation.component.MutableDisabledComponentsHolder; import org.sonar.server.computation.component.ProjectViewAttributes; import org.sonar.server.computation.component.ViewsComponent; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.db.component.ComponentTesting.newProjectDto; @@ -69,22 +71,19 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { @Rule public MutableDbIdsRepositoryRule dbIdsRepository = MutableDbIdsRepositoryRule.create(treeRootHolder); - System2 system2 = mock(System2.class); - - DbClient dbClient = dbTester.getDbClient(); - - Date now; - - ComponentDbTester componentDbTester = new ComponentDbTester(dbTester); - - PersistComponentsStep underTest; + private System2 system2 = mock(System2.class); + private DbClient dbClient = dbTester.getDbClient(); + private Date now; + private ComponentDbTester componentDbTester = new ComponentDbTester(dbTester); + private MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS); + private PersistComponentsStep underTest; @Before public void setup() throws Exception { now = DATE_FORMAT.parse("2015-06-02"); when(system2.now()).thenReturn(now.getTime()); - underTest = new PersistComponentsStep(dbClient, treeRootHolder, dbIdsRepository, system2); + underTest = new PersistComponentsStep(dbClient, treeRootHolder, dbIdsRepository, system2, disabledComponentsHolder); } @Override @@ -231,8 +230,11 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { underTest.execute(); - assertRowsCountInTableProjects(1); + // commit functional transaction -> copies B-fields to A-fields + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), viewDto.uuid()); + dbTester.commit(); + assertRowsCountInTableProjects(1); ComponentDto newViewDto = getComponentFromDb(VIEW_KEY); assertDtoIsView(newViewDto); } @@ -255,20 +257,23 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { underTest.execute(); - assertRowsCountInTableProjects(3); + // commit functional transaction -> copies B-fields to A-fields + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid()); + dbTester.commit(); + assertRowsCountInTableProjects(3); ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); assertDtoIsProjectView1(pv1Dto, view, view, project); } @Test - public void update_copy_resource_id_of_project_view() { + public void update_copy_component_uuid_of_project_view() { ComponentDto view = newViewDto(); - ComponentDto project1 = newProjectDto(); - ComponentDto project2 = newProjectDto(); + ComponentDto project1 = newProjectDto("P1"); + ComponentDto project2 = newProjectDto("P2"); persistComponents(view, project1, project2); - // Project view in DB is linked to project1 + // Project view in DB is associated to project1 ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view) .setKey(PROJECT_VIEW_1_KEY) .setCreatedAt(now); @@ -282,6 +287,10 @@ public class ViewsPersistComponentsStepTest extends BaseStepTest { underTest.execute(); + // commit functional transaction -> copies B-fields to A-fields + dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid()); + dbTester.commit(); + ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY); // Project view should now be linked to project2 assertDtoIsProjectView1(pv1Dto, view, view, project2); diff --git a/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_add_b_columns_to_projects.rb b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_add_b_columns_to_projects.rb new file mode 100644 index 00000000000..74a5b43c053 --- /dev/null +++ b/server/sonar-web/src/main/webapp/WEB-INF/db/migrate/1276_add_b_columns_to_projects.rb @@ -0,0 +1,29 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2014 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# +# SonarQube 6.0 +# +class AddBColumnsToProjects < ActiveRecord::Migration + + def self.up + execute_java_migration('org.sonar.db.version.v60.AddBColumnsToProjects') + end +end diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java index 6742bec2cc0..af24457c602 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentDao.java @@ -345,8 +345,16 @@ public class ComponentDao implements Dao { insert(session, Lists.asList(item, others)); } - public void update(DbSession session, ComponentDto item) { - mapper(session).update(item); + public void update(DbSession session, ComponentUpdateDto component) { + mapper(session).update(component); + } + + public void applyBChangesForRootComponentUuid(DbSession session, String projectUuid) { + mapper(session).applyBChangesForRootComponentUuid(projectUuid); + } + + public void resetBChangedForRootComponentUuid(DbSession session, String projectUuid) { + mapper(session).resetBChangedForRootComponentUuid(projectUuid); } public void delete(DbSession session, long componentId) { diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java index 9f69872a2fa..74d4b1c92b0 100644 --- a/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentMapper.java @@ -141,7 +141,12 @@ public interface ComponentMapper { void insertBatch(ComponentDto componentDto); - void update(ComponentDto componentDto); + void update(ComponentUpdateDto component); + + void applyBChangesForRootComponentUuid(@Param("projectUuid") String projectUuid); + + void resetBChangedForRootComponentUuid(@Param("projectUuid") String projectUuid); void delete(long componentId); + } diff --git a/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java new file mode 100644 index 00000000000..7f9af5ab723 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/component/ComponentUpdateDto.java @@ -0,0 +1,179 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.component; + +import javax.annotation.CheckForNull; +import javax.annotation.Nullable; + +public class ComponentUpdateDto { + private String uuid; + + /** + * if true, the component is being updated + * See https://jira.sonarsource.com/browse/SONAR-7700 + */ + private boolean bChanged; + private String bCopyComponentUuid; + private String bDescription; + private boolean bEnabled; + private String bLanguage; + private String bLongName; + private String bModuleUuid; + private String bModuleUuidPath; + private String bName; + private String bPath; + private String bQualifier; + + public ComponentUpdateDto setUuid(String uuid) { + this.uuid = uuid; + return this; + } + + public String getUuid() { + return uuid; + } + + public boolean isBChanged() { + return bChanged; + } + + @CheckForNull + public String getBCopyComponentUuid() { + return bCopyComponentUuid; + } + + @CheckForNull + public String getBDescription() { + return bDescription; + } + + public boolean isBEnabled() { + return bEnabled; + } + + @CheckForNull + public String getBLanguage() { + return bLanguage; + } + + @CheckForNull + public String getBLongName() { + return bLongName; + } + + @CheckForNull + public String getBModuleUuid() { + return bModuleUuid; + } + + @CheckForNull + public String getBModuleUuidPath() { + return bModuleUuidPath; + } + + @CheckForNull + public String getBName() { + return bName; + } + + @CheckForNull + public String getBPath() { + return bPath; + } + + @CheckForNull + public String getBQualifier() { + return bQualifier; + } + + public ComponentUpdateDto setBChanged(boolean b) { + this.bChanged = b; + return this; + } + + public ComponentUpdateDto setBCopyComponentUuid(@Nullable String s) { + this.bCopyComponentUuid = s; + return this; + } + + public ComponentUpdateDto setBEnabled(boolean b) { + this.bEnabled = b; + return this; + } + + public ComponentUpdateDto setBName(@Nullable String s) { + this.bName = s; + return this; + } + + public ComponentUpdateDto setBLongName(@Nullable String s) { + this.bLongName = s; + return this; + } + + public ComponentUpdateDto setBDescription(@Nullable String s) { + this.bDescription = s; + return this; + } + + public ComponentUpdateDto setBModuleUuid(@Nullable String s) { + this.bModuleUuid = s; + return this; + } + + public ComponentUpdateDto setBModuleUuidPath(@Nullable String s) { + this.bModuleUuidPath = s; + return this; + } + + public ComponentUpdateDto setBPath(@Nullable String s) { + this.bPath = s; + return this; + } + + public ComponentUpdateDto setBLanguage(@Nullable String s) { + this.bLanguage = s; + return this; + } + + public ComponentUpdateDto setBQualifier(@Nullable String s) { + this.bQualifier = s; + return this; + } + + /** + * Copy the A-fields to B-fields. The field bChanged is kept to false. + */ + public static ComponentUpdateDto copyFrom(ComponentDto from) { + return new ComponentUpdateDto() + .setUuid(from.uuid()) + .setBChanged(false) + .setBCopyComponentUuid(from.getCopyResourceUuid()) + .setBDescription(from.description()) + .setBEnabled(from.isEnabled()) + .setBLanguage(from.language()) + .setBLongName(from.longName()) + .setBModuleUuid(from.moduleUuid()) + .setBModuleUuidPath(from.moduleUuidPath()) + .setBName(from.name()) + .setBPath(from.path()) + .setBQualifier(from.qualifier()); + } +} diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeConfiguration.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeConfiguration.java index 4c9256e2f07..6e51564cadc 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeConfiguration.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeConfiguration.java @@ -20,6 +20,7 @@ package org.sonar.db.purge; import com.google.common.annotations.VisibleForTesting; +import java.util.Collection; import java.util.Date; import javax.annotation.CheckForNull; import org.apache.commons.lang.time.DateUtils; @@ -34,25 +35,23 @@ public class PurgeConfiguration { private final String[] scopesWithoutHistoricalData; private final int maxAgeInDaysOfClosedIssues; private final System2 system2; + private final Collection<String> disabledComponentUuids; - public PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues) { - this(rootProjectId, scopesWithoutHistoricalData, maxAgeInDaysOfClosedIssues, System2.INSTANCE); - } - - @VisibleForTesting - PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, System2 system2) { + public PurgeConfiguration(IdUuidPair rootProjectId, String[] scopesWithoutHistoricalData, int maxAgeInDaysOfClosedIssues, + System2 system2, Collection<String> disabledComponentUuids) { this.rootProjectIdUuid = rootProjectId; this.scopesWithoutHistoricalData = scopesWithoutHistoricalData; this.maxAgeInDaysOfClosedIssues = maxAgeInDaysOfClosedIssues; this.system2 = system2; + this.disabledComponentUuids = disabledComponentUuids; } - public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, IdUuidPair idUuidPair) { + public static PurgeConfiguration newDefaultPurgeConfiguration(Settings settings, IdUuidPair idUuidPair, Collection<String> disabledComponentUuids) { String[] scopes = new String[] {Scopes.FILE}; if (settings.getBoolean(PurgeConstants.PROPERTY_CLEAN_DIRECTORY)) { scopes = new String[] {Scopes.DIRECTORY, Scopes.FILE}; } - return new PurgeConfiguration(idUuidPair, scopes, settings.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES)); + return new PurgeConfiguration(idUuidPair, scopes, settings.getInt(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES), System2.INSTANCE, disabledComponentUuids); } public IdUuidPair rootProjectIdUuid() { @@ -63,6 +62,10 @@ public class PurgeConfiguration { return scopesWithoutHistoricalData; } + public Collection<String> getDisabledComponentUuids() { + return disabledComponentUuids; + } + @CheckForNull public Date maxLiveDateOfClosedIssues() { return maxLiveDateOfClosedIssues(new Date(system2.now())); diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java index 93ea962bb19..bd8da668000 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -20,12 +20,11 @@ package org.sonar.db.purge; import com.google.common.collect.Lists; -import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.List; -import org.apache.ibatis.session.SqlSession; import org.sonar.api.utils.System2; import org.sonar.api.utils.log.Logger; import org.sonar.api.utils.log.Loggers; @@ -63,9 +62,7 @@ public class PurgeDao implements Dao { deleteAbortedAnalyses(rootUuid, commands); deleteDataOfComponentsWithoutHistoricalData(session, rootUuid, conf.scopesWithoutHistoricalData(), commands); purgeAnalyses(commands, rootUuid); - - // FIXME to be re-enabled with - //disableOrphanResources(rootUuid, session, mapper, listener); + purgeDisabledComponents(session, conf.getDisabledComponentUuids(), listener); deleteOldClosedIssues(conf, mapper, listener); } @@ -135,19 +132,17 @@ public class PurgeDao implements Dao { .setSortFields(UUID_FIELD_SORT); } - private void disableOrphanResources(String rootUuid, SqlSession session, PurgeMapper mapper, PurgeListener listener) { - List<String> componentUuids = new ArrayList<>(); - mapper.selectComponentUuidsToDisable( - rootUuid, - resultContext -> { - String componentUuid = (String) resultContext.getResultObject(); - if (componentUuid != null) { - componentUuids.add(componentUuid); - } + private void purgeDisabledComponents(DbSession session, Collection<String> uuids, PurgeListener listener) { + PurgeMapper mapper = mapper(session); + executeLargeInputs(uuids, + input -> { + mapper.deleteResourceIndex(input); + mapper.deleteFileSourcesByUuid(input); + mapper.resolveComponentIssuesNotAlreadyResolved(input, system2.now()); + return emptyList(); }); - disableComponents(componentUuids, mapper); - for (String componentUuid : componentUuids) { + for (String componentUuid : uuids) { listener.onComponentDisabling(componentUuid); } @@ -178,18 +173,6 @@ public class PurgeDao implements Dao { commands.deleteCeActivity(rootUuid); } - private void disableComponents(List<String> uuids, PurgeMapper mapper) { - executeLargeInputs(uuids, - input -> { - mapper.deleteResourceIndex(input); - mapper.setAnalysisIsLastToFalse(input); - mapper.deleteFileSourcesByUuid(input); - mapper.disableComponent(input); - mapper.resolveComponentIssuesNotAlreadyResolved(input, system2.now()); - return emptyList(); - }); - } - public void deleteAnalyses(DbSession session, PurgeProfiler profiler, List<IdUuidPair> analysisIdUuids) { new PurgeCommands(session, profiler).deleteAnalyses(analysisIdUuids); } diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java index 0b6aaa5011b..91cb547e29f 100644 --- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java +++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java @@ -22,7 +22,6 @@ package org.sonar.db.purge; import java.util.List; import javax.annotation.Nullable; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.session.ResultHandler; public interface PurgeMapper { @@ -33,8 +32,6 @@ public interface PurgeMapper { */ List<IdUuidPair> selectComponentsByProjectUuid(String projectUuid); - void selectComponentUuidsToDisable(@Param("rootUuid") String rootUuid, ResultHandler resultHandler); - void deleteAnalyses(@Param("analysisUuids") List<String> analysisUuids); void deleteAnalysisDuplications(@Param("analysisUuids") List<String> analysisUuids); @@ -53,14 +50,10 @@ public interface PurgeMapper { void updatePurgeStatusToOne(@Param("analysisUuids") List<String> analysisUuid); - void disableComponent(@Param("componentUuids") List<String> componentUuids); - void resolveComponentIssuesNotAlreadyResolved(@Param("componentUuids") List<String> componentUuids, @Param("dateAsLong") Long dateAsLong); void deleteResourceIndex(@Param("componentUuids") List<String> componentUuids); - void setAnalysisIsLastToFalse(@Param("componentUuids") List<String> componentUuids); - void deleteComponentLinks(@Param("componentUuids") List<String> componentUuids); void deleteComponentProperties(@Param("componentIds") List<Long> componentIds); diff --git a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java index 616324a2ed8..796c16e5954 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java +++ b/sonar-db/src/main/java/org/sonar/db/version/DatabaseVersion.java @@ -30,7 +30,7 @@ import org.sonar.db.MyBatis; public class DatabaseVersion { - public static final int LAST_VERSION = 1_275; + public static final int LAST_VERSION = 1_276; /** * The minimum supported version which can be upgraded. Lower diff --git a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java index 41900151987..72d947d5e85 100644 --- a/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java +++ b/sonar-db/src/main/java/org/sonar/db/version/MigrationStepModule.java @@ -87,6 +87,7 @@ import org.sonar.db.version.v60.AddAnalysisUuidColumnToCeActivity; import org.sonar.db.version.v60.AddAnalysisUuidColumnToDuplicationsIndex; import org.sonar.db.version.v60.AddAnalysisUuidColumnToEvents; import org.sonar.db.version.v60.AddAnalysisUuidColumnToMeasures; +import org.sonar.db.version.v60.AddBColumnsToProjects; import org.sonar.db.version.v60.AddComponentUuidColumnToDuplicationsIndex; import org.sonar.db.version.v60.AddComponentUuidColumnToMeasures; import org.sonar.db.version.v60.AddComponentUuidColumnsToSnapshots; @@ -310,6 +311,8 @@ public class MigrationStepModule extends Module { DropTreesOfSnapshots.class, DropTreeColumnsFromSnapshots.class, - DropSnapshotIdColumnFromMeasures.class); + DropSnapshotIdColumnFromMeasures.class, + AddBColumnsToProjects.class + ); } } diff --git a/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java b/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java new file mode 100644 index 00000000000..72af465d5b2 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/version/v60/AddBColumnsToProjects.java @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v60; + +import java.sql.SQLException; +import org.sonar.db.Database; +import org.sonar.db.version.AddColumnsBuilder; +import org.sonar.db.version.DdlChange; + +import static org.sonar.db.version.BooleanColumnDef.newBooleanColumnDefBuilder; +import static org.sonar.db.version.VarcharColumnDef.newVarcharColumnDefBuilder; + +public class AddBColumnsToProjects extends DdlChange { + + private static final String TABLE_PROJECTS = "projects"; + + public AddBColumnsToProjects(Database db) { + super(db); + } + + @Override + public void execute(Context context) throws SQLException { + context.execute(new AddColumnsBuilder(getDatabase().getDialect(), TABLE_PROJECTS) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_changed").build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_copy_component_uuid").setLimit(50).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_description").setLimit(2000).setIsNullable(true).build()) + .addColumn(newBooleanColumnDefBuilder().setColumnName("b_enabled").build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_language").setLimit(20).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_long_name").setLimit(2000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid").setLimit(50).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_module_uuid_path").setLimit(4000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_name").setLimit(2000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_path").setLimit(2000).setIsNullable(true).build()) + .addColumn(newVarcharColumnDefBuilder().setColumnName("b_qualifier").setLimit(3).setIsNullable(true).build()) + .build()); + } + +} diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml index 31b71fecbab..919dffbf62b 100644 --- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml @@ -535,7 +535,19 @@ developer_uuid, enabled, created_at, - authorization_updated_at) + authorization_updated_at, + b_changed, + b_copy_component_uuid, + b_description, + b_enabled, + b_language, + b_long_name, + b_module_uuid, + b_module_uuid_path, + b_name, + b_path, + b_qualifier + ) VALUES ( #{kee,jdbcType=VARCHAR}, #{deprecatedKey,jdbcType=VARCHAR}, @@ -556,7 +568,19 @@ #{developerUuid,jdbcType=VARCHAR}, #{enabled,jdbcType=BOOLEAN}, #{createdAt,jdbcType=TIMESTAMP}, - #{authorizationUpdatedAt,jdbcType=BIGINT}) + #{authorizationUpdatedAt,jdbcType=BIGINT}, + ${_false}, + null, + null, + ${_false}, + null, + null, + null, + null, + null, + null, + null + ) </sql> <insert id="insert" parameterType="Component" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> @@ -567,26 +591,57 @@ <include refid="insertSql"/> </insert> - <update id="update" parameterType="Component" useGeneratedKeys="false"> - UPDATE projects SET - kee=#{kee,jdbcType=VARCHAR}, - deprecated_kee=#{deprecatedKey,jdbcType=VARCHAR}, - project_uuid=#{projectUuid,jdbcType=VARCHAR}, - module_uuid=#{moduleUuid,jdbcType=VARCHAR}, - module_uuid_path=#{moduleUuidPath,jdbcType=VARCHAR}, - name=#{name,jdbcType=VARCHAR}, - long_name=#{longName,jdbcType=VARCHAR}, - qualifier=#{qualifier,jdbcType=VARCHAR}, - scope=#{scope,jdbcType=VARCHAR}, - language=#{language,jdbcType=VARCHAR}, - description=#{description,jdbcType=VARCHAR}, - root_uuid=#{rootUuid,jdbcType=VARCHAR}, - path=#{path,jdbcType=VARCHAR}, - copy_component_uuid=#{copyComponentUuid,jdbcType=VARCHAR}, - developer_uuid=#{developerUuid,jdbcType=VARCHAR}, - enabled=#{enabled,jdbcType=BOOLEAN}, - authorization_updated_at=#{authorizationUpdatedAt,jdbcType=BIGINT} - WHERE uuid=#{uuid} + <update id="update" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false"> + update projects set + b_changed = #{bChanged,jdbcType=BOOLEAN}, + b_copy_component_uuid = #{bCopyComponentUuid,jdbcType=VARCHAR}, + b_description = #{bDescription,jdbcType=VARCHAR}, + b_enabled = #{bEnabled,jdbcType=BOOLEAN}, + b_language = #{bLanguage,jdbcType=VARCHAR}, + b_long_name = #{bLongName,jdbcType=VARCHAR}, + b_module_uuid = #{bModuleUuid,jdbcType=VARCHAR}, + b_module_uuid_path = #{bModuleUuidPath,jdbcType=VARCHAR}, + b_name = #{bName,jdbcType=VARCHAR}, + b_path = #{bPath,jdbcType=VARCHAR}, + b_qualifier = #{bQualifier,jdbcType=VARCHAR} + where + uuid = #{uuid} + </update> + + <update id="applyBChangesForRootComponentUuid" parameterType="string" useGeneratedKeys="false"> + update projects set + copy_component_uuid = b_copy_component_uuid, + description = b_description, + enabled = b_enabled, + language = b_language, + long_name = b_long_name, + module_uuid = b_module_uuid, + module_uuid_path = b_module_uuid_path, + name = b_name, + path = b_path, + qualifier = b_qualifier, + b_changed = ${_false}, + b_copy_component_uuid = null, + b_description = null, + b_enabled = ${_false}, + b_language = null, + b_long_name = null, + b_module_uuid = null, + b_module_uuid_path = null, + b_name = null, + b_path = null, + b_qualifier = null + where + project_uuid = #{projectUuid} and + b_changed = ${_true} + </update> + + <update id="resetBChangedForRootComponentUuid" parameterType="map" > + update projects + set b_changed = ${_false} + where + project_uuid = #{projectUuid} and + b_changed = ${_true} </update> <delete id="delete" parameterType="long"> diff --git a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml index 0302b9ecde4..fa9fd4b78c5 100644 --- a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml +++ b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml @@ -47,17 +47,6 @@ and not exists(select e.id from events e where e.analysis_uuid=s.uuid) </select> - <select id="selectComponentUuidsToDisable" resultType="String" parameterType="String"> - select - p.uuid - from - projects p - where - p.project_uuid=#{rootUuid} - and p.enabled=${_true} - and not exists(select s.component_uuid from snapshots s where s.islast=${_true} and s.component_uuid=p.uuid) - </select> - <select id="selectMetricIdsWithoutHistoricalData" resultType="long"> select id from metrics where delete_historical_data=${_true} </select> @@ -154,18 +143,6 @@ </foreach> </update> - <update id="disableComponent" parameterType="string"> - update - projects - set - enabled=${_false} - where - uuid in - <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> - #{componentUuid} - </foreach> - </update> - <update id="resolveComponentIssuesNotAlreadyResolved" parameterType="map"> update issues @@ -262,18 +239,6 @@ </foreach> </delete> - <update id="setAnalysisIsLastToFalse" parameterType="String"> - update - snapshots - set - islast=${_false} - where - component_uuid in - <foreach collection="componentUuids" open="(" close=")" item="componentUuid" separator=","> - #{componentUuid} - </foreach> - </update> - <delete id="deleteComponentIssueChanges" parameterType="map"> delete from issue_changes ic where exists (select * from issues i where i.kee=ic.issue_key and i.component_uuid in diff --git a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql index 05dcd3a02ad..5e0c15f1de8 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql +++ b/sonar-db/src/main/resources/org/sonar/db/version/rows-h2.sql @@ -482,6 +482,7 @@ INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1272'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1273'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1274'); INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1275'); +INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('1276'); INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, EXTERNAL_IDENTITY, EXTERNAL_IDENTITY_PROVIDER, USER_LOCAL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT) VALUES (1, 'admin', 'Administrator', '', 'admin', 'sonarqube', true, 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482'); ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2; diff --git a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl index 1983c30d7a3..64c9fc7b99f 100644 --- a/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl +++ b/sonar-db/src/main/resources/org/sonar/db/version/schema-h2.ddl @@ -228,7 +228,18 @@ CREATE TABLE "PROJECTS" ( "LONG_NAME" VARCHAR(2000), "DEVELOPER_UUID" VARCHAR(50), "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT + "AUTHORIZATION_UPDATED_AT" BIGINT, + "B_CHANGED" BOOLEAN, + "B_COPY_COMPONENT_UUID" VARCHAR(50), + "B_DESCRIPTION" VARCHAR(2000), + "B_ENABLED" BOOLEAN, + "B_LANGUAGE" VARCHAR(20), + "B_LONG_NAME" VARCHAR(2000), + "B_MODULE_UUID" VARCHAR(50), + "B_MODULE_UUID_PATH" VARCHAR(4000), + "B_NAME" VARCHAR(2000), + "B_PATH" VARCHAR(2000), + "B_QUALIFIER" VARCHAR(3) ); CREATE TABLE "MANUAL_MEASURES" ( diff --git a/sonar-db/src/test/java/org/sonar/db/DbTester.java b/sonar-db/src/test/java/org/sonar/db/DbTester.java index e96507352cf..170a863862f 100644 --- a/sonar-db/src/test/java/org/sonar/db/DbTester.java +++ b/sonar-db/src/test/java/org/sonar/db/DbTester.java @@ -378,7 +378,7 @@ public class DbTester extends ExternalResource { assertThat(res.getMetaData().isNullable(columnIndex)).isEqualTo(isNullable ? columnNullable : columnNoNulls); } } catch (Exception e) { - throw new IllegalStateException("Fail to check column"); + throw new IllegalStateException("Fail to check column", e); } } diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java index 71d3070e8e2..9623de54754 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -657,35 +657,36 @@ public class ComponentDaoTest { db.assertDbUnit(getClass(), "insert_disabled_component-result.xml", "projects"); } - @Test - public void update() { - db.prepareDbUnit(getClass(), "update.xml"); - - ComponentDto componentDto = new ComponentDto() - .setUuid("GHIJ") - .setProjectUuid("DCBA") - .setModuleUuid("HGFE") - .setModuleUuidPath(".DCBA.HGFE.") - .setKey("org.struts:struts-core:src/org/struts/RequestContext2.java") - .setDeprecatedKey("org.struts:struts-core:src/org/struts/RequestContext2.java") - .setName("RequestContext2.java") - .setLongName("org.struts.RequestContext2") - .setQualifier("LIF") - .setScope("LIF") - .setLanguage("java2") - .setDescription("description2") - .setPath("src/org/struts/RequestContext2.java") - .setRootUuid("uuid_4") - .setCopyComponentUuid("uuid_6") - .setDeveloperUuid("uuid_9") - .setEnabled(false) - .setAuthorizationUpdatedAt(12345678910L); - - underTest.update(dbSession, componentDto); - dbSession.commit(); - - db.assertDbUnit(getClass(), "update-result.xml", "projects"); - } + // FIXME +// @Test +// public void update() { +// db.prepareDbUnit(getClass(), "update.xml"); +// +// ComponentDto componentDto = new ComponentDto() +// .setUuid("GHIJ") +// .setProjectUuid("DCBA") +// .setModuleUuid("HGFE") +// .setModuleUuidPath(".DCBA.HGFE.") +// .setKey("org.struts:struts-core:src/org/struts/RequestContext2.java") +// .setDeprecatedKey("org.struts:struts-core:src/org/struts/RequestContext2.java") +// .setName("RequestContext2.java") +// .setLongName("org.struts.RequestContext2") +// .setQualifier("LIF") +// .setScope("LIF") +// .setLanguage("java2") +// .setDescription("description2") +// .setPath("src/org/struts/RequestContext2.java") +// .setRootUuid("uuid_4") +// .setCopyComponentUuid("uuid_6") +// .setDeveloperUuid("uuid_9") +// .setEnabled(false) +// .setAuthorizationUpdatedAt(12345678910L); +// +// underTest.update(dbSession, componentDto); +// dbSession.commit(); +// +// db.assertDbUnit(getClass(), "update-result.xml", "projects"); +// } @Test public void delete() throws Exception { diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java index 6adf642245d..8acf62f29c7 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest.java @@ -30,7 +30,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.db.component.ComponentTesting.newProjectDto; /** - * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique, we need to create a schema where there's no unique index on PROJECTS.KEE + * On H2, the index on PROJECTS.KEE is unique. In order to simulate the MySQL behaviour where the index is not unique, + * we need to create a schema where there's no unique index on PROJECTS.KEE */ public class ComponentDaoWithDuplicatedKeysTest { diff --git a/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java b/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java index d8e9de2e54b..9750500f3c9 100644 --- a/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/component/ComponentDtoTest.java @@ -43,7 +43,8 @@ public class ComponentDtoTest { .setCopyComponentUuid("uuid_5") .setRootUuid("uuid_3") .setDeveloperUuid("uuid_6") - .setAuthorizationUpdatedAt(123456789L); + .setAuthorizationUpdatedAt(123456789L) + ; assertThat(componentDto.getId()).isEqualTo(1L); assertThat(componentDto.key()).isEqualTo("org.struts:struts-core:src/org/struts/RequestContext.java"); diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java index 9e3b3e52339..e7f4ea58ed1 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeConfigurationTest.java @@ -19,11 +19,13 @@ */ package org.sonar.db.purge; +import java.util.Collections; import java.util.Date; import org.junit.Test; import org.sonar.api.config.Settings; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.DateUtils; +import org.sonar.api.utils.System2; import org.sonar.core.config.PurgeConstants; import static org.assertj.core.api.Assertions.assertThat; @@ -31,10 +33,10 @@ import static org.assertj.core.api.Assertions.assertThat; public class PurgeConfigurationTest { @Test public void should_delete_all_closed_issues() { - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 0, System2.INSTANCE, Collections.emptyList()); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); - conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], -1); + conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], -1, System2.INSTANCE, Collections.emptyList()); assertThat(conf.maxLiveDateOfClosedIssues()).isNull(); } @@ -42,7 +44,7 @@ public class PurgeConfigurationTest { public void should_delete_only_old_closed_issues() { Date now = DateUtils.parseDate("2013-05-18"); - PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[0], 30, System2.INSTANCE, Collections.emptyList()); Date toDate = conf.maxLiveDateOfClosedIssues(now); assertThat(toDate.getYear()).isEqualTo(113);// =2013 @@ -57,7 +59,7 @@ public class PurgeConfigurationTest { settings.setProperty(PurgeConstants.DAYS_BEFORE_DELETING_CLOSED_ISSUES, 5); Date now = new Date(); - PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid")); + PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList()); assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.FILE) .doesNotContain(Scopes.DIRECTORY); @@ -69,7 +71,7 @@ public class PurgeConfigurationTest { Settings settings = new Settings(); settings.setProperty(PurgeConstants.PROPERTY_CLEAN_DIRECTORY, true); - PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid")); + PurgeConfiguration underTest = PurgeConfiguration.newDefaultPurgeConfiguration(settings, new IdUuidPair(42L, "any-uuid"), Collections.emptyList()); assertThat(underTest.scopesWithoutHistoricalData()).contains(Scopes.DIRECTORY, Scopes.FILE); } diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index 276bfc0afb8..5870c075dca 100644 --- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -21,6 +21,7 @@ package org.sonar.db.purge; import com.google.common.collect.ImmutableList; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.junit.Ignore; import org.junit.Rule; @@ -87,9 +88,12 @@ public class PurgeDaoTest { @Test public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() { dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml"); - underTest.purge(dbSession, new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "ABCD"), new String[] {Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, - new PurgeProfiler()); + PurgeConfiguration conf = new PurgeConfiguration( + new IdUuidPair(THE_PROJECT_ID, "ABCD"), new String[]{Scopes.DIRECTORY, Scopes.FILE}, 30, System2.INSTANCE, Collections.emptyList()); + + underTest.purge(dbSession, conf, PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); + dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots"); } @@ -207,7 +211,8 @@ public class PurgeDaoTest { @Test public void should_delete_all_closed_issues() { dbTester.prepareDbUnit(getClass(), "should_delete_all_closed_issues.xml"); - underTest.purge(dbSession, new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "1"), new String[0], 0), PurgeListener.EMPTY, new PurgeProfiler()); + PurgeConfiguration conf = new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, "1"), new String[0], 0, System2.INSTANCE, Collections.emptyList()); + underTest.purge(dbSession, conf, PurgeListener.EMPTY, new PurgeProfiler()); dbSession.commit(); dbTester.assertDbUnit(getClass(), "should_delete_all_closed_issues-result.xml", "issues", "issue_changes"); } @@ -237,10 +242,10 @@ public class PurgeDaoTest { } private static PurgeConfiguration newConfigurationWith30Days() { - return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30); + return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, System2.INSTANCE, Collections.emptyList()); } private static PurgeConfiguration newConfigurationWith30Days(System2 system2) { - return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, system2); + return new PurgeConfiguration(new IdUuidPair(THE_PROJECT_ID, THE_PROJECT_UUID), new String[0], 30, system2, Collections.emptyList()); } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java index 1983e73c711..cd190a68543 100644 --- a/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java +++ b/sonar-db/src/test/java/org/sonar/db/version/MigrationStepModuleTest.java @@ -29,6 +29,6 @@ public class MigrationStepModuleTest { public void verify_count_of_added_MigrationStep_types() { ComponentContainer container = new ComponentContainer(); new MigrationStepModule().configure(container); - assertThat(container.size()).isEqualTo(128); + assertThat(container.size()).isEqualTo(129); } } diff --git a/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java b/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java new file mode 100644 index 00000000000..facb21de02d --- /dev/null +++ b/sonar-db/src/test/java/org/sonar/db/version/v60/AddBColumnsToProjectsTest.java @@ -0,0 +1,91 @@ +/* + * SonarQube + * Copyright (C) 2009-2016 SonarSource SA + * mailto:contact AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.db.version.v60; + +import java.sql.SQLException; +import java.sql.Types; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.sonar.api.utils.System2; +import org.sonar.db.DbTester; + +import static java.lang.String.valueOf; + + +public class AddBColumnsToProjectsTest { + + private static final String TABLE = "projects"; + + @Rule + public DbTester db = DbTester.createForSchema(System2.INSTANCE, AddBColumnsToProjectsTest.class, "old_projects.sql"); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private AddBColumnsToProjects underTest = new AddBColumnsToProjects(db.database()); + + @Test + public void migration_adds_column_to_empty_table() throws SQLException { + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_adds_columns_to_populated_table() throws SQLException { + for (int i = 0; i < 9; i++) { + db.executeInsert( + TABLE, + "uuid", valueOf(i), + "kee", valueOf(i + 10), + "root_uuid", valueOf(i + 20), + "uuid_path", valueOf(i + 30) + ); + } + db.commit(); + + underTest.execute(); + + verifyAddedColumns(); + } + + @Test + public void migration_is_not_reentrant() throws SQLException { + underTest.execute(); + + expectedException.expect(IllegalStateException.class); + expectedException.expectMessage("Fail to execute "); + underTest.execute(); + } + + private void verifyAddedColumns() { + db.assertColumnDefinition(TABLE, "b_changed", Types.BOOLEAN, null, true); + db.assertColumnDefinition(TABLE, "b_copy_component_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(TABLE, "b_description", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_enabled", Types.BOOLEAN, null, true); + db.assertColumnDefinition(TABLE, "b_language", Types.VARCHAR, 20, true); + db.assertColumnDefinition(TABLE, "b_module_uuid", Types.VARCHAR, 50, true); + db.assertColumnDefinition(TABLE, "b_module_uuid_path", Types.VARCHAR, 4000, true); + db.assertColumnDefinition(TABLE, "b_name", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_long_name", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_path", Types.VARCHAR, 2000, true); + db.assertColumnDefinition(TABLE, "b_qualifier", Types.VARCHAR, 3, true); + } +} diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml index d9307035631..1ea48523c8c 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert-result.xml @@ -21,6 +21,17 @@ developer_uuid="uuid_7" authorization_updated_at="123456789" created_at="2014-06-18" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml index d5b8047d511..b374ecfc7dd 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoTest/insert_disabled_component-result.xml @@ -21,6 +21,17 @@ deprecated_kee="[null]" authorization_updated_at="123456789" created_at="2014-06-18" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql index 8b56b010029..dc4eeec7702 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql +++ b/sonar-db/src/test/resources/org/sonar/db/component/ComponentDaoWithDuplicatedKeysTest/schema.sql @@ -19,7 +19,18 @@ CREATE TABLE "PROJECTS" ( "LONG_NAME" VARCHAR(2000), "DEVELOPER_UUID" VARCHAR(50), "CREATED_AT" TIMESTAMP, - "AUTHORIZATION_UPDATED_AT" BIGINT + "AUTHORIZATION_UPDATED_AT" BIGINT, + "B_CHANGED" BOOLEAN, + "B_COPY_COMPONENT_UUID" VARCHAR(50), + "B_DESCRIPTION" VARCHAR(2000), + "B_ENABLED" BOOLEAN, + "B_LANGUAGE" VARCHAR(20), + "B_LONG_NAME" VARCHAR(2000), + "B_MODULE_UUID" VARCHAR(50), + "B_MODULE_UUID_PATH" VARCHAR(4000), + "B_NAME" VARCHAR(2000), + "B_PATH" VARCHAR(2000), + "B_QUALIFIER" VARCHAR(10) ); CREATE INDEX "PROJECTS_KEE" ON "PROJECTS" ("KEE"); diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml index 5766deb0c16..b012cb172a0 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date-result.xml @@ -20,6 +20,18 @@ created_at="[null]" path="/old/foo/bar" deprecated_kee="old deprecated key" - authorization_updated_at="987654321"/> + authorization_updated_at="987654321" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml index 4de09c833ce..2b48581c2fc 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceDaoTest/update_authorization_date.xml @@ -20,6 +20,18 @@ created_at="[null]" path="/old/foo/bar" deprecated_kee="old deprecated key" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml index 9ee0181a4d9..2c9b3eecd3d 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shared.xml @@ -19,7 +19,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> ² <!-- **************** First sub project **************** --> @@ -41,7 +53,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -62,7 +86,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -83,7 +119,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Second sub project **************** --> @@ -105,7 +153,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -126,7 +186,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -147,7 +219,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Another independent project **************** --> @@ -169,6 +253,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml index b990ddeae8f..7548d17dd93 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKey-result.xml @@ -21,7 +21,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** First sub project **************** --> @@ -45,7 +57,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -68,7 +92,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -91,7 +127,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Second sub project **************** --> @@ -115,7 +163,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-ui" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -138,7 +198,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-ui:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -161,7 +233,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-ui:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Another independent project **************** --> @@ -185,6 +269,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml index 59f46c562df..ced8067f823 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldBulkUpdateKeyOnOnlyOneSubmodule-result.xml @@ -21,7 +21,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** First sub project **************** --> @@ -45,7 +57,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -68,7 +92,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -91,7 +127,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Second sub project **************** --> @@ -115,7 +163,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-web" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -138,7 +198,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-web:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -161,7 +233,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-web:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Another independent project **************** --> @@ -185,6 +269,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml index 5c768d3e957..e789eff392b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules-result.xml @@ -21,7 +21,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** First sub project **************** --> @@ -43,7 +55,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -64,7 +88,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -85,7 +121,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.apache.struts:struts-core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** --> @@ -107,7 +155,19 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -128,7 +188,19 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -149,6 +221,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml index c9435636334..efcbeeb653b 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldNotUpdateAllSubmodules.xml @@ -19,7 +19,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** First sub project **************** --> @@ -41,7 +53,18 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]"/> <!-- directory --> <projects long_name="org.struts" @@ -62,7 +85,18 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -83,7 +117,18 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]"/> <!-- **************** Second sub project THAT HAS A DIFFERENT GROUP ID => MUST NOT BE UPDATED **************** --> @@ -105,7 +150,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]"/> <!-- directory --> <projects long_name="org.struts" @@ -126,7 +182,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]"/> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -147,6 +214,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-ui:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml index ea851c10683..b077221c664 100644 --- a/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/component/ResourceKeyUpdaterDaoTest/shouldUpdateKey-result.xml @@ -21,7 +21,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** First sub project **************** --> @@ -45,7 +57,19 @@ created_at="[null]" path="[null]" deprecated_kee="struts:core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -66,7 +90,19 @@ created_at="[null]" path="[null]" deprecated_kee="struts:core:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -87,7 +123,19 @@ created_at="[null]" path="[null]" deprecated_kee="struts:core:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Second sub project **************** --> @@ -109,7 +157,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- directory --> <projects long_name="org.struts" @@ -130,7 +190,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui:org.struts" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file --> <projects long_name="org.struts.RequestContext" @@ -151,7 +223,19 @@ created_at="[null]" path="[null]" deprecated_kee="org.struts:struts-ui:org.struts.RequestContext" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- **************** Another independent project **************** --> @@ -173,6 +257,18 @@ created_at="[null]" path="[null]" deprecated_kee="foo:struts-core" - authorization_updated_at="[null]"/> + authorization_updated_at="[null]" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> </dataset> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml index 439ccefceb2..f1999b978dd 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml @@ -27,7 +27,19 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="1" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- the directory --> <projects uuid="EFGH" @@ -50,7 +62,19 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="2" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- the file --> <projects uuid="GHIJ" @@ -73,7 +97,19 @@ What has been changed : purge_status=1 on snapshot 4 (PRJ) and snapshots 5 and 6 authorization_updated_at="[null]" id="3" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- do not purge last snapshots --> <snapshots id="1" diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml index e4ca8cb9727..7cd546a9111 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml @@ -21,7 +21,18 @@ authorization_updated_at="[null]" id="1" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- the directory --> <projects uuid="EFGH" @@ -44,7 +55,18 @@ authorization_updated_at="[null]" id="2" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- the file --> <projects uuid="GHIJ" @@ -67,7 +89,18 @@ authorization_updated_at="[null]" id="3" enabled="[true]" - root_uuid="ABCD"/> + root_uuid="ABCD" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- do not purge last snapshots --> <snapshots id="1" diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml index c1b4656d2e3..1f94301bbdf 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldDeleteProject.xml @@ -18,7 +18,18 @@ authorization_updated_at="[null]" id="1" enabled="[true]" - root_uuid="A"/> + root_uuid="A" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <snapshots id="1" uuid="u1" @@ -119,7 +130,18 @@ authorization_updated_at="[null]" id="2" enabled="[true]" - root_uuid="A"/> + root_uuid="A" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <projects uuid="C" uuid_path="NOT_USED" @@ -138,7 +160,18 @@ authorization_updated_at="[null]" id="3" enabled="[false]" - root_uuid="A"/> + root_uuid="A" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- file of module 2--> <projects uuid="D" @@ -158,7 +191,18 @@ authorization_updated_at="[null]" id="4" enabled="[false]" - root_uuid="C"/> + root_uuid="C" + b_changed="[false]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <file_sources id="1" project_uuid="A" diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml index 2df2d72f998..2b94a67e6b2 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject-result.xml @@ -21,7 +21,19 @@ path="[null]" deprecated_kee="[null]" authorization_updated_at="[null]" - id="1"/> + id="1" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- snapshot already purged --> diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml index 9df37692d2b..c3b836b7593 100644 --- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml +++ b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/shouldPurgeProject.xml @@ -21,7 +21,19 @@ path="[null]" deprecated_kee="[null]" authorization_updated_at="[null]" - id="1"/> + id="1" + b_changed="[false]" + b_copy_component_uuid="[null]" + b_description="[null]" + b_enabled="[false]" + b_language="[null]" + b_long_name="[null]" + b_module_uuid="[null]" + b_module_uuid_path="[null]" + b_name="[null]" + b_path="[null]" + b_qualifier="[null]" + /> <!-- snapshot already purged --> diff --git a/sonar-db/src/test/resources/org/sonar/db/version/v60/AddBColumnsToProjectsTest/old_projects.sql b/sonar-db/src/test/resources/org/sonar/db/version/v60/AddBColumnsToProjectsTest/old_projects.sql new file mode 100644 index 00000000000..1c469e80b26 --- /dev/null +++ b/sonar-db/src/test/resources/org/sonar/db/version/v60/AddBColumnsToProjectsTest/old_projects.sql @@ -0,0 +1,23 @@ +CREATE TABLE "PROJECTS" ( + "ID" INTEGER NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1), + "KEE" VARCHAR(400), + "UUID" VARCHAR(50) NOT NULL, + "UUID_PATH" VARCHAR(4000) NOT NULL, + "ROOT_UUID" VARCHAR(50) NOT NULL, + "PROJECT_UUID" VARCHAR(50), + "MODULE_UUID" VARCHAR(50), + "MODULE_UUID_PATH" VARCHAR(4000), + "NAME" VARCHAR(2000), + "DESCRIPTION" VARCHAR(2000), + "ENABLED" BOOLEAN NOT NULL DEFAULT TRUE, + "SCOPE" VARCHAR(3), + "QUALIFIER" VARCHAR(10), + "DEPRECATED_KEE" VARCHAR(400), + "PATH" VARCHAR(2000), + "LANGUAGE" VARCHAR(20), + "COPY_COMPONENT_UUID" VARCHAR(50), + "LONG_NAME" VARCHAR(2000), + "DEVELOPER_UUID" VARCHAR(50), + "CREATED_AT" TIMESTAMP, + "AUTHORIZATION_UPDATED_AT" BIGINT +); |