]> source.dussan.org Git - sonarqube.git/blob
1972a83bb760b8eef4fc88fe6d4d50adaa89fbbf
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2023 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.projectanalysis.component.VisitException;
45 import org.sonar.ce.task.step.ComputationStep;
46 import org.sonar.ce.task.step.TestComputationStepContext;
47 import org.sonar.db.DbClient;
48 import org.sonar.db.DbTester;
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.assertj.core.api.Assertions.assertThatThrownBy;
54 import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
55 import static org.mockito.Mockito.mock;
56 import static org.mockito.Mockito.when;
57 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.APPLICATION;
58 import static org.sonar.ce.task.projectanalysis.component.ViewAttributes.Type.PORTFOLIO;
59 import static org.sonar.ce.task.projectanalysis.component.ViewsComponent.builder;
60 import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
61 import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto;
62 import static org.sonar.db.component.ComponentTesting.newProjectCopy;
63 import static org.sonar.db.component.ComponentTesting.newSubPortfolio;
64
65 public class ViewsPersistComponentsStepIT extends BaseStepTest {
66
67   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
68
69   private static final String VIEW_KEY = "VIEW_KEY";
70   private static final String VIEW_NAME = "VIEW_NAME";
71   private static final String VIEW_DESCRIPTION = "view description";
72   private static final String VIEW_UUID = "VIEW_UUID";
73   private static final String SUBVIEW_1_KEY = "SUBVIEW_1_KEY";
74   private static final String SUBVIEW_1_NAME = "SUBVIEW_1_NAME";
75   private static final String SUBVIEW_1_DESCRIPTION = "subview 1 description";
76   private static final String SUBVIEW_1_UUID = "SUBVIEW_1_UUID";
77   private static final String PROJECT_VIEW_1_KEY = "PV1_KEY";
78   private static final String PROJECT_VIEW_1_NAME = "PV1_NAME";
79   private static final String PROJECT_VIEW_1_UUID = "PV1_UUID";
80
81   @Rule
82   public DbTester dbTester = DbTester.create(System2.INSTANCE);
83
84   @Rule
85   public TreeRootHolderRule treeRootHolder = new TreeRootHolderRule();
86   @Rule
87   public AnalysisMetadataHolderRule analysisMetadataHolder = new AnalysisMetadataHolderRule();
88
89   private final System2 system2 = mock(System2.class);
90   private final DbClient dbClient = dbTester.getDbClient();
91   private Date now;
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_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     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 update_copy_component_uuid_of_project_view() {
318     ComponentDto view = newViewDto();
319     ComponentDto project1 = newPrivateProjectDto("P1");
320     ComponentDto project2 = newPrivateProjectDto("P2");
321     persistComponents(view, project1, project2);
322
323     // Project view in DB is associated to project1
324     ComponentDto projectView = ComponentTesting.newProjectCopy(PROJECT_VIEW_1_UUID, project1, view)
325       .setKey(PROJECT_VIEW_1_KEY)
326       .setCreatedAt(now);
327     persistComponents(projectView);
328
329     treeRootHolder.setRoot(
330       createViewBuilder(PORTFOLIO)
331         // Project view in the View is linked to the first project2
332         .addChildren(createProjectView1Builder(project2, null).build())
333         .build());
334
335     underTest.execute(new TestComputationStepContext());
336
337     // commit functional transaction -> copies B-fields to A-fields
338     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
339     dbTester.commit();
340
341     ComponentDto pv1Dto = getComponentFromDb(PROJECT_VIEW_1_KEY);
342     // Project view should now be linked to project2
343     assertDtoIsProjectView1(pv1Dto, view, view, project2);
344   }
345
346   @Test
347   public void update_copy_component_uuid_of_sub_view() {
348     ComponentDto view = newViewDto();
349     ComponentDto subView = newSubViewDto(view).setCopyComponentUuid("OLD_COPY");
350     persistComponents(view, subView);
351
352     treeRootHolder.setRoot(
353       createViewBuilder(PORTFOLIO)
354         .addChildren(
355           createSubView1Builder("NEW_COPY").build())
356         .build());
357
358     underTest.execute(new TestComputationStepContext());
359
360     // commit functional transaction -> copies B-fields to A-fields
361     dbClient.componentDao().applyBChangesForBranchUuid(dbTester.getSession(), view.uuid());
362     dbTester.commit();
363
364     ComponentDto subViewReloaded = getComponentFromDb(SUBVIEW_1_KEY);
365     assertThat(subViewReloaded.getCopyComponentUuid()).isEqualTo("NEW_COPY");
366   }
367
368   @Test
369   public void persists_new_components_as_public_if_root_does_not_exist_yet_out_of_functional_transaction() {
370     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
371     treeRootHolder.setRoot(
372       createViewBuilder(PORTFOLIO)
373         .addChildren(
374           createSubView1Builder(null)
375             .addChildren(
376               createProjectView1Builder(project, null).build())
377             .build())
378         .build());
379
380     underTest.execute(new TestComputationStepContext());
381
382     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
383       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate()).isFalse());
384   }
385
386   @Test
387   public void persists_new_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
388     boolean isRootPrivate = new Random().nextBoolean();
389     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
390     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
391     dbTester.components().insertComponent(view);
392     treeRootHolder.setRoot(
393       createViewBuilder(PORTFOLIO)
394         .addChildren(
395           createSubView1Builder(null)
396             .addChildren(
397               createProjectView1Builder(project, null).build())
398             .build())
399         .build());
400
401     underTest.execute(new TestComputationStepContext());
402
403     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID)
404       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
405         .describedAs("for uuid " + uuid)
406         .isEqualTo(isRootPrivate));
407   }
408
409   @Test
410   public void persists_existing_components_with_visibility_of_root_in_db_out_of_functional_transaction() {
411     boolean isRootPrivate = new Random().nextBoolean();
412     ComponentDto project = dbTester.components().insertComponent(ComponentTesting.newPrivateProjectDto());
413     ComponentDto view = newViewDto().setUuid(VIEW_UUID).setKey(VIEW_KEY).setName("View").setPrivate(isRootPrivate);
414     dbTester.components().insertComponent(view);
415     ComponentDto subView = newSubPortfolio(view).setUuid("BCDE").setKey("MODULE").setPrivate(!isRootPrivate);
416     dbTester.components().insertComponent(subView);
417     dbTester.components().insertComponent(newProjectCopy("DEFG", project, view).setKey("DIR").setPrivate(isRootPrivate));
418     treeRootHolder.setRoot(
419       createViewBuilder(PORTFOLIO)
420         .addChildren(
421           createSubView1Builder(null)
422             .addChildren(
423               createProjectView1Builder(project, null).build())
424             .build())
425         .build());
426
427     underTest.execute(new TestComputationStepContext());
428
429     Stream.of(VIEW_UUID, SUBVIEW_1_UUID, PROJECT_VIEW_1_UUID, subView.uuid(), "DEFG")
430       .forEach(uuid -> assertThat(dbClient.componentDao().selectByUuid(dbTester.getSession(), uuid).get().isPrivate())
431         .describedAs("for uuid " + uuid)
432         .isEqualTo(isRootPrivate));
433   }
434
435   private static ViewsComponent.Builder createViewBuilder(ViewAttributes.Type viewType) {
436     return builder(Component.Type.VIEW, VIEW_KEY)
437       .setUuid(VIEW_UUID)
438       .setName(VIEW_NAME)
439       .setDescription(VIEW_DESCRIPTION)
440       .setViewAttributes(new ViewAttributes(viewType));
441   }
442
443   private ViewsComponent.Builder createSubView1Builder(@Nullable String originalViewUuid) {
444     return builder(Component.Type.SUBVIEW, SUBVIEW_1_KEY)
445       .setUuid(SUBVIEW_1_UUID)
446       .setName(SUBVIEW_1_NAME)
447       .setDescription(SUBVIEW_1_DESCRIPTION)
448       .setSubViewAttributes(new SubViewAttributes(originalViewUuid));
449   }
450
451   private static ViewsComponent.Builder createProjectView1Builder(ComponentDto project, Long analysisDate) {
452     return builder(Component.Type.PROJECT_VIEW, PROJECT_VIEW_1_KEY)
453       .setUuid(PROJECT_VIEW_1_UUID)
454       .setName(PROJECT_VIEW_1_NAME)
455       .setDescription("project view description is not persisted")
456       .setProjectViewAttributes(new ProjectViewAttributes(project.uuid(), project.getKey(), analysisDate, null));
457   }
458
459   private void persistComponents(ComponentDto... componentDtos) {
460     dbTester.components().insertComponents(componentDtos);
461   }
462
463   private ComponentDto getComponentFromDb(String componentKey) {
464     return dbClient.componentDao().selectByKey(dbTester.getSession(), componentKey).get();
465   }
466
467   private void assertRowsCountInTableComponents(int rowCount) {
468     assertThat(dbTester.countRowsOfTable("components")).isEqualTo(rowCount);
469   }
470
471   private void assertDtoNotUpdated(String componentKey) {
472     assertThat(getComponentFromDb(componentKey).getCreatedAt()).isNotEqualTo(now);
473   }
474
475   private ComponentDto newViewDto() {
476     return ComponentTesting.newPortfolio(VIEW_UUID)
477       .setKey(VIEW_KEY)
478       .setName(VIEW_NAME);
479   }
480
481   private ComponentDto newSubViewDto(ComponentDto rootView) {
482     return ComponentTesting.newSubPortfolio(rootView, SUBVIEW_1_UUID, SUBVIEW_1_KEY)
483       .setName(SUBVIEW_1_NAME);
484   }
485
486   /**
487    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
488    */
489   private void assertDtoIsView(ComponentDto dto) {
490     assertThat(dto.name()).isEqualTo(VIEW_NAME);
491     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
492     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
493     assertThat(dto.path()).isNull();
494     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
495     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
496     assertThat(dto.qualifier()).isEqualTo(Qualifiers.VIEW);
497     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
498     assertThat(dto.getCopyComponentUuid()).isNull();
499     assertThat(dto.getCreatedAt()).isEqualTo(now);
500   }
501
502   /**
503    * Assertions to verify the DTO created from {@link #createViewBuilder(ViewAttributes.Type)} ()}
504    */
505   private void assertDtoIsApplication(ComponentDto dto) {
506     assertThat(dto.name()).isEqualTo(VIEW_NAME);
507     assertThat(dto.longName()).isEqualTo(VIEW_NAME);
508     assertThat(dto.description()).isEqualTo(VIEW_DESCRIPTION);
509     assertThat(dto.path()).isNull();
510     assertThat(dto.uuid()).isEqualTo(VIEW_UUID);
511     assertThat(dto.branchUuid()).isEqualTo(VIEW_UUID);
512     assertThat(dto.qualifier()).isEqualTo(Qualifiers.APP);
513     assertThat(dto.scope()).isEqualTo(Scopes.PROJECT);
514     assertThat(dto.getCopyComponentUuid()).isNull();
515     assertThat(dto.getCreatedAt()).isEqualTo(now);
516   }
517
518   /**
519    * Assertions to verify the DTO created from {@link #createProjectView1Builder(ComponentDto, Long)}
520    */
521   private void assertDtoIsSubView1(ComponentDto viewDto, ComponentDto sv1Dto) {
522     assertThat(sv1Dto.name()).isEqualTo(SUBVIEW_1_NAME);
523     assertThat(sv1Dto.longName()).isEqualTo(SUBVIEW_1_NAME);
524     assertThat(sv1Dto.description()).isEqualTo(SUBVIEW_1_DESCRIPTION);
525     assertThat(sv1Dto.path()).isNull();
526     assertThat(sv1Dto.uuid()).isEqualTo(SUBVIEW_1_UUID);
527     assertThat(sv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
528     assertThat(sv1Dto.qualifier()).isEqualTo(Qualifiers.SUBVIEW);
529     assertThat(sv1Dto.scope()).isEqualTo(Scopes.PROJECT);
530     assertThat(sv1Dto.getCopyComponentUuid()).isNull();
531     assertThat(sv1Dto.getCreatedAt()).isEqualTo(now);
532   }
533
534   private void assertDtoIsProjectView1(ComponentDto pv1Dto, ComponentDto viewDto, ComponentDto parentViewDto, ComponentDto project) {
535     assertThat(pv1Dto.name()).isEqualTo(PROJECT_VIEW_1_NAME);
536     assertThat(pv1Dto.longName()).isEqualTo(PROJECT_VIEW_1_NAME);
537     assertThat(pv1Dto.description()).isNull();
538     assertThat(pv1Dto.path()).isNull();
539     assertThat(pv1Dto.uuid()).isEqualTo(PROJECT_VIEW_1_UUID);
540     assertThat(pv1Dto.branchUuid()).isEqualTo(viewDto.uuid());
541     assertThat(pv1Dto.qualifier()).isEqualTo(Qualifiers.PROJECT);
542     assertThat(pv1Dto.scope()).isEqualTo(Scopes.FILE);
543     assertThat(pv1Dto.getCopyComponentUuid()).isEqualTo(project.uuid());
544     assertThat(pv1Dto.getCreatedAt()).isEqualTo(now);
545   }
546
547 }