From: Julien Lancelot Date: Wed, 29 Apr 2015 14:44:09 +0000 (+0200) Subject: SONAR-6458 Create FileDependencyDao to insert and select file dependencies X-Git-Tag: 5.2-RC1~2081 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=06d45ec40552f410c2e5beb318e8aac066572e2f;p=sonarqube.git SONAR-6458 Create FileDependencyDao to insert and select file dependencies --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java index 6cda0323c7e..d3340efd5fe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/DbClient.java @@ -43,6 +43,7 @@ import org.sonar.server.computation.db.AnalysisReportDao; import org.sonar.server.dashboard.db.DashboardDao; import org.sonar.server.dashboard.db.WidgetDao; import org.sonar.server.dashboard.db.WidgetPropertyDao; +import org.sonar.server.design.db.FileDependencyDao; import org.sonar.server.event.db.EventDao; import org.sonar.server.issue.db.IssueDao; import org.sonar.server.measure.persistence.MeasureDao; @@ -97,6 +98,7 @@ public class DbClient implements ServerComponent { private final ComponentIndexDao componentIndexDao; private final ComponentLinkDao componentLinkDao; private final EventDao eventDao; + private final FileDependencyDao fileDependencyDao; public DbClient(Database db, MyBatis myBatis, DaoComponent... daoComponents) { this.db = db; @@ -135,6 +137,7 @@ public class DbClient implements ServerComponent { componentIndexDao = getDao(map, ComponentIndexDao.class); componentLinkDao = getDao(map, ComponentLinkDao.class); eventDao = getDao(map, EventDao.class); + fileDependencyDao = getDao(map, FileDependencyDao.class); } public Database database() { @@ -261,6 +264,10 @@ public class DbClient implements ServerComponent { return eventDao; } + public FileDependencyDao fileDependencyDao() { + return fileDependencyDao; + } + private K getDao(Map map, Class clazz) { return (K) map.get(clazz); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/design/db/FileDependencyDao.java b/server/sonar-server/src/main/java/org/sonar/server/design/db/FileDependencyDao.java new file mode 100644 index 00000000000..0a7bfcd4d68 --- /dev/null +++ b/server/sonar-server/src/main/java/org/sonar/server/design/db/FileDependencyDao.java @@ -0,0 +1,41 @@ +/* + * 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.design.db; + +import org.sonar.api.ServerComponent; +import org.sonar.core.design.FileDependencyDto; +import org.sonar.core.design.FileDependencyMapper; +import org.sonar.core.persistence.DaoComponent; +import org.sonar.core.persistence.DbSession; + +import java.util.List; + +public class FileDependencyDao implements ServerComponent, DaoComponent { + + public List selectFromParents(DbSession session, String fromParentUuid, String toParentUuid, Long projectId) { + return session.getMapper(FileDependencyMapper.class).selectFromParents(fromParentUuid, toParentUuid, projectId); + } + + public void insert(DbSession session, FileDependencyDto dto) { + session.getMapper(FileDependencyMapper.class).insert(dto); + } + +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/design/db/FileDependencyDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/design/db/FileDependencyDaoTest.java new file mode 100644 index 00000000000..e7877bfd386 --- /dev/null +++ b/server/sonar-server/src/test/java/org/sonar/server/design/db/FileDependencyDaoTest.java @@ -0,0 +1,93 @@ +/* + * 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.design.db; + +import org.junit.After; +import org.junit.Before; +import org.junit.ClassRule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.sonar.core.design.FileDependencyDto; +import org.sonar.core.persistence.DbSession; +import org.sonar.core.persistence.DbTester; +import org.sonar.test.DbTests; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@Category(DbTests.class) +public class FileDependencyDaoTest { + + @ClassRule + public static DbTester dbTester = new DbTester(); + + DbSession session; + + FileDependencyDao dao; + + @Before + public void setup() throws Exception { + dbTester.truncateTables(); + session = dbTester.myBatis().openSession(false); + dao = new FileDependencyDao(); + } + + @After + public void tearDown() throws Exception { + session.close(); + } + + @Test + public void select_from_parents() throws Exception { + dbTester.prepareDbUnit(getClass(), "shared.xml"); + + List dtos = dao.selectFromParents(session, "MNOP", "QRST", 1L); + assertThat(dtos).hasSize(1); + + assertThat(dtos.get(0).getId()).isEqualTo(1); + assertThat(dtos.get(0).getFromComponentUuid()).isEqualTo("EFGH"); + assertThat(dtos.get(0).getToComponentUuid()).isEqualTo("IJKL"); + assertThat(dtos.get(0).getFromParentUuid()).isEqualTo("MNOP"); + assertThat(dtos.get(0).getToParentUuid()).isEqualTo("QRST"); + assertThat(dtos.get(0).getWeight()).isEqualTo(2); + assertThat(dtos.get(0).getRootProjectSnapshotId()).isEqualTo(10L); + assertThat(dtos.get(0).getCreatedAt()).isEqualTo(1000L); + + assertThat(dao.selectFromParents(session, "MNOP", "QRST", 123L)).isEmpty(); + } + + @Test + public void insert() throws Exception { + dao.insert(session, new FileDependencyDto() + .setFromComponentUuid("ABCD") + .setToComponentUuid("EFGH") + .setFromParentUuid("IJKL") + .setToParentUuid("MNOP") + .setRootProjectSnapshotId(10L) + .setWeight(2) + .setCreatedAt(1000L) + ); + session.commit(); + + dbTester.assertDbUnit(getClass(), "insert.xml", new String[]{"id"}, "dependencies"); + } +} diff --git a/server/sonar-server/src/test/java/org/sonar/server/event/db/EventDaoTest.java b/server/sonar-server/src/test/java/org/sonar/server/event/db/EventDaoTest.java index 30464f7273a..9068f1cce32 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/event/db/EventDaoTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/event/db/EventDaoTest.java @@ -46,6 +46,7 @@ public class EventDaoTest { @Before public void setup() throws Exception { + dbTester.truncateTables(); session = dbTester.myBatis().openSession(false); dao = new EventDao(); } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/insert.xml b/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/insert.xml new file mode 100644 index 00000000000..84dc73680c5 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/insert.xml @@ -0,0 +1,6 @@ + + + + + diff --git a/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/shared.xml new file mode 100644 index 00000000000..d45b5721cc9 --- /dev/null +++ b/server/sonar-server/src/test/resources/org/sonar/server/design/db/FileDependencyDaoTest/shared.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + diff --git a/sonar-core/src/main/java/org/sonar/core/design/DependencyDto.java b/sonar-core/src/main/java/org/sonar/core/design/DependencyDto.java deleted file mode 100644 index f7c3aa7cd21..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/design/DependencyDto.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.core.design; - -public final class DependencyDto { - private Long id; - private Long fromSnapshotId; - private Long toSnapshotId; - private String usage; - - public Long getId() { - return id; - } - - public DependencyDto setId(Long id) { - this.id = id; - return this; - } - - public Long getFromSnapshotId() { - return fromSnapshotId; - } - - public DependencyDto setFromSnapshotId(Long fromSnapshotId) { - this.fromSnapshotId = fromSnapshotId; - return this; - } - - public Long getToSnapshotId() { - return toSnapshotId; - } - - public DependencyDto setToSnapshotId(Long toSnapshotId) { - this.toSnapshotId = toSnapshotId; - return this; - } - - public String getUsage() { - return usage; - } - - public DependencyDto setUsage(String usage) { - this.usage = usage; - return this; - } -} diff --git a/sonar-core/src/main/java/org/sonar/core/design/DependencyMapper.java b/sonar-core/src/main/java/org/sonar/core/design/DependencyMapper.java deleted file mode 100644 index d596bbca71c..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/design/DependencyMapper.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.core.design; - -import org.apache.ibatis.session.ResultHandler; - -public interface DependencyMapper { - void selectAll(ResultHandler handler); -} diff --git a/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java b/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java new file mode 100644 index 00000000000..1c5fa2e3bb0 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/design/FileDependencyDto.java @@ -0,0 +1,105 @@ +/* + * 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.core.design; + +public final class FileDependencyDto { + + private Long id; + private String fromComponentUuid; + private String fromParentUuid; + private String toComponentUuid; + private String toParentUuid; + private Long rootProjectSnapshotId; + private Integer weight; + private Long createdAt; + + public Long getId() { + return id; + } + + public FileDependencyDto setId(Long id) { + this.id = id; + return this; + } + + public String getFromComponentUuid() { + return fromComponentUuid; + } + + public FileDependencyDto setFromComponentUuid(String fromComponentUuid) { + this.fromComponentUuid = fromComponentUuid; + return this; + } + + public String getFromParentUuid() { + return fromParentUuid; + } + + public FileDependencyDto setFromParentUuid(String fromParentUuid) { + this.fromParentUuid = fromParentUuid; + return this; + } + + public Long getRootProjectSnapshotId() { + return rootProjectSnapshotId; + } + + public FileDependencyDto setRootProjectSnapshotId(Long rootProjectSnapshotId) { + this.rootProjectSnapshotId = rootProjectSnapshotId; + return this; + } + + public String getToComponentUuid() { + return toComponentUuid; + } + + public FileDependencyDto setToComponentUuid(String toComponentUuid) { + this.toComponentUuid = toComponentUuid; + return this; + } + + public String getToParentUuid() { + return toParentUuid; + } + + public FileDependencyDto setToParentUuid(String toParentUuid) { + this.toParentUuid = toParentUuid; + return this; + } + + public Integer getWeight() { + return weight; + } + + public FileDependencyDto setWeight(Integer weight) { + this.weight = weight; + return this; + } + + public Long getCreatedAt() { + return createdAt; + } + + public FileDependencyDto setCreatedAt(Long createdAt) { + this.createdAt = createdAt; + return this; + } +} diff --git a/sonar-core/src/main/java/org/sonar/core/design/FileDependencyMapper.java b/sonar-core/src/main/java/org/sonar/core/design/FileDependencyMapper.java new file mode 100644 index 00000000000..1db9580520e --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/design/FileDependencyMapper.java @@ -0,0 +1,32 @@ +/* + * 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.core.design; + +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface FileDependencyMapper { + + List selectFromParents(@Param("fromParentUuid") String fromParentUuid, @Param("toParentUuid") String toParentUuid, @Param("projectId") Long projectId); + + void insert(FileDependencyDto dto); + +} diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java index d95c62afbab..fefd39960ce 100644 --- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java +++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java @@ -59,8 +59,7 @@ import org.sonar.core.dashboard.WidgetDto; import org.sonar.core.dashboard.WidgetMapper; import org.sonar.core.dashboard.WidgetPropertyDto; import org.sonar.core.dashboard.WidgetPropertyMapper; -import org.sonar.core.design.DependencyDto; -import org.sonar.core.design.DependencyMapper; +import org.sonar.core.design.FileDependencyMapper; import org.sonar.core.duplication.DuplicationMapper; import org.sonar.core.duplication.DuplicationUnitDto; import org.sonar.core.event.EventDto; @@ -193,7 +192,6 @@ public class MyBatis implements BatchComponent, ServerComponent { loadAlias(conf, "Component", ComponentDto.class); loadAlias(conf, "ComponentLink", ComponentLinkDto.class); loadAlias(conf, "Dashboard", DashboardDto.class); - loadAlias(conf, "Dependency", DependencyDto.class); loadAlias(conf, "DuplicationUnit", DuplicationUnitDto.class); loadAlias(conf, "Graph", GraphDto.class); loadAlias(conf, "Group", GroupDto.class); @@ -251,7 +249,7 @@ public class MyBatis implements BatchComponent, ServerComponent { loadMapper(conf, "org.sonar.core.permission.PermissionMapper"); Class[] mappers = {ActivityMapper.class, ActiveDashboardMapper.class, AuthorMapper.class, DashboardMapper.class, - DependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class, + FileDependencyMapper.class, DuplicationMapper.class, GraphDtoMapper.class, IssueMapper.class, IssueChangeMapper.class, IssueFilterMapper.class, IssueFilterFavouriteMapper.class, LoadedTemplateMapper.class, MeasureFilterMapper.class, Migration44Mapper.class, PermissionTemplateMapper.class, PropertiesMapper.class, PurgeMapper.class, ResourceKeyUpdaterMapper.class, ResourceIndexerMapper.class, RoleMapper.class, RuleMapper.class, diff --git a/sonar-core/src/main/resources/org/sonar/core/design/DependencyMapper.xml b/sonar-core/src/main/resources/org/sonar/core/design/DependencyMapper.xml deleted file mode 100644 index 313a9ba7148..00000000000 --- a/sonar-core/src/main/resources/org/sonar/core/design/DependencyMapper.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - diff --git a/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml b/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml new file mode 100644 index 00000000000..e738132b704 --- /dev/null +++ b/sonar-core/src/main/resources/org/sonar/core/design/FileDependencyMapper.xml @@ -0,0 +1,33 @@ + + + + + + + d.id as id, + d.from_component_uuid as fromComponentUuid, + d.to_component_uuid as toComponentUuid, + d.from_parent_uuid as fromParentUuid, + d.to_parent_uuid as toParentUuid, + d.root_project_snapshot_id as rootProjectSnapshotId, + d.dep_weight as "weight", + d.created_at as "createdAt" + + + + + + INSERT INTO dependencies (from_component_uuid, to_component_uuid, from_parent_uuid, to_parent_uuid, root_project_snapshot_id, dep_weight, created_at) + VALUES (#{fromComponentUuid,jdbcType=VARCHAR}, #{toComponentUuid,jdbcType=VARCHAR}, #{fromParentUuid,jdbcType=VARCHAR}, #{toParentUuid,jdbcType=BOOLEAN}, + #{rootProjectSnapshotId,jdbcType=VARCHAR}, #{weight,jdbcType=VARCHAR}, #{createdAt,jdbcType=VARCHAR}) + + + diff --git a/sonar-core/src/test/java/org/sonar/core/design/DependencyMapperTest.java b/sonar-core/src/test/java/org/sonar/core/design/DependencyMapperTest.java deleted file mode 100644 index 98244b3963d..00000000000 --- a/sonar-core/src/test/java/org/sonar/core/design/DependencyMapperTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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.core.design; - -import com.google.common.collect.Lists; -import org.apache.ibatis.session.ResultContext; -import org.apache.ibatis.session.ResultHandler; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.sonar.core.persistence.DbSession; -import org.sonar.core.persistence.DbTester; - -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; - -public class DependencyMapperTest { - - @ClassRule - public static DbTester dbtester = new DbTester(); - - DbSession session; - - @Before - public void setUp() throws Exception { - dbtester.truncateTables(); - session = dbtester.myBatis().openSession(false); - } - - @After - public void tearDown() throws Exception { - session.close(); - } - - @Test - public void select_all_dependencies() { - dbtester.prepareDbUnit(getClass(), "fixture.xml"); - - final List dependencies = Lists.newArrayList(); - - session.getMapper(DependencyMapper.class).selectAll(new ResultHandler() { - public void handleResult(ResultContext context) { - dependencies.add((DependencyDto) context.getResultObject()); - } - }); - - assertThat(dependencies).hasSize(2); - - DependencyDto dep = dependencies.get(0); - assertThat(dep.getId()).isEqualTo(1L); - assertThat(dep.getFromSnapshotId()).isEqualTo(1000L); - assertThat(dep.getToSnapshotId()).isEqualTo(1001L); - assertThat(dep.getUsage()).isEqualTo("compile"); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/design/FileDependencyDtoTest.java b/sonar-core/src/test/java/org/sonar/core/design/FileDependencyDtoTest.java new file mode 100644 index 00000000000..2870056b5d8 --- /dev/null +++ b/sonar-core/src/test/java/org/sonar/core/design/FileDependencyDtoTest.java @@ -0,0 +1,51 @@ +/* + * 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.core.design; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +public class FileDependencyDtoTest { + + @Test + public void test_getters_and_setters() throws Exception { + FileDependencyDto dto = new FileDependencyDto() + .setId(1L) + .setFromComponentUuid("ABCD") + .setToComponentUuid("EFGH") + .setFromParentUuid("IJKL") + .setToParentUuid("MNOP") + .setRootProjectSnapshotId(10L) + .setWeight(2) + .setCreatedAt(1000L); + + assertThat(dto.getId()).isEqualTo(1L); + assertThat(dto.getFromComponentUuid()).isEqualTo("ABCD"); + assertThat(dto.getToComponentUuid()).isEqualTo("EFGH"); + assertThat(dto.getFromParentUuid()).isEqualTo("IJKL"); + assertThat(dto.getToParentUuid()).isEqualTo("MNOP"); + assertThat(dto.getRootProjectSnapshotId()).isEqualTo(10L); + assertThat(dto.getWeight()).isEqualTo(2); + assertThat(dto.getCreatedAt()).isEqualTo(1000L); + } + +} diff --git a/sonar-core/src/test/resources/org/sonar/core/design/DependencyMapperTest/fixture.xml b/sonar-core/src/test/resources/org/sonar/core/design/DependencyMapperTest/fixture.xml deleted file mode 100644 index f190e3a4221..00000000000 --- a/sonar-core/src/test/resources/org/sonar/core/design/DependencyMapperTest/fixture.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - -