import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.utils.Duration;
+import org.sonar.api.utils.System2;
import org.sonar.batch.issue.IssueCache;
import org.sonar.batch.scan.LastLineHashes;
import org.sonar.batch.scan.filesystem.InputPathCache;
@Test
public void merge_issue_changelog_with_previous_changelog() throws Exception {
- when(initialOpenIssues.selectChangelog("ABCDE")).thenReturn(newArrayList(new IssueChangeDto().setIssueKey("ABCD")));
+ when(initialOpenIssues.selectChangelog("ABCDE")).thenReturn(newArrayList(new IssueChangeDto().setIssueKey("ABCD").setCreatedAt(System2.INSTANCE.now())));
IssueDto previousIssue = new IssueDto().setKee("ABCDE").setResolution(null).setStatus("OPEN").setRuleKey("squid", "AvoidCycle")
- .setLine(10).setMessage("Message").setEffortToFix(1.5).setDebt(1L);
+ .setLine(10).setMessage("Message").setEffortToFix(1.5).setDebt(1L).setCreatedAt(System2.INSTANCE.now());
DefaultIssue issue = new DefaultIssue();
IssueTrackingResult trackingResult = mock(IssueTrackingResult.class);
import org.sonar.server.db.migrations.v451.AddMissingCustomRuleParametersMigration;
import org.sonar.server.db.migrations.v451.DeleteUnescapedActivities;
import org.sonar.server.db.migrations.v50.*;
-import org.sonar.server.db.migrations.v51.CopyScmAccountsFromAuthorsToUsers;
-import org.sonar.server.db.migrations.v51.FeedIssueTags;
-import org.sonar.server.db.migrations.v51.FeedUsersLongDates;
-import org.sonar.server.db.migrations.v51.RenameComponentRelatedParamsInIssueFilters;
+import org.sonar.server.db.migrations.v51.*;
import java.util.List;
FeedIssueTags.class,
FeedUsersLongDates.class,
RenameComponentRelatedParamsInIssueFilters.class,
- CopyScmAccountsFromAuthorsToUsers.class
- );
+ CopyScmAccountsFromAuthorsToUsers.class,
+ FeedIssueChangesLongDates.class
+ );
}
--- /dev/null
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v51;
+
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.Database;
+import org.sonar.server.db.migrations.BaseDataChange;
+import org.sonar.server.db.migrations.MassUpdate;
+import org.sonar.server.db.migrations.Select;
+import org.sonar.server.db.migrations.SqlStatement;
+
+import java.sql.SQLException;
+import java.util.Date;
+
+public class FeedIssueChangesLongDates extends BaseDataChange {
+
+ private final System2 system;
+
+ public FeedIssueChangesLongDates(Database db, System2 system) {
+ super(db);
+ this.system = system;
+ }
+
+ @Override
+ public void execute(Context context) throws SQLException {
+ final long now = system.now();
+
+ MassUpdate massUpdate = context.prepareMassUpdate();
+ massUpdate.select("SELECT i.created_at, i.updated_at, i.issue_change_creation_date_ms, i.id FROM issue_changes i WHERE created_at_ms IS NULL");
+ massUpdate.update("UPDATE issue_changes SET created_at_ms=?, updated_at_ms=?, issue_change_creation_date_ms=? WHERE id=?");
+ massUpdate.rowPluralName("issue_changes");
+ massUpdate.execute(new MassUpdate.Handler() {
+ @Override
+ public boolean handle(Select.Row row, SqlStatement update) throws SQLException {
+ Date createdAt = row.getDate(1);
+ Date updatedAt = row.getDate(2);
+ Date functionalCreatedAt = row.getDate(3);
+ Long id = row.getLong(4);
+
+ updateColumn(update, 1, createdAt);
+ updateColumn(update, 2, updatedAt);
+ if (functionalCreatedAt == null) {
+ update.setLong(3, null);
+ } else {
+ update.setLong(3, functionalCreatedAt.getTime());
+ }
+ update.setLong(4, id);
+ return true;
+ }
+
+ private void updateColumn(SqlStatement update, int position, Date time) throws SQLException {
+ if (time == null) {
+ update.setLong(position, now);
+ } else {
+ update.setLong(position, Math.min(now, time.getTime()));
+ }
+ }
+ });
+ }
+
+}
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.issue.internal.DefaultIssueComment;
import org.sonar.api.issue.internal.IssueChangeContext;
+import org.sonar.api.utils.System2;
import org.sonar.core.issue.IssueUpdater;
import org.sonar.core.issue.db.IssueChangeDao;
import org.sonar.core.issue.db.IssueChangeDto;
issueService.getByKey(comment.issueKey());
IssueChangeDto dto = IssueChangeDto.of(comment);
- dto.setUpdatedAt(new Date());
+ dto.setUpdatedAt(System2.INSTANCE.now());
dto.setChangeData(text);
changeDao.update(dto);
--- /dev/null
+/*
+ * 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.
+ */
+
+package org.sonar.server.db.migrations.v51;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonar.api.utils.System2;
+import org.sonar.core.persistence.DbTester;
+import org.sonar.server.db.migrations.DatabaseMigration;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class FeedIssueChangesLongDatesTest {
+ @ClassRule
+ public static DbTester db = new DbTester().schema(FeedIssueChangesLongDatesTest.class, "schema.sql");
+
+ @Test
+ public void execute() throws Exception {
+ db.prepareDbUnit(getClass(), "before.xml");
+
+ System2 system = mock(System2.class);
+ when(system.now()).thenReturn(1500000000000L);
+ DatabaseMigration migration = new FeedIssueChangesLongDates(db.database(), system);
+ migration.execute();
+
+ int count = db.countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null");
+ assertThat(count).isEqualTo(3);
+
+ int countWithAllDateFieldsNull = db
+ .countSql("select count(*) from issue_changes where created_at_ms is not null and updated_at_ms is not null and issue_change_creation_date_ms is not null");
+ assertThat(countWithAllDateFieldsNull).isEqualTo(1);
+ }
+}
.setChangeData("*My comment*")
.setChangeType(IssueChangeDto.TYPE_COMMENT)
.setUserLogin("john")
- .setCreatedAt(DateUtils.parseDate("2014-09-09")));
+ .setCreatedAt(DateUtils.parseDate("2014-09-09").getTime()));
tester.get(IssueChangeDao.class).insert(session,
new IssueChangeDto().setIssueKey(issue.getKey())
.setKey("COMMENT-ABCE")
.setChangeData("Another comment")
.setChangeType(IssueChangeDto.TYPE_COMMENT)
.setUserLogin("fabrice")
- .setCreatedAt(DateUtils.parseDate("2014-09-10")));
+ .setCreatedAt(DateUtils.parseDate("2014-09-10").getTime()));
session.commit();
tester.get(IssueIndexer.class).indexAll();
--- /dev/null
+<dataset>
+
+ <!-- new migration -->
+ <issue_changes id="1" kee="ABC-DEF" issue_key="ABC" user_login="[null]" change_type="[null]" change_data="[null]"
+ created_at="2013-05-18"
+ updated_at="2013-05-18"
+ issue_change_creation_date="2013-05-18"
+ created_at_ms="[null]"
+ updated_at_ms="[null]"
+ issue_change_creation_date_ms="[null]"/>
+ />
+
+ <!-- re-entrant migration - ignore the issues that are already fed with new dates -->
+ <issue_changes id="2" kee="FGH-DEF" issue_key="FGH" user_login="[null]" change_type="[null]" change_data="[null]"
+ created_at="2013-05-18"
+ updated_at="2013-05-18"
+ issue_change_creation_date="2013-05-18"
+ created_at_ms="1500000000000"
+ updated_at_ms="1500000000000"
+ issue_change_creation_date_ms="1500000000000"/>
+
+ <!-- NULL dates -->
+ <issue_changes id="3" kee="MISSING-DEF" issue_key="MISSING" user_login="[null]" change_type="[null]"
+ change_data="[null]"
+ created_at="[null]"
+ updated_at="[null]"
+ issue_change_creation_date="[null]"
+ created_at_ms="[null]"
+ updated_at_ms="[null]"
+ issue_change_creation_date_ms="[null]"/>
+</dataset>
--- /dev/null
+CREATE TABLE "ISSUE_CHANGES" (
+ "ID" BIGINT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1),
+ "KEE" VARCHAR(50),
+ "ISSUE_KEY" VARCHAR(50) NOT NULL,
+ "USER_LOGIN" VARCHAR(255),
+ "CHANGE_TYPE" VARCHAR(40),
+ "CHANGE_DATA" VARCHAR(16777215),
+ "CREATED_AT" TIMESTAMP,
+ "UPDATED_AT" TIMESTAMP,
+ "ISSUE_CHANGE_CREATION_DATE" TIMESTAMP,
+ "CREATED_AT_MS" BIGINT,
+ "UPDATED_AT_MS" BIGINT,
+ "ISSUE_CHANGE_CREATION_DATE_MS" BIGINT
+);
--- /dev/null
+#
+# 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 5.1
+#
+class AddIssueChangesLongDates < ActiveRecord::Migration
+
+ def self.up
+ add_column 'issue_changes', :created_at_ms, :big_integer, :null => true
+ add_column 'issue_changes', :updated_at_ms, :big_integer, :null => true
+ add_column 'issue_changes', :issue_change_creation_date_ms, :big_integer, :null => true
+ end
+end
+
--- /dev/null
+#
+# 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 5.1
+#
+class FeedIssueChangesLongDates < ActiveRecord::Migration
+
+ def self.up
+ execute_java_migration('org.sonar.server.db.migrations.v51.FeedIssueChangesLongDates')
+ end
+
+end
+
--- /dev/null
+#
+# 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 5.1
+#
+class RenameIssueChangesLongDates < ActiveRecord::Migration
+
+ def self.up
+ remove_column 'issue_changes', 'created_at'
+ remove_column 'issue_changes', 'updated_at'
+ remove_column 'issue_changes', 'issue_change_creation_date'
+ rename_column 'issue_changes', 'created_at_ms', 'created_at'
+ rename_column 'issue_changes', 'updated_at_ms', 'updated_at'
+ rename_column 'issue_changes', 'issue_change_creation_date_ms', 'issue_change_creation_date'
+ end
+end
+
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.issue.internal.DefaultIssueComment;
import org.sonar.api.issue.internal.FieldDiffs;
+import org.sonar.api.utils.System2;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.Date;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* @since 3.6
*/
private String changeData;
// technical dates
- private Date createdAt;
- private Date updatedAt;
+ private Long createdAt;
+ private Long updatedAt;
// functional date
- private Date issueChangeCreationDate;
+ private Long issueChangeCreationDate;
+
+ public static IssueChangeDto of(DefaultIssueComment comment) {
+ IssueChangeDto dto = newDto(comment.issueKey());
+ dto.setKey(comment.key());
+ dto.setChangeType(IssueChangeDto.TYPE_COMMENT);
+ dto.setChangeData(comment.markdownText());
+ dto.setUserLogin(comment.userLogin());
+ dto.setIssueChangeCreationDate(comment.createdAt() == null ? null : comment.createdAt().getTime());
+ return dto;
+ }
+
+ public static IssueChangeDto of(String issueKey, FieldDiffs diffs) {
+ IssueChangeDto dto = newDto(issueKey);
+ dto.setChangeType(IssueChangeDto.TYPE_FIELD_CHANGE);
+ dto.setChangeData(diffs.toString());
+ dto.setUserLogin(diffs.userLogin());
+ dto.setIssueChangeCreationDate(diffs.creationDate() == null ? null : diffs.creationDate().getTime());
+ return dto;
+ }
+
+ private static IssueChangeDto newDto(String issueKey) {
+ IssueChangeDto dto = new IssueChangeDto();
+ dto.setIssueKey(issueKey);
+
+ // technical dates - do not use the context date
+ dto.setCreatedAt(System2.INSTANCE.now());
+ dto.setUpdatedAt(System2.INSTANCE.now());
+ return dto;
+ }
public Long getId() {
return id;
return this;
}
- public Date getCreatedAt() {
+ public Long getCreatedAt() {
return createdAt;
}
- public IssueChangeDto setCreatedAt(Date createdAt) {
- this.createdAt = createdAt;
+ public IssueChangeDto setCreatedAt(Long createdAt) {
+ this.createdAt = checkNotNull(createdAt);
return this;
}
- public Date getUpdatedAt() {
+ public Long getUpdatedAt() {
return updatedAt;
}
- public IssueChangeDto setUpdatedAt(Date updatedAt) {
+ public IssueChangeDto setUpdatedAt(@Nullable Long updatedAt) {
this.updatedAt = updatedAt;
return this;
}
- public Date getIssueChangeCreationDate() {
+ public Long getIssueChangeCreationDate() {
return issueChangeCreationDate;
}
- public IssueChangeDto setIssueChangeCreationDate(Date issueChangeCreationDate) {
+ public IssueChangeDto setIssueChangeCreationDate(@Nullable Long issueChangeCreationDate) {
this.issueChangeCreationDate = issueChangeCreationDate;
return this;
}
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
- public static IssueChangeDto of(DefaultIssueComment comment) {
- IssueChangeDto dto = newDto(comment.issueKey());
- dto.setKey(comment.key());
- dto.setChangeType(IssueChangeDto.TYPE_COMMENT);
- dto.setChangeData(comment.markdownText());
- dto.setUserLogin(comment.userLogin());
- dto.setIssueChangeCreationDate(comment.createdAt());
- return dto;
- }
-
- public static IssueChangeDto of(String issueKey, FieldDiffs diffs) {
- IssueChangeDto dto = newDto(issueKey);
- dto.setChangeType(IssueChangeDto.TYPE_FIELD_CHANGE);
- dto.setChangeData(diffs.toString());
- dto.setUserLogin(diffs.userLogin());
- dto.setIssueChangeCreationDate(diffs.creationDate());
- return dto;
- }
-
- private static IssueChangeDto newDto(String issueKey) {
- IssueChangeDto dto = new IssueChangeDto();
- dto.setIssueKey(issueKey);
-
- // technical dates - do not use the context date
- Date now = new Date();
- dto.setCreatedAt(now);
- dto.setUpdatedAt(new Date());
- return dto;
- }
-
public DefaultIssueComment toComment() {
return new DefaultIssueComment()
.setMarkdownText(changeData)
.setKey(kee)
- .setCreatedAt(createdAt)
- .setUpdatedAt(updatedAt)
+ .setCreatedAt(new Date(createdAt))
+ .setUpdatedAt(updatedAt == null ? null : new Date(updatedAt))
.setUserLogin(userLogin)
.setIssueKey(issueKey)
.setNew(false);
return FieldDiffs.parse(changeData)
.setUserLogin(userLogin)
// issueChangeCreationDate can be null as it has been introduced after createdAt
- .setCreationDate(issueChangeCreationDate != null ? issueChangeCreationDate : createdAt)
+ .setCreationDate(issueChangeCreationDate != null ? new Date(issueChangeCreationDate) : new Date(createdAt))
.setIssueKey(issueKey);
}
}
*/
public class DatabaseVersion implements BatchComponent, ServerComponent {
- public static final int LAST_VERSION = 759;
+ public static final int LAST_VERSION = 762;
/**
* List of all the tables.n
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('757');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('758');
INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('759');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('760');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('761');
+INSERT INTO SCHEMA_MIGRATIONS(VERSION) VALUES ('762');
INSERT INTO USERS(ID, LOGIN, NAME, EMAIL, CRYPTED_PASSWORD, SALT, CREATED_AT, UPDATED_AT, REMEMBER_TOKEN, REMEMBER_TOKEN_EXPIRES_AT) VALUES (1, 'admin', 'Administrator', '', 'a373a0e667abb2604c1fd571eb4ad47fe8cc0878', '48bc4b0d93179b5103fd3885ea9119498e9d161b', '1418215735482', '1418215735482', null, null);
ALTER TABLE USERS ALTER COLUMN ID RESTART WITH 2;
"USER_LOGIN" VARCHAR(255),
"CHANGE_TYPE" VARCHAR(40),
"CHANGE_DATA" VARCHAR(16777215),
- "CREATED_AT" TIMESTAMP,
- "UPDATED_AT" TIMESTAMP,
- "ISSUE_CHANGE_CREATION_DATE" TIMESTAMP,
+ "CREATED_AT" BIGINT,
+ "UPDATED_AT" BIGINT,
+ "ISSUE_CHANGE_CREATION_DATE" BIGINT
);
CREATE TABLE "ISSUE_FILTERS" (
DefaultIssueComment first = comments.get(0);
assertThat(first.markdownText()).isEqualTo("old comment");
-
DefaultIssueComment second = comments.get(1);
assertThat(second.userLogin()).isEqualTo("arthur");
assertThat(second.key()).isEqualTo("FGHIJ");
DbSession session = getMyBatis().openSession(false);
List<String> hugeNbOfIssues = newArrayList();
- for (int i=0; i<4500; i++) {
- hugeNbOfIssues.add("ABCD"+i);
+ for (int i = 0; i < 4500; i++) {
+ hugeNbOfIssues.add("ABCD" + i);
}
List<DefaultIssueComment> comments = dao.selectCommentsByIssues(session, hugeNbOfIssues);
MyBatis.closeQuietly(session);
.setChangeData("Some text")
.setChangeType("comment")
.setIssueKey("ABCDE")
- .setCreatedAt(DateUtils.parseDate("2014-09-09"))
- .setUpdatedAt(DateUtils.parseDate("2014-09-10"))
- .setIssueChangeCreationDate(DateUtils.parseDate("2014-09-11"));
+ .setCreatedAt(DateUtils.parseDate("2014-09-09").getTime())
+ .setUpdatedAt(DateUtils.parseDate("2014-09-10").getTime())
+ .setIssueChangeCreationDate(DateUtils.parseDate("2014-09-11").getTime());
dao.insert(session, changeDto);
session.commit();
// Only the following fields can be updated:
change.setChangeData("new comment");
- change.setUpdatedAt(DateUtils.parseDate("2013-06-30"));
+ change.setUpdatedAt(DateUtils.parseDate("2013-06-30").getTime());
assertThat(dao.update(change)).isTrue();
// Only the following fields can be updated:
change.setChangeData("new comment");
- change.setUpdatedAt(DateUtils.parseDate("2013-06-30"));
+ change.setUpdatedAt(DateUtils.parseDate("2013-06-30").getTime());
assertThat(dao.update(change)).isFalse();
}
import org.sonar.api.issue.internal.DefaultIssueComment;
import org.sonar.api.issue.internal.FieldDiffs;
import org.sonar.api.utils.DateUtils;
-
-import java.util.Date;
+import org.sonar.api.utils.System2;
import static org.assertj.core.api.Assertions.assertThat;
assertThat(dto.getChangeType()).isEqualTo("diff");
assertThat(dto.getCreatedAt()).isNotNull();
assertThat(dto.getUpdatedAt()).isNotNull();
- assertThat(dto.getIssueChangeCreationDate()).isEqualTo(DateUtils.parseDate("2014-01-03"));
+ assertThat(dto.getIssueChangeCreationDate()).isEqualTo(DateUtils.parseDate("2014-01-03").getTime());
assertThat(dto.getIssueKey()).isEqualTo("ABCDE");
assertThat(dto.getUserLogin()).isEqualTo("emmerik");
}
.setUserLogin("emmerik")
.setChangeData("Some text")
.setIssueKey("ABCDE")
- .setCreatedAt(new Date())
- .setUpdatedAt(new Date());
+ .setCreatedAt(System2.INSTANCE.now())
+ .setUpdatedAt(System2.INSTANCE.now());
DefaultIssueComment comment = changeDto.toComment();
assertThat(comment.key()).isEqualTo("EFGH");
.setUserLogin("emmerik")
.setChangeData("Some text")
.setIssueKey("ABCDE")
- .setIssueChangeCreationDate(new Date());
+ .setIssueChangeCreationDate(System2.INSTANCE.now());
FieldDiffs diffs = changeDto.toFieldDiffs();
assertThat(diffs.userLogin()).isEqualTo("emmerik");
.setUserLogin("emmerik")
.setChangeData("Some text")
.setIssueKey("ABCDE")
- .setCreatedAt(new Date());
+ .setCreatedAt(System2.INSTANCE.now());
FieldDiffs diffs = changeDto.toFieldDiffs();
assertThat(diffs.userLogin()).isEqualTo("emmerik");
import org.sonar.core.persistence.AbstractDaoTestCase;
import org.sonar.core.persistence.MyBatis;
-import java.util.Date;
-
public class IssueChangeMapperTest extends AbstractDaoTestCase {
SqlSession session;
IssueChangeMapper mapper;
dto.setIssueKey("ABCDE");
dto.setChangeType(IssueChangeDto.TYPE_FIELD_CHANGE);
dto.setChangeData("severity=INFO|BLOCKER");
- Date d = DateUtils.parseDate("2013-05-18");
+ long d = DateUtils.parseDate("2013-05-18").getTime();
dto.setCreatedAt(d);
dto.setUpdatedAt(d);
dto.setIssueChangeCreationDate(d);
mapper.insert(dto);
session.commit();
- checkTables("insert_diff", new String[]{"id"}, "issue_changes");
+ checkTables("insert_diff", new String[] {"id"}, "issue_changes");
}
@Test
dto.setIssueKey("ABCDE");
dto.setChangeType(IssueChangeDto.TYPE_COMMENT);
dto.setChangeData("the comment");
- Date d = DateUtils.parseDate("2013-05-18");
+ long d = DateUtils.parseDate("2013-05-18").getTime();
dto.setCreatedAt(d);
dto.setUpdatedAt(d);
mapper.insert(dto);
session.commit();
- checkTables("insert_comment", new String[]{"id"}, "issue_changes");
+ checkTables("insert_comment", new String[] {"id"}, "issue_changes");
}
}
user_login="arthur"
change_type="comment"
change_data="old comment"
- created_at="2013-01-01"
- updated_at="2013-01-01"
+ created_at="1356994800000"
+ updated_at="1356994800000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
/>
<!--
user_login="arthur"
change_type="comment"
change_data="recent comment"
- created_at="2013-05-05"
- updated_at="2013-05-05"
- issue_change_creation_date="2013-05-05"
+ created_at="1367704800000"
+ updated_at="1367704800000"
+ issue_change_creation_date="1367704800000"
/>
-->
</dataset>
user_login="arthur"
change_type="comment"
change_data="old comment"
- created_at="2013-01-01"
- updated_at="2013-01-01"
+ created_at="1356994800000"
+ updated_at="1356994800000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
/>
<issue_changes
user_login="arthur"
change_type="comment"
change_data="recent comment"
- created_at="2013-05-05"
- updated_at="2013-05-05"
- issue_change_creation_date="2013-05-05"
+ created_at="1367704800000"
+ updated_at="1367704800000"
+ issue_change_creation_date="1367704800000"
/>
</dataset>
user_login="emmerik"
change_type="comment"
change_data="Some text"
- created_at="2014-09-09"
- updated_at="2014-09-10"
- issue_change_creation_date="2014-09-11"
+ created_at="1410213600000"
+ updated_at="1410300000000"
+ issue_change_creation_date="1410386400000"
/>
</dataset>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<issue_changes
user_login="arthur"
change_type="diff"
change_data="actionPlan=1.0|1.1"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<issue_changes
user_login="arthur"
change_type="comment"
change_data="recent comment"
- created_at="2013-04-16"
- updated_at="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<!-- Closed Issue on a file -->
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<!-- Open Issue on a sub module -->
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<!-- Open Issue on a root module -->
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
</dataset>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-18"
- updated_at="2013-04-18"
- issue_change_creation_date="2013-04-18"
+ created_at="1410386400000"
+ updated_at="1410386400000"
+ issue_change_creation_date="1410386400000"
/>
<issue_changes
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-04-16"
- updated_at="2013-04-16"
- issue_change_creation_date="2013-04-16"
+ created_at="1410213600000"
+ updated_at="1410213600000"
+ issue_change_creation_date="1410213600000"
/>
<issue_changes
user_login="arthur"
change_type="diff"
change_data="actionPlan=1.0|1.1"
- created_at="2013-04-17"
- updated_at="2013-04-17"
- issue_change_creation_date="2013-04-17"
+ created_at="1410300000000"
+ updated_at="1410300000000"
+ issue_change_creation_date="1410300000000"
/>
</dataset>
user_login="arthur"
change_type="comment"
change_data="old comment"
- created_at="2013-01-01"
- updated_at="2013-01-01"
+ created_at="1356994800000"
+ updated_at="1356994800000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
/>
<issue_changes
user_login="arthur"
change_type="comment"
change_data="recent comment"
- created_at="2013-05-05"
- updated_at="2013-05-05"
+ created_at="1367704800000"
+ updated_at="1367704800000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="actionPlan=1.0|1.1"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
/>
<issue_changes
user_login="henry"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-01"
- updated_at="2013-02-01"
- issue_change_creation_date="2013-02-01"
+ created_at="1356994800000"
+ updated_at="1356994800000"
+ issue_change_creation_date="1356994800000"
/>
</dataset>
<dataset>
<issue_changes
- id="100"
- kee="COMMENT-1"
- issue_key="ISSUE-1"
- user_login="arthur"
- change_type="comment"
- change_data="old comment"
- created_at="2013-01-01"
- updated_at="2013-01-01"
- issue_change_creation_date="[null]"
- />
+ id="100"
+ kee="COMMENT-1"
+ issue_key="ISSUE-1"
+ user_login="arthur"
+ change_type="comment"
+ change_data="old comment"
+ created_at="1356994800000"
+ updated_at="1356994800000"
+ issue_change_creation_date="[null]"
+ />
<issue_changes
- id="101"
- kee="[null]"
- issue_key="1000"
- user_login="arthur"
- change_type="diff"
- change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
- />
+ id="101"
+ kee="[null]"
+ issue_key="1000"
+ user_login="arthur"
+ change_type="diff"
+ change_data="severity=MAJOR|BLOCKER"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
+ />
<issue_changes
- id="102"
- kee="COMMENT-2"
- issue_key="ISSUE-1"
- user_login="arthur"
- change_type="comment"
- change_data="new comment"
- created_at="2013-05-05"
- updated_at="2013-06-30"
- issue_change_creation_date="[null]"
- />
+ id="102"
+ kee="COMMENT-2"
+ issue_key="ISSUE-1"
+ user_login="arthur"
+ change_type="comment"
+ change_data="new comment"
+ created_at="1367704800000"
+ updated_at="1372543200000"
+ issue_change_creation_date="[null]"
+ />
</dataset>
user_login="arthur"
change_type="comment"
change_data="old comment"
- created_at="2013-01-01"
- updated_at="2013-01-01"
+ created_at="1356994800000"
+ updated_at="1356994800000"
issue_change_creation_date="[null]"
/>
user_login="arthur"
change_type="diff"
change_data="severity=MAJOR|BLOCKER"
- created_at="2013-02-02"
- updated_at="2013-02-02"
- issue_change_creation_date="2013-02-02"
+ created_at="1359759600000"
+ updated_at="1359759600000"
+ issue_change_creation_date="1359759600000"
/>
<issue_changes
user_login="arthur"
change_type="comment"
change_data="old value"
- created_at="2013-05-05"
- updated_at="2013-05-05"
+ created_at="1367704800000"
+ updated_at="1367704800000"
issue_change_creation_date="[null]"
/>
</dataset>
user_login="emmerik"
change_type="comment"
change_data="the comment"
- created_at="2013-05-18"
- updated_at="2013-05-18"
+ created_at="1368828000000"
+ updated_at="1368828000000"
issue_change_creation_date="[null]"
/>
</dataset>
user_login="emmerik"
change_type="diff"
change_data="severity=INFO|BLOCKER"
- created_at="2013-05-18"
- updated_at="2013-05-18"
- issue_change_creation_date="2013-05-18"
+ created_at="1368828000000"
+ updated_at="1368828000000"
+ issue_change_creation_date="1368828000000"
/>
</dataset>