]> source.dussan.org Git - sonarqube.git/blob
5aa74cf95ad63f447051b524c203ed1f0bc3ad23
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2024 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.component.BranchPersister;
34 import org.sonar.ce.task.projectanalysis.component.Component;
35 import org.sonar.ce.task.projectanalysis.component.MutableDisabledComponentsHolder;
36 import org.sonar.ce.task.projectanalysis.component.ProjectPersister;
37 import org.sonar.ce.task.projectanalysis.component.ProjectViewAttributes;
38 import org.sonar.ce.task.projectanalysis.component.SubViewAttributes;
39 import org.sonar.ce.task.projectanalysis.component.TreeRootHolderRule;
40 import org.sonar.ce.task.projectanalysis.component.ViewAttributes;
41 import org.sonar.ce.task.projectanalysis.component.ViewsComponent;
42 import org.sonar.ce.task.projectanalysis.component.VisitException;
43 import org.sonar.ce.task.step.ComputationStep;
44 import org.sonar.ce.task.step.TestComputationStepContext;
45 import org.sonar.db.DbClient;
46 import org.sonar.db.DbTester;
47 import org.sonar.db.audit.AuditPersister;
48 import org.sonar.db.component.ComponentDto;
49 import org.sonar.db.component.ComponentTesting;
50
51 import static org.assertj.core.api.Assertions.assertThat;
52 import static org.assertj.core.api.Assertions.assertThatThrownBy;
53 import static org.mockito.ArgumentMatchers.any;
54 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
55 import static org.mockito.Mockito.mock;
56 import static org.mockito.Mockito.times;
57 import static org.mockito.Mockito.verify;
58 import static org.mockito.Mockito.when;
59 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.APPLICATION;
60 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.PORTFOLIO;
61 import static org.sonar.ce.task.projectanalysis.component.ViewsComponent.builder;
62 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
63 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
64 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
65
66 public class ViewsPersistComponentsStepIT extends BaseStepTest {
67
68   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
69
70   private static final String VIEW_KEY = "VIEW_KEY";
71   private static final String VIEW_NAME = "VIEW_NAME";
72   private static final String VIEW_DESCRIPTION = "view description";
73   private static final String VIEW_UUID = "VIEW_UUID";
74   private static final String SUBVIEW_1_KEY = "SUBVIEW_1_KEY";
75   private static final String SUBVIEW_1_NAME = "SUBVIEW_1_NAME";
76   private static final String SUBVIEW_1_DESCRIPTION = "subview 1 description";
77   private static final String SUBVIEW_1_UUID = "SUBVIEW_1_UUID";
78   private static final String PROJECT_VIEW_1_KEY = "PV1_KEY";
79   private static final String PROJECT_VIEW_1_NAME = "PV1_NAME";
80   private static final String PROJECT_VIEW_1_UUID = "PV1_UUID";
81
82   private final AuditPersister auditPersister = mock();
83
84   @Rule
85   public DbTester dbTester = DbTester.create(System2.INSTANCE, auditPersister);
86
87   @Rule
88   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
89
90   private final System2 system2 = mock(System2.class);
91   private final DbClient dbClient = dbTester.getDbClient();
92   private Date now;
93   private final MutableDisabledComponentsHolder disabledComponentsHolder = mock(MutableDisabledComponentsHolder.class, RETURNS_DEEP_STUBS);
94   private PersistComponentsStep underTest;
95
96   @Before
97   public void setup() throws Exception {
98     now = DATE_FORMAT.parse("2015-06-02");
99     when(system2.now()).thenReturn(now.getTime());
100
101     BranchPersister branchPersister = mock(BranchPersister.class);
102     ProjectPersister projectPersister = mock(ProjectPersister.class);
103     underTest = new PersistComponentsStep(dbClient, treeRootHolder, system2, disabledComponentsHolder, 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     assertRowsCountInTableComponents(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     assertRowsCountInTableComponents(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     assertRowsCountInTableComponents(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   /**
159    * Assumption under test here is that application should always exists in the projects table.
160    * We should never have a state where application exists in Components table but not in Projects table
161    */
162   @Test
163   public void execute_whenApplicationDoesNotExistsAndTryingToInsertItInComponentsTable_throwException() {
164     ComponentDto project = dbTester.components().insertPrivateProject().getMainBranchComponent();
165
166     treeRootHolder.setRoot(
167       createViewBuilder(APPLICATION)
168         .addChildren(createProjectView1Builder(project, null).build())
169         .build());
170
171     assertThatThrownBy(() -> underTest.execute(new TestComputationStepContext()))
172       .isInstanceOf(VisitException.class);
173   }
174
175   @Test
176   public void persist_empty_subview() {
177     treeRootHolder.setRoot(
178       createViewBuilder(PORTFOLIO)
179         .addChildren(
180           createSubView1Builder(null).build())
181         .build());
182
183     underTest.execute(new TestComputationStepContext());
184
185     assertRowsCountInTableComponents(2);
186
187     ComponentDto viewDto = getComponentFromDb(VIEW_KEY);
188     assertDtoIsView(viewDto);
189
190     ComponentDto sv1Dto = getComponentFromDb(SUBVIEW_1_KEY);
191     assertDtoIsSubView1(viewDto, sv1Dto);
192   }
193
194   @Test
195   public void persist_empty_subview_having_original_view_uuid() {
196     treeRootHolder.setRoot(
197       createViewBuilder(PORTFOLIO)
198         .addChildren(
199           createSubView1Builder("ORIGINAL_UUID").build())
200         .build());
201
202     underTest.execute(new TestComputationStepContext());
203
204     assertRowsCountInTableComponents(2);
205
206     ComponentDto subView = getComponentFromDb(SUBVIEW_1_KEY);
207     assertThat(subView.getCopyComponentUuid()).isEqualTo("ORIGINAL_UUID");
208   }
209
210   @Test
211   public void persist_existing_empty_subview_under_existing_view() {
212     ComponentDto viewDto = newViewDto();
213     persistComponents(viewDto);
214     persistComponents(ComponentTesting.newSubPortfolio(viewDto, SUBVIEW_1_UUID, SUBVIEW_1_KEY).setName(SUBVIEW_1_NAME));
215
216     treeRootHolder.setRoot(
217       createViewBuilder(PORTFOLIO)
218         .addChildren(
219           createSubView1Builder(null).build())
220         .build());
221
222     underTest.execute(new TestComputationStepContext());
223
224     assertRowsCountInTableComponents(2);
225
226     assertDtoNotUpdated(VIEW_KEY);
227     assertDtoNotUpdated(SUBVIEW_1_KEY);
228   }
229
230   @Test
231   public void persist_empty_subview_under_existing_view() {
232     persistComponents(newViewDto());
233
234     treeRootHolder.setRoot(
235       createViewBuilder(PORTFOLIO)
236         .addChildren(
237           createSubView1Builder(null).build())
238         .build());
239
240     underTest.execute(new TestComputationStepContext());
241
242     assertRowsCountInTableComponents(2);
243
244     assertDtoNotUpdated(VIEW_KEY);
245     assertDtoIsSubView1(getComponentFromDb(VIEW_KEY), getComponentFromDb(SUBVIEW_1_KEY));
246   }
247
248   @Test
249   public void persist_project_view_under_subview() {
250     ComponentDto project = ComponentTesting.newPrivateProjectDto();
251     persistComponents(project);
252
253     treeRootHolder.setRoot(
254       createViewBuilder(PORTFOLIO)
255         .addChildren(
256           createSubView1Builder(null)
257             .addChildren(
258               createProjectView1Builder(project, null).build())
259             .build())
260         .build());
261
262     underTest.execute(new TestComputationStepContext());
263
264     assertRowsCountInTableComponents(4);
265
266     ComponentDto viewDto = getComponentFromDb(VIEW_KEY);
267     assertDtoIsView(viewDto);
268     ComponentDto subView1Dto = getComponentFromDb(SUBVIEW_1_KEY);
269     assertDtoIsSubView1(viewDto, subView1Dto);
270     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
271     assertDtoIsProjectView1(pv1Dto, viewDto, subView1Dto, project);
272   }
273
274   @Test
275   public void update_view_name_and_longName() {
276     ComponentDto viewDto = newViewDto().setLongName("another long name").setCreatedAt(now);
277     persistComponents(viewDto);
278
279     treeRootHolder.setRoot(createViewBuilder(PORTFOLIO).build());
280
281     underTest.execute(new TestComputationStepContext());
282
283     // commit functional transaction -> copies B-fields to A-fields
284     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), viewDto.uuid());
285     dbTester.commit();
286
287     assertRowsCountInTableComponents(1);
288     ComponentDto newViewDto = getComponentFromDb(VIEW_KEY);
289     assertDtoIsView(newViewDto);
290   }
291
292   @Test
293   public void update_project_view() {
294     ComponentDto view = newViewDto();
295     ComponentDto project = ComponentTesting.newPrivateProjectDto();
296     persistComponents(view, project);
297     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project, view)
298       .setKey(PROJECT_VIEW_1_KEY)
299       .setName("Old name")
300       .setCreatedAt(now);
301     persistComponents(projectView);
302     treeRootHolder.setRoot(
303       createViewBuilder(PORTFOLIO)
304         .addChildren(createProjectView1Builder(project, null).build())
305         .build());
306     underTest.execute(new TestComputationStepContext());
307     // commit functional transaction -> copies B-fields to A-fields
308     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
309     dbTester.commit();
310
311     assertRowsCountInTableComponents(3);
312     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
313     assertDtoIsProjectView1(pv1Dto, view, view, project);
314   }
315
316   @Test
317   public void execute_whenPortfolioProjectAndTechnicalProjectIsCreated_shouldStoreTwoAuditLogs() {
318     ComponentDto view = newViewDto();
319     ComponentDto project = ComponentTesting.newPrivateProjectDto();
320     persistComponents(view, project);
321
322     treeRootHolder.setRoot(
323       createViewBuilder(PORTFOLIO)
324         .addChildren(createProjectView1Builder(project, null).build())
325         .build());
326
327     underTest.execute(new TestComputationStepContext());
328
329     //We create audits for the portfolio and the project, not for the technical project
330     verify(auditPersister, times(2)).addComponent(any(), any());
331   }
332
333   @Test
334   public void update_copy_component_uuid_of_project_view() {
335     ComponentDto view = newViewDto();
336     ComponentDto project1 = newPrivateProjectDto("P1");
337     ComponentDto project2 = newPrivateProjectDto("P2");
338     persistComponents(view, project1, project2);
339
340     // Project view in DB is associated to project1
341     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view)
342       .setKey(PROJECT_VIEW_1_KEY)
343       .setCreatedAt(now);
344     persistComponents(projectView);
345
346     treeRootHolder.setRoot(
347       createViewBuilder(PORTFOLIO)
348         // Project view in the View is linked to the first project2
349         .addChildren(createProjectView1Builder(project2, null).build())
350         .build());
351
352     underTest.execute(new TestComputationStepContext());
353
354     // commit functional transaction -> copies B-fields to A-fields
355     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
356     dbTester.commit();
357
358     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
359     // Project view should now be linked to project2
360     assertDtoIsProjectView1(pv1Dto, view, view, project2);
361   }
362
363   @Test
364   public void update_copy_component_uuid_of_sub_view() {
365     ComponentDto view = newViewDto();
366     ComponentDto subView = newSubViewDto(view).setCopyComponentUuid("OLD_COPY");
367     persistComponents(view, subView);
368
369     treeRootHolder.setRoot(
370       createViewBuilder(PORTFOLIO)
371         .addChildren(
372           createSubView1Builder("NEW_COPY").build())
373         .build());
374
375     underTest.execute(new TestComputationStepContext());
376
377     // commit functional transaction -> copies B-fields to A-fields
378     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
379     dbTester.commit();
380
381     ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY);
382     assertThat(subViewReloaded.getCopyComponentUuid()).isEqualTo("NEW_COPY");
383   }
384
385   @Test
386   public void persists_new_components_as_public_if_root_does_not_exist_yet_out_of_functional_transaction() {
387     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
388     treeRootHolder.setRoot(
389       createViewBuilder(PORTFOLIO)
390         .addChildren(
391           createSubView1Builder(null)
392             .addChildren(
393               createProjectView1Builder(project, null).build())
394             .build())
395         .build());
396
397     underTest.execute(new TestComputationStepContext());
398
399     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
400       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate()).isFalse());
401   }
402
403   @Test
404   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
405     boolean isRootPrivate = new Random().nextBoolean();
406     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
407     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
408     dbTester.components().insertComponent(view);
409     treeRootHolder.setRoot(
410       createViewBuilder(PORTFOLIO)
411         .addChildren(
412           createSubView1Builder(null)
413             .addChildren(
414               createProjectView1Builder(project, null).build())
415             .build())
416         .build());
417
418     underTest.execute(new TestComputationStepContext());
419
420     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
421       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
422         .describedAs("for uuid " + uuid)
423         .isEqualTo(isRootPrivate));
424   }
425
426   @Test
427   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
428     boolean isRootPrivate = new Random().nextBoolean();
429     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
430     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
431     dbTester.components().insertComponent(view);
432     ComponentDto subView = newSubPortfolio(view).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
433     dbTester.components().insertComponent(subView);
434     dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setKey("DIR").setPrivate(isRootPrivate));
435     treeRootHolder.setRoot(
436       createViewBuilder(PORTFOLIO)
437         .addChildren(
438           createSubView1Builder(null)
439             .addChildren(
440               createProjectView1Builder(project, null).build())
441             .build())
442         .build());
443
444     underTest.execute(new TestComputationStepContext());
445
446     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID, subView.uuid(), "DEFG")
447       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
448         .describedAs("for uuid " + uuid)
449         .isEqualTo(isRootPrivate));
450   }
451
452   private static ViewsComponent.Builder createViewBuilder(ViewAttributes.Type viewType) {
453     return builder(Component.Type.VIEW, VIEW_KEY)
454       .setUuid(VIEW_UUID)
455       .setName(VIEW_NAME)
456       .setDescription(VIEW_DESCRIPTION)
457       .setViewAttributes(new ViewAttributes(viewType));
458   }
459
460   private ViewsComponent.Builder createSubView1Builder(@Nullable String originalViewUuid) {
461     return builder(Component.Type.SUBVIEW, SUBVIEW_1_KEY)
462       .setUuid(SUBVIEW_1_UUID)
463       .setName(SUBVIEW_1_NAME)
464       .setDescription(SUBVIEW_1_DESCRIPTION)
465       .setSubViewAttributes(new SubViewAttributes(originalViewUuid));
466   }
467
468   private static ViewsComponent.Builder createProjectView1Builder(ComponentDto project, Long analysisDate) {
469     return builder(Component.Type.PROJECT_VIEW, PROJECT_VIEW_1_KEY)
470       .setUuid(PROJECT_VIEW_1_UUID)
471       .setName(PROJECT_VIEW_1_NAME)
472       .setDescription("project view description is not persisted")
473       .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, null));
474   }
475
476   private void persistComponents(ComponentDto... componentDtos) {
477     dbTester.components().insertComponents(componentDtos);
478   }
479
480   private ComponentDto getComponentFromDb(String componentKey) {
481     return dbClient.componentDao().selectByKey(dbTester.getSession(), componentKey).get();
482   }
483
484   private void assertRowsCountInTableComponents(int rowCount) {
485     assertThat(dbTester.countRowsOfTable("components")).isEqualTo(rowCount);
486   }
487
488   private void assertDtoNotUpdated(String componentKey) {
489     assertThat(getComponentFromDb(componentKey).getCreatedAt()).isNotEqualTo(now);
490   }
491
492   private ComponentDto newViewDto() {
493     return ComponentTesting.newPortfolio(VIEW_UUID)
494       .setKey(VIEW_KEY)
495       .setName(VIEW_NAME);
496   }
497
498   private ComponentDto newSubViewDto(ComponentDto rootView) {
499     return ComponentTesting.newSubPortfolio(rootView, SUBVIEW_1_UUID, SUBVIEW_1_KEY)
500       .setName(SUBVIEW_1_NAME);
501   }
502
503   /**
504    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
505    */
506   private void assertDtoIsView(ComponentDto dto) {
507     assertThat(dto.name()).isEqualTo(VIEW_NAME);
508     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
509     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
510     assertThat(dto.path()).isNull();
511     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
512     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
513     assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
514     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
515     assertThat(dto.getCopyComponentUuid()).isNull();
516     assertThat(dto.getCreatedAt()).isEqualTo(now);
517   }
518
519   /**
520    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
521    */
522   private void assertDtoIsApplication(ComponentDto dto) {
523     assertThat(dto.name()).isEqualTo(VIEW_NAME);
524     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
525     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
526     assertThat(dto.path()).isNull();
527     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
528     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
529     assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
530     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
531     assertThat(dto.getCopyComponentUuid()).isNull();
532     assertThat(dto.getCreatedAt()).isEqualTo(now);
533   }
534
535   /**
536    * Assertions to verify the DTO created from {@link #createProjectView1Builder(ComponentDto, Long)}
537    */
538   private void assertDtoIsSubView1(ComponentDto viewDto, ComponentDto sv1Dto) {
539     assertThat(sv1Dto.name()).isEqualTo(SUBVIEW_1_NAME);
540     assertThat(sv1Dto.longName()).isEqualTo(SUBVIEW_1_NAME);
541     assertThat(sv1Dto.description()).isEqualTo(SUBVIEW_1_DESCRIPTION);
542     assertThat(sv1Dto.path()).isNull();
543     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
544     assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
545     assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
546     assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
547     assertThat(sv1Dto.getCopyComponentUuid()).isNull();
548     assertThat(sv1Dto.getCreatedAt()).isEqualTo(now);
549   }
550
551   private void assertDtoIsProjectView1(ComponentDto pv1Dto, ComponentDto viewDto, ComponentDto parentViewDto, ComponentDto project) {
552     assertThat(pv1Dto.name()).isEqualTo(PROJECT_VIEW_1_NAME);
553     assertThat(pv1Dto.longName()).isEqualTo(PROJECT_VIEW_1_NAME);
554     assertThat(pv1Dto.description()).isNull();
555     assertThat(pv1Dto.path()).isNull();
556     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
557     assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
558     assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
559     assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
560     assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
561     assertThat(pv1Dto.getCreatedAt()).isEqualTo(now);
562   }
563
564 }