diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-14 17:41:04 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-12-15 14:45:00 +0100 |
commit | a2387e7c4baeec2522b6017b7447fcda77716c5d (patch) | |
tree | c7f4096c8e0c64a70e45ab7c406cf02bb92f73e1 /sonar-db/src | |
parent | 2ce306a42f031d75c4ec4f12a69e2bc580f4a1d5 (diff) | |
download | sonarqube-a2387e7c4baeec2522b6017b7447fcda77716c5d.tar.gz sonarqube-a2387e7c4baeec2522b6017b7447fcda77716c5d.zip |
SONAR-7292 Move IssueTesting to sonar-db for IssueDto and keep IssueDocTesting for IssueDoc
Diffstat (limited to 'sonar-db/src')
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/issue/IssueTesting.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/issue/IssueTesting.java b/sonar-db/src/main/java/org/sonar/db/issue/IssueTesting.java new file mode 100644 index 00000000000..c5106090393 --- /dev/null +++ b/sonar-db/src/main/java/org/sonar/db/issue/IssueTesting.java @@ -0,0 +1,61 @@ +/* + * 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.issue; + +import org.sonar.api.issue.Issue; +import org.sonar.api.rule.Severity; +import org.sonar.api.rules.RuleType; +import org.sonar.api.utils.DateUtils; +import org.sonar.core.util.Uuids; +import org.sonar.db.component.ComponentDto; +import org.sonar.db.rule.RuleDto; + +public class IssueTesting { + + private IssueTesting() { + + } + + /** + * Full IssueDto used to feed database with fake data. Tests must not rely on the + * field contents declared here. They should override the fields they need to test, + * for example: + * <pre> + * issueDao.insert(dbSession, IssueTesting.newDto(rule, file, project).setStatus(Issue.STATUS_RESOLVED).setResolution(Issue.RESOLUTION_FALSE_POSITIVE)); + * </pre> + */ + public static IssueDto newDto(RuleDto rule, ComponentDto file, ComponentDto project) { + return new IssueDto() + .setKee(Uuids.create()) + .setRule(rule) + .setType(RuleType.CODE_SMELL) + .setComponent(file) + .setProject(project) + .setStatus(Issue.STATUS_OPEN) + .setResolution(null) + .setSeverity(Severity.MAJOR) + .setEffort(10L) + .setIssueCreationDate(DateUtils.parseDate("2014-09-04")) + .setIssueUpdateDate(DateUtils.parseDate("2014-12-04")) + .setCreatedAt(1_400_000_000_000L) + .setUpdatedAt(1_400_000_000_000L); + } + +} |