]> source.dussan.org Git - sonarqube.git/blob
9690ef6f783272d2803a83c7ebfcb07e62ef47ec
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2022 SonarSource SA
4  * mailto:info AT sonarsource DOT com
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 package org.sonar.ce.task.projectanalysis.step;
21
22 import java.text.SimpleDateFormat;
23 import java.util.Date;
24 import java.util.Random;
25 import java.util.stream.Stream;
26 import javax.annotation.Nullable;
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.sonar.api.resources.Qualifiers;
31 import org.sonar.api.resources.Scopes;
32 import org.sonar.api.utils.System2;
33 import org.sonar.ce.task.projectanalysis.analysis.AnalysisMetadataHolderRule;
34 import org.sonar.ce.task.projectanalysis.component.BranchPersister;
35 import org.sonar.ce.task.projectanalysis.component.Component;
36 import org.sonar.ce.task.projectanalysis.component.DefaultBranchImpl;
37 import org.sonar.ce.task.projectanalysis.component.MutableDisabledComponentsHolder;
38 import org.sonar.ce.task.projectanalysis.component.ProjectPersister;
39 import org.sonar.ce.task.projectanalysis.component.ProjectViewAttributes;
40 import org.sonar.ce.task.projectanalysis.component.SubViewAttributes;
41 import org.sonar.ce.task.projectanalysis.component.TreeRootHolderRule;
42 import org.sonar.ce.task.projectanalysis.component.ViewAttributes;
43 import org.sonar.ce.task.projectanalysis.component.ViewsComponent;
44 import org.sonar.ce.task.step.ComputationStep;
45 import org.sonar.ce.task.step.TestComputationStepContext;
46 import org.sonar.db.DbClient;
47 import org.sonar.db.DbTester;
48 import org.sonar.db.component.ComponentDbTester;
49 import org.sonar.db.component.ComponentDto;
50 import org.sonar.db.component.ComponentTesting;
51
52 import static org.assertj.core.api.Assertions.assertThat;
53 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
54 import static org.mockito.Mockito.mock;
55 import static org.mockito.Mockito.when;
56 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.APPLICATION;
57 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.PORTFOLIO;
58 import static org.sonar.ce.task.projectanalysis.component.ViewsComponent.builder;
59 import static org.sonar.db.component.BranchDto.DEFAULT_PROJECT_MAIN_BRANCH_NAME;
60 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
61 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
62 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
63
64 public class ViewsPersistComponentsStepTest extends BaseStepTest {
65
66   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
67
68   private static final String VIEW_KEY = "VIEW_KEY";
69   private static final String VIEW_NAME = "VIEW_NAME";
70   private static final String VIEW_DESCRIPTION = "view description";
71   private static final String VIEW_UUID = "VIEW_UUID";
72   private static final String SUBVIEW_1_KEY = "SUBVIEW_1_KEY";
73   private static final String SUBVIEW_1_NAME = "SUBVIEW_1_NAME";
74   private static final String SUBVIEW_1_DESCRIPTION = "subview 1 description";
75   private static final String SUBVIEW_1_UUID = "SUBVIEW_1_UUID";
76   private static final String PROJECT_VIEW_1_KEY = "PV1_KEY";
77   private static final String PROJECT_VIEW_1_NAME = "PV1_NAME";
78   private static final String PROJECT_VIEW_1_UUID = "PV1_UUID";
79
80   @Rule
81   public DbTester dbTester = DbTester.create(System2.INSTANCE);
82
83   @Rule
84   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
85   @Rule
86   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
87
88   private final System2 system2 = mock(System2.class);
89   private final DbClient dbClient = dbTester.getDbClient();
90   private Date now;
91   private final ComponentDbTester componentDbTester = new ComponentDbTester(dbTester);
92   private final MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS);
93   private PersistComponentsStep underTest;
94
95   @Before
96   public void setup() throws Exception {
97     now = DATE_FORMAT.parse("2015-06-02");
98     when(system2.now()).thenReturn(now.getTime());
99
100     analysisMetadataHolder.setBranch(new DefaultBranchImpl(DEFAULT_PROJECT_MAIN_BRANCH_NAME));
101     BranchPersister branchPersister = mock(BranchPersister.class);
102     ProjectPersister projectPersister = mock(ProjectPersister.class);
103     underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, analysisMetadataHolder, branchPersister, projectPersister);
104   }
105
106   @Override
107   protected ComputationStep step() {
108     return underTest;
109   }
110
111   @Test
112   public void persist_empty_view() {
113     treeRootHolder.setRoot(createViewBuilder(PORTFOLIO).build());
114
115     underTest.execute(new TestComputationStepContext());
116
117     assertRowsCountInTableProjects(1);
118
119     ComponentDto projectDto = getComponentFromDb(VIEW_KEY);
120     assertDtoIsView(projectDto);
121   }
122
123   @Test
124   public void persist_existing_empty_view() {
125     // most of the time view already exists since its supposed to be created when config is uploaded
126     persistComponents(newViewDto());
127
128     treeRootHolder.setRoot(createViewBuilder(PORTFOLIO).build());
129
130     underTest.execute(new TestComputationStepContext());
131
132     assertRowsCountInTableProjects(1);
133
134     assertDtoNotUpdated(VIEW_KEY);
135   }
136
137   @Test
138   public void persist_view_with_projectView() {
139     ComponentDto project = ComponentTesting.newPrivateProjectDto();
140     persistComponents(project);
141
142     treeRootHolder.setRoot(
143       createViewBuilder(PORTFOLIO)
144         .addChildren(createProjectView1Builder(project, null).build())
145         .build());
146
147     underTest.execute(new TestComputationStepContext());
148
149     assertRowsCountInTableProjects(3);
150
151     ComponentDto viewDto = getComponentFromDb(VIEW_KEY);
152     assertDtoIsView(viewDto);
153
154     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
155     assertDtoIsProjectView1(pv1Dto, viewDto, viewDto, project);
156   }
157
158   @Test
159   public void persist_application_with_projectView() {
160     ComponentDto project = ComponentTesting.newPrivateProjectDto();
161     persistComponents(project);
162
163     treeRootHolder.setRoot(
164       createViewBuilder(APPLICATION)
165         .addChildren(createProjectView1Builder(project, null).build())
166         .build());
167
168     underTest.execute(new TestComputationStepContext());
169
170     assertRowsCountInTableProjects(3);
171
172     ComponentDto applicationDto = getComponentFromDb(VIEW_KEY);
173     assertDtoIsApplication(applicationDto);
174
175     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
176     assertDtoIsProjectView1(pv1Dto, applicationDto, applicationDto, project);
177   }
178
179   @Test
180   public void persist_empty_subview() {
181     treeRootHolder.setRoot(
182       createViewBuilder(PORTFOLIO)
183         .addChildren(
184           createSubView1Builder(null).build())
185         .build());
186
187     underTest.execute(new TestComputationStepContext());
188
189     assertRowsCountInTableProjects(2);
190
191     ComponentDto viewDto = getComponentFromDb(VIEW_KEY);
192     assertDtoIsView(viewDto);
193
194     ComponentDto sv1Dto = getComponentFromDb(SUBVIEW_1_KEY);
195     assertDtoIsSubView1(viewDto, sv1Dto);
196   }
197
198   @Test
199   public void persist_empty_subview_having_original_view_uuid() {
200     treeRootHolder.setRoot(
201       createViewBuilder(PORTFOLIO)
202         .addChildren(
203           createSubView1Builder("ORIGINAL_UUID").build())
204         .build());
205
206     underTest.execute(new TestComputationStepContext());
207
208     assertRowsCountInTableProjects(2);
209
210     ComponentDto subView = getComponentFromDb(SUBVIEW_1_KEY);
211     assertThat(subView.getCopyComponentUuid()).isEqualTo("ORIGINAL_UUID");
212   }
213
214   @Test
215   public void persist_existing_empty_subview_under_existing_view() {
216     ComponentDto viewDto = newViewDto();
217     persistComponents(viewDto);
218     persistComponents(ComponentTesting.newSubPortfolio(viewDto, SUBVIEW_1_UUID, SUBVIEW_1_KEY).setName(SUBVIEW_1_NAME));
219
220     treeRootHolder.setRoot(
221       createViewBuilder(PORTFOLIO)
222         .addChildren(
223           createSubView1Builder(null).build())
224         .build());
225
226     underTest.execute(new TestComputationStepContext());
227
228     assertRowsCountInTableProjects(2);
229
230     assertDtoNotUpdated(VIEW_KEY);
231     assertDtoNotUpdated(SUBVIEW_1_KEY);
232   }
233
234   @Test
235   public void persist_empty_subview_under_existing_view() {
236     persistComponents(newViewDto());
237
238     treeRootHolder.setRoot(
239       createViewBuilder(PORTFOLIO)
240         .addChildren(
241           createSubView1Builder(null).build())
242         .build());
243
244     underTest.execute(new TestComputationStepContext());
245
246     assertRowsCountInTableProjects(2);
247
248     assertDtoNotUpdated(VIEW_KEY);
249     assertDtoIsSubView1(getComponentFromDb(VIEW_KEY), getComponentFromDb(SUBVIEW_1_KEY));
250   }
251
252   @Test
253   public void persist_project_view_under_subview() {
254     ComponentDto project = ComponentTesting.newPrivateProjectDto();
255     persistComponents(project);
256
257     treeRootHolder.setRoot(
258       createViewBuilder(PORTFOLIO)
259         .addChildren(
260           createSubView1Builder(null)
261             .addChildren(
262               createProjectView1Builder(project, null).build())
263             .build())
264         .build());
265
266     underTest.execute(new TestComputationStepContext());
267
268     assertRowsCountInTableProjects(4);
269
270     ComponentDto viewDto = getComponentFromDb(VIEW_KEY);
271     assertDtoIsView(viewDto);
272     ComponentDto subView1Dto = getComponentFromDb(SUBVIEW_1_KEY);
273     assertDtoIsSubView1(viewDto, subView1Dto);
274     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
275     assertDtoIsProjectView1(pv1Dto, viewDto, subView1Dto, project);
276   }
277
278   @Test
279   public void update_view_name_and_longName() {
280     ComponentDto viewDto = newViewDto().setLongName("another long name").setCreatedAt(now);
281     persistComponents(viewDto);
282
283     treeRootHolder.setRoot(createViewBuilder(PORTFOLIO).build());
284
285     underTest.execute(new TestComputationStepContext());
286
287     // commit functional transaction -> copies B-fields to A-fields
288     dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), viewDto.uuid());
289     dbTester.commit();
290
291     assertRowsCountInTableProjects(1);
292     ComponentDto newViewDto = getComponentFromDb(VIEW_KEY);
293     assertDtoIsView(newViewDto);
294   }
295
296   @Test
297   public void update_project_view() {
298     ComponentDto view = newViewDto();
299     ComponentDto project = ComponentTesting.newPrivateProjectDto();
300     persistComponents(view, project);
301     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view)
302       .setKey(PROJECT_VIEW_1_KEY)
303       .setName("Old name")
304       .setCreatedAt(now);
305     persistComponents(projectView);
306
307     treeRootHolder.setRoot(
308       createViewBuilder(PORTFOLIO)
309         .addChildren(createProjectView1Builder(project, null).build())
310         .build());
311
312     underTest.execute(new TestComputationStepContext());
313
314     // commit functional transaction -> copies B-fields to A-fields
315     dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
316     dbTester.commit();
317
318     assertRowsCountInTableProjects(3);
319     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
320     assertDtoIsProjectView1(pv1Dto, view, view, project);
321   }
322
323   @Test
324   public void update_copy_component_uuid_of_project_view() {
325     ComponentDto view = newViewDto();
326     ComponentDto project1 = newPrivateProjectDto("P1");
327     ComponentDto project2 = newPrivateProjectDto("P2");
328     persistComponents(view, project1, project2);
329
330     // Project view in DB is associated to project1
331     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view)
332       .setKey(PROJECT_VIEW_1_KEY)
333       .setCreatedAt(now);
334     persistComponents(projectView);
335
336     treeRootHolder.setRoot(
337       createViewBuilder(PORTFOLIO)
338         // Project view in the View is linked to the first project2
339         .addChildren(createProjectView1Builder(project2, null).build())
340         .build());
341
342     underTest.execute(new TestComputationStepContext());
343
344     // commit functional transaction -> copies B-fields to A-fields
345     dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
346     dbTester.commit();
347
348     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
349     // Project view should now be linked to project2
350     assertDtoIsProjectView1(pv1Dto, view, view, project2);
351   }
352
353   @Test
354   public void update_copy_component_uuid_of_sub_view() {
355     ComponentDto view = newViewDto();
356     ComponentDto subView = newSubViewDto(view).setCopyComponentUuid("OLD_COPY");
357     persistComponents(view, subView);
358
359     treeRootHolder.setRoot(
360       createViewBuilder(PORTFOLIO)
361         .addChildren(
362           createSubView1Builder("NEW_COPY").build())
363         .build());
364
365     underTest.execute(new TestComputationStepContext());
366
367     // commit functional transaction -> copies B-fields to A-fields
368     dbClient.componentDao().applyBChangesForRootComponentUuid(dbTester.getSession(), view.uuid());
369     dbTester.commit();
370
371     ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY);
372     assertThat(subViewReloaded.getCopyComponentUuid()).isEqualTo("NEW_COPY");
373   }
374
375   @Test
376   public void persists_new_components_as_public_if_root_does_not_exist_yet_out_of_functional_transaction() {
377     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
378     treeRootHolder.setRoot(
379       createViewBuilder(PORTFOLIO)
380         .addChildren(
381           createSubView1Builder(null)
382             .addChildren(
383               createProjectView1Builder(project, null).build())
384             .build())
385         .build());
386
387     underTest.execute(new TestComputationStepContext());
388
389     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
390       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate()).isFalse());
391   }
392
393   @Test
394   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
395     boolean isRootPrivate = new Random().nextBoolean();
396     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
397     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
398     dbTester.components().insertComponent(view);
399     treeRootHolder.setRoot(
400       createViewBuilder(PORTFOLIO)
401         .addChildren(
402           createSubView1Builder(null)
403             .addChildren(
404               createProjectView1Builder(project, null).build())
405             .build())
406         .build());
407
408     underTest.execute(new TestComputationStepContext());
409
410     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
411       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
412         .describedAs("for uuid " + uuid)
413         .isEqualTo(isRootPrivate));
414   }
415
416   @Test
417   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
418     boolean isRootPrivate = new Random().nextBoolean();
419     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
420     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
421     dbTester.components().insertComponent(view);
422     ComponentDto subView = newSubPortfolio(view).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
423     dbTester.components().insertComponent(subView);
424     dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setKey("DIR").setPrivate(isRootPrivate));
425     treeRootHolder.setRoot(
426       createViewBuilder(PORTFOLIO)
427         .addChildren(
428           createSubView1Builder(null)
429             .addChildren(
430               createProjectView1Builder(project, null).build())
431             .build())
432         .build());
433
434     underTest.execute(new TestComputationStepContext());
435
436     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID, subView.uuid(), "DEFG")
437       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
438         .describedAs("for uuid " + uuid)
439         .isEqualTo(isRootPrivate));
440   }
441
442   private static ViewsComponent.Builder createViewBuilder(ViewAttributes.Type viewType) {
443     return builder(Component.Type.VIEW, VIEW_KEY)
444       .setUuid(VIEW_UUID)
445       .setName(VIEW_NAME)
446       .setDescription(VIEW_DESCRIPTION)
447       .setViewAttributes(new ViewAttributes(viewType));
448   }
449
450   private ViewsComponent.Builder createSubView1Builder(@Nullable String originalViewUuid) {
451     return builder(Component.Type.SUBVIEW, SUBVIEW_1_KEY)
452       .setUuid(SUBVIEW_1_UUID)
453       .setName(SUBVIEW_1_NAME)
454       .setDescription(SUBVIEW_1_DESCRIPTION)
455       .setSubViewAttributes(new SubViewAttributes(originalViewUuid));
456   }
457
458   private static ViewsComponent.Builder createProjectView1Builder(ComponentDto project, Long analysisDate) {
459     return builder(Component.Type.PROJECT_VIEW, PROJECT_VIEW_1_KEY)
460       .setUuid(PROJECT_VIEW_1_UUID)
461       .setName(PROJECT_VIEW_1_NAME)
462       .setDescription("project view description is not persisted")
463       .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, null));
464   }
465
466   private void persistComponents(ComponentDto... componentDtos) {
467     componentDbTester.insertComponents(componentDtos);
468   }
469
470   private ComponentDto getComponentFromDb(String componentKey) {
471     return dbClient.componentDao().selectByKey(dbTester.getSession(), componentKey).get();
472   }
473
474   private void assertRowsCountInTableProjects(int rowCount) {
475     assertThat(dbTester.countRowsOfTable("components")).isEqualTo(rowCount);
476   }
477
478   private void assertDtoNotUpdated(String componentKey) {
479     assertThat(getComponentFromDb(componentKey).getCreatedAt()).isNotEqualTo(now);
480   }
481
482   private ComponentDto newViewDto() {
483     return ComponentTesting.newPortfolio(VIEW_UUID)
484       .setKey(VIEW_KEY)
485       .setName(VIEW_NAME);
486   }
487
488   private ComponentDto newSubViewDto(ComponentDto rootView) {
489     return ComponentTesting.newSubPortfolio(rootView, SUBVIEW_1_UUID, SUBVIEW_1_KEY)
490       .setName(SUBVIEW_1_NAME);
491   }
492
493   /**
494    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
495    */
496   private void assertDtoIsView(ComponentDto dto) {
497     assertThat(dto.name()).isEqualTo(VIEW_NAME);
498     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
499     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
500     assertThat(dto.path()).isNull();
501     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
502     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
503     assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
504     assertThat(dto.moduleUuid()).isNull();
505     assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + ".");
506     assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
507     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
508     assertThat(dto.getCopyComponentUuid()).isNull();
509     assertThat(dto.getCreatedAt()).isEqualTo(now);
510   }
511
512   /**
513    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
514    */
515   private void assertDtoIsApplication(ComponentDto dto) {
516     assertThat(dto.name()).isEqualTo(VIEW_NAME);
517     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
518     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
519     assertThat(dto.path()).isNull();
520     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
521     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
522     assertThat(dto.getRootUuid()).isEqualTo(VIEW_UUID);
523     assertThat(dto.moduleUuid()).isNull();
524     assertThat(dto.moduleUuidPath()).isEqualTo("." + dto.uuid() + ".");
525     assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
526     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
527     assertThat(dto.getCopyComponentUuid()).isNull();
528     assertThat(dto.getCreatedAt()).isEqualTo(now);
529   }
530
531   /**
532    * Assertions to verify the DTO created from {@link #createProjectView1Builder(ComponentDto, Long)}
533    */
534   private void assertDtoIsSubView1(ComponentDto viewDto, ComponentDto sv1Dto) {
535     assertThat(sv1Dto.name()).isEqualTo(SUBVIEW_1_NAME);
536     assertThat(sv1Dto.longName()).isEqualTo(SUBVIEW_1_NAME);
537     assertThat(sv1Dto.description()).isEqualTo(SUBVIEW_1_DESCRIPTION);
538     assertThat(sv1Dto.path()).isNull();
539     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
540     assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
541     assertThat(sv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
542     assertThat(sv1Dto.moduleUuid()).isEqualTo(viewDto.uuid());
543     assertThat(sv1Dto.moduleUuidPath()).isEqualTo(viewDto.moduleUuidPath() + sv1Dto.uuid() + ".");
544     assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
545     assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
546     assertThat(sv1Dto.getCopyComponentUuid()).isNull();
547     assertThat(sv1Dto.getCreatedAt()).isEqualTo(now);
548   }
549
550   private void assertDtoIsProjectView1(ComponentDto pv1Dto, ComponentDto viewDto, ComponentDto parentViewDto, ComponentDto project) {
551     assertThat(pv1Dto.name()).isEqualTo(PROJECT_VIEW_1_NAME);
552     assertThat(pv1Dto.longName()).isEqualTo(PROJECT_VIEW_1_NAME);
553     assertThat(pv1Dto.description()).isNull();
554     assertThat(pv1Dto.path()).isNull();
555     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
556     assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
557     assertThat(pv1Dto.getRootUuid()).isEqualTo(viewDto.uuid());
558     assertThat(pv1Dto.moduleUuid()).isEqualTo(parentViewDto.uuid());
559     assertThat(pv1Dto.moduleUuidPath()).isEqualTo(parentViewDto.moduleUuidPath() + pv1Dto.uuid() + ".");
560     assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
561     assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
562     assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
563     assertThat(pv1Dto.getCreatedAt()).isEqualTo(now);
564   }
565
566 }