From 6e5404e31af30a5800e041c74c97dde2c93c6f6e Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Fri, 20 Jun 2014 15:16:25 +0200 Subject: [PATCH] SONAR-5329 - Fix migration bug --- .../sonar/server/db/migrations/v44/ChangeLogMigration.java | 6 +++--- .../server/db/migrations/v44/ChangeLogMigrationTest.java | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java index 0c995b80823..9b105522700 100644 --- a/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java +++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/v44/ChangeLogMigration.java @@ -114,9 +114,9 @@ public class ChangeLogMigration implements DatabaseMigration { private void processRuleChange(ActiveRuleChange ruleChange, ChangeLog change) { ruleChange.setSeverity(SeverityUtil.getSeverityFromOrdinal(change.getSeverity())); - String param_value = change.getParamKey(); - String param_name = change.getParamValue(); - if (StringUtils.isNotEmpty(param_name) && !param_name.equals("null")) { + String param_name = change.getParamKey(); + String param_value = change.getParamValue(); + if (StringUtils.isNotEmpty(param_name)) { ruleChange.setParameter(param_name, param_value); } } diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationTest.java index 405ef8bcde1..26ac5f20952 100644 --- a/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationTest.java +++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/v44/ChangeLogMigrationTest.java @@ -28,11 +28,14 @@ import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; +import org.sonar.core.activity.db.ActivityDto; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.TestDatabase; import org.sonar.server.activity.db.ActivityDao; import org.sonar.server.db.DbClient; +import java.util.List; + import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.when; @@ -68,8 +71,10 @@ public class ChangeLogMigrationTest { public void migrate() throws Exception { db.prepareDbUnit(getClass(), "active_rules_changes.xml"); migration.execute(); - assertThat(dao.findAll(session)).hasSize(5); + + List changes = dao.findAll(session); + assertThat(changes.get(1).getData()).contains("param_PARAM1=TODO"); } @Test -- 2.39.5