1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
|
/*-
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.openecomp.sdc.ci.tests.execute.sanity;
import com.aventstack.extentreports.Status;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.GroupDefinition;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.ci.tests.datatypes.ArtifactInfo;
import org.openecomp.sdc.ci.tests.datatypes.CanvasElement;
import org.openecomp.sdc.ci.tests.datatypes.CanvasManager;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.CompositionScreenEnum;
import org.openecomp.sdc.ci.tests.datatypes.DataTestIdEnum.ServiceMetadataEnum;
import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
import org.openecomp.sdc.ci.tests.datatypes.ResourceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.ServiceReqDetails;
import org.openecomp.sdc.ci.tests.datatypes.TopMenuButtonsEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ArtifactTypeEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.NormativeTypesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ResourceCategoryEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.ServiceCategoriesEnum;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.ci.tests.execute.setup.SetupCDTest;
import org.openecomp.sdc.ci.tests.pages.CompositionPage;
import org.openecomp.sdc.ci.tests.pages.DeploymentArtifactPage;
import org.openecomp.sdc.ci.tests.pages.DeploymentPage;
import org.openecomp.sdc.ci.tests.pages.GeneralPageElements;
import org.openecomp.sdc.ci.tests.pages.HomePage;
import org.openecomp.sdc.ci.tests.pages.InputsPage;
import org.openecomp.sdc.ci.tests.pages.ResourceGeneralPage;
import org.openecomp.sdc.ci.tests.pages.ServiceGeneralPage;
import org.openecomp.sdc.ci.tests.pages.TesterOperationPage;
import org.openecomp.sdc.ci.tests.utilities.ArtifactUIUtils;
import org.openecomp.sdc.ci.tests.utilities.CatalogUIUtilitis;
import org.openecomp.sdc.ci.tests.utilities.FileHandling;
import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
import org.openecomp.sdc.ci.tests.utilities.ResourceUIUtils;
import org.openecomp.sdc.ci.tests.utilities.ServiceUIUtils;
import org.openecomp.sdc.ci.tests.utils.general.AtomicOperationUtils;
import org.openecomp.sdc.ci.tests.utils.general.ElementFactory;
import org.openecomp.sdc.ci.tests.utils.rest.ResourceRestUtils;
import org.openecomp.sdc.ci.tests.utils.validation.ErrorValidationUtils;
import org.openecomp.sdc.ci.tests.verificator.DeploymentViewVerificator;
import org.openecomp.sdc.ci.tests.verificator.ServiceVerificator;
import org.openecomp.sdc.ci.tests.verificator.VfVerificator;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.AssertJUnit;
import org.testng.TestException;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.awt.AWTException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.AssertJUnit.assertTrue;
public class Service extends SetupCDTest {
private static final String DESCRIPTION = "kuku";
private static final String ARTIFACT_LABEL = "artifact3";
private static final String ARTIFACT_LABEL_UPDATE = "artifactUpdate";
private static final String GET_ARTIFACT_LIST_BY_CLASS_NAME = "i-sdc-designer-sidebar-section-content-item-artifact";
private static final String HEAT_FILE_YAML_NAME = "Heat-File.yaml";
private static final String HEAT_FILE_YAML_UPDATE_NAME = "Heat-File-Update.yaml";
private String filePath;
private static CanvasElement computeElement;
public static CanvasElement getComputeElement() {
return computeElement;
}
@BeforeMethod
public void beforeTest() {
filePath = FileHandling.getFilePath("");
}
@Test
public void createService() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
}
@Test
public void validDefaultContactAndTagAfterCreateService() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser());
assertTrue("wrong userId", getUser().getUserId().equals(ResourceGeneralPage.getContactIdText()));
List<String> actualTags = Arrays.asList(ServiceGeneralPage.getTags());
assertTrue("wrong tags", (actualTags.size() == 1) && actualTags.get(0).equals(serviceMetadata.getName()));
}
@Test
public void updateService() throws Exception {
// Create Service
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
// Update Service
ServiceGeneralPage.deleteOldTags(serviceMetadata);
serviceMetadata.setName(ElementFactory.getServicePrefix() + "UpdatedName" + serviceMetadata.getName());
serviceMetadata.setDescription("updatedDescriptionSanity");
serviceMetadata.setProjectCode("654321");
serviceMetadata.setContactId("cs6543");
serviceMetadata.getTags().addAll(Arrays.asList("updatedTag", "oneMoreUpdatedTag", "lastOne UpdatedTag"));
ServiceUIUtils.setServiceCategory(serviceMetadata, ServiceCategoriesEnum.VOIP);
ServiceUIUtils.fillServiceGeneralPage(serviceMetadata);
GeneralPageElements.clickCreateButton();
ServiceVerificator.verifyServiceUpdatedInUI(serviceMetadata);
}
@Test
public void deleteService() throws Exception {
// create service
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
// Delete service
//GeneralUIUtils.HighlightMyElement(GeneralUIUtils.getWebButton("delete_version"));
GeneralPageElements.clickTrashButtonAndConfirm();
// Verification
CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
CatalogUIUtilitis.catalogSearchBox(serviceMetadata.getName());
ServiceVerificator.verifyServiceDeletedInUI(serviceMetadata);
}
@Test
public void checkoutServiceTest() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER");
CompositionPage.showDeploymentArtifactTab();
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName());
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
GeneralPageElements.clickCheckoutButton();
serviceMetadata.setVersion("0.2");
ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion());
ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.TESTER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
TesterOperationPage.certifyComponent(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.DESIGNER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
ResourceGeneralPage.clickCheckoutButton();
serviceMetadata.setVersion("1.1");
serviceMetadata.setUniqueId(null);
ServiceVerificator.verifyServiceLifecycle(serviceMetadata, getUser(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT);
VfVerificator.verifyVfLifecycleInUI(LifeCycleStateEnum.CHECKOUT);
ServiceVerificator.verifyVersionUI(serviceMetadata.getVersion());
}
@Test
public void submitServiceForTestingWithNonCertifiedAsset() throws Exception {
ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
ResourceUIUtils.createVF(atomicResourceMetaData, getUser());
//TODO Andrey changed to click on ceckIn button
ResourceGeneralPage.clickCheckinButton(atomicResourceMetaData.getName());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
CanvasManager canvasManager = CanvasManager.getCanvasManager();
CompositionPage.searchForElement(atomicResourceMetaData.getName());
canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
try {
CompositionPage.clickSubmitForTestingButton(serviceMetadata.getName());
assert (false);
} catch (Exception e) {
String errorMessage = GeneralUIUtils.getWebElementByClassName("w-sdc-modal-caption").getText();
String checkUIResponseOnError = ErrorValidationUtils.checkUIResponseOnError(ActionStatus.VALIDATED_RESOURCE_NOT_FOUND.name());
assertTrue(errorMessage.contains(checkUIResponseOnError));
} finally {
ResourceRestUtils.deleteResourceByNameAndVersion(atomicResourceMetaData.getName(), "0.1");
}
}
@Test
public void createLinkService() throws Exception {
String fileName2 = "vSeGW.csar";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
CanvasManager canvasManager = CanvasManager.getCanvasManager();
CompositionPage.searchForElement(resourceMetaData.getName());
CanvasElement firstElement = canvasManager.createElementOnCanvas(resourceMetaData.getName());
CanvasElement secondElement = canvasManager.createElementOnCanvas(resourceMetaData.getName());
canvasManager.linkElements(firstElement, secondElement);
}
@Test
public void addDeploymentArtifactInCompositionScreenTest() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER");
CompositionPage.showDeploymentArtifactTab();
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
AssertJUnit.assertEquals(1, actualArtifactList.size());
for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) {
assertTrue(HEAT_FILE_YAML_NAME.equals(actualArtifactFileName.getText()));
}
}
@Test
public void addInformationArtifactInCompositionScreenTest() throws Exception {
String descriptionText = DESCRIPTION;
List<String> artifactFileNames = new ArrayList<>();
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
ArtifactInfo artifactInfo = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, descriptionText, ARTIFACT_LABEL, "OTHER");
CompositionPage.showInformationArtifactTab();
List<WebElement> beforeArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifactInfo, CompositionPage.artifactPopup());
List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
assertThat(actualArtifactList).as("Check number of artifacts").hasSize(beforeArtifactList.size() + 1);
int fileNameCounter = 0;
String fileName;
for (DataTestIdEnum.InformationalArtifactsService artifact : DataTestIdEnum.InformationalArtifactsService.values()) {
fileName = HEAT_FILE_YAML_NAME_PREFIX + fileNameCounter + HEAT_FILE_YAML_NAME_SUFFIX;
ArtifactUIUtils.fillPlaceHolderInformationalArtifact(artifact,
FileHandling.getFilePath("uniqueFileNames"), fileName, descriptionText);
artifactFileNames.add(fileName);
fileNameCounter++;
}
artifactFileNames.add(HEAT_FILE_YAML_NAME);
int numberOfFiles = CompositionPage.getAllAddedArtifacts().size();
assertThat(numberOfFiles).as("Check number of artifacts").isEqualTo(beforeArtifactList.size() + 1);
fileNameCounter = 0;
for (WebElement actualArtifact : CompositionPage.getAllAddedArtifacts()) {
assertThat(actualArtifact.getText()).isEqualTo(artifactFileNames.get(fileNameCounter));
fileNameCounter++;
}
}
@Test
public void addAPIArtifactInCompositionScreenTest() throws Exception {
String fileName = HEAT_FILE_YAML_NAME,
descriptionText = DESCRIPTION,
url = "http://kuku.com";
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
new ArtifactInfo(filePath, fileName, descriptionText, ARTIFACT_LABEL, "OTHER");
CompositionPage.showAPIArtifactTab();
for (DataTestIdEnum.APIArtifactsService artifact : DataTestIdEnum.APIArtifactsService.values()) {
ArtifactUIUtils.fillPlaceHolderAPIArtifact(artifact, filePath, fileName, descriptionText, url);
}
int numberOfFiles = CompositionPage.getAllAddedArtifacts().size(),
numberOfPlacehoders = DataTestIdEnum.APIArtifactsService.values().length;
assertTrue(String.format("Wrong file count, should be %s files", numberOfPlacehoders), numberOfPlacehoders == numberOfFiles);
for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) {
assertTrue(fileName.equals(actualArtifactFileName.getText()));
}
}
@Test
public void ManagmentWorkflowTest() throws Exception {
String descriptionText = DESCRIPTION,
descriptionTextEdit = "kuku2";
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ServiceGeneralPage.getServiceLeftMenu().moveToManagmentWorkflow();
ServiceGeneralPage.fillAndAddNewWorkflow(descriptionText, descriptionText);
ServiceVerificator.verifyManagmentWorkflow(descriptionText, descriptionText);
ServiceGeneralPage.clickAddWorkflow();
ServiceGeneralPage.fillAndAddNewWorkflow(descriptionTextEdit, descriptionTextEdit);
}
@Test
public void deleteChangeVersionTest() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, "OTHER");
CompositionPage.showDeploymentArtifactTab();
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName());
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
GeneralPageElements.clickCheckoutButton();
changeDeleteAndValidateVersionOnGeneralPage("0.1", "0.2", serviceMetadata.getName());
GeneralPageElements.clickCheckoutButton();
ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.TESTER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
TesterOperationPage.certifyComponent(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.DESIGNER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
ResourceGeneralPage.clickCheckoutButton();
changeDeleteAndValidateVersionOnGeneralPage("1.0", "1.1", serviceMetadata.getName());
}
@Test
public void compositionScreenRightSideButtonsTest() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
ResourceGeneralPage.getLeftMenu().moveToCompositionScreen();
CompositionPage.showInformationTab();
ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION);
//feature removed from UI
// CompositionPage.showCompositionTab();
// ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.COMPOSITION);
CompositionPage.showDeploymentArtifactTab();
ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.DEPLOYMENT_ARTIFACT_TAB);
CompositionPage.showInputsTab();
assertTrue(CompositionPage.getOpenTabTitle().size() == 0);
CompositionPage.showAPIArtifactTab();
ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.API);
CompositionPage.showInformationArtifactTab();
ServiceVerificator.verifyOpenTabTitle(CompositionScreenEnum.INFORMATION_ARTIFACTS);
}
@Test
public void addDeploymentArtifactToVFInstanceTest() throws Exception {
ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType());
CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact);
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
checkInService(serviceMetadata);
clickOncanvasElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
}
@Test
public void deleteDeploymentArtifactFromVFInstanceTest() throws Exception {
ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType());
createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact);
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
deleteAndVerifyArtifact(actualArtifactList);
}
@Test
public void deleteDeploymentArtifactFromVFInstanceNextVersionTest() throws Exception {
// if(true){
// throw new SkipException("Open bug 342260");
// }
ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType());
CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact);
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
checkInService(serviceMetadata);
ResourceGeneralPage.clickCheckoutButton();
clickOncanvasElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
deleteAndVerifyArtifact(actualArtifactList);
// change container version
GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue());
GeneralPageElements.selectVersion("V0.1");
clickOncanvasElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
}
// service version V0.1 default artifact, service version V0.2 updated artifact
@Test
public void updateDeploymentArtifactOnVFInstanceNextVersionTest() throws Exception {
// if(true){
// throw new SkipException("Open bug 322930");
// }
ResourceReqDetails atomicResourceMetaData = ElementFactory.getDefaultResourceByTypeNormTypeAndCatregory(ResourceTypeEnum.VF, NormativeTypesEnum.ROOT, ResourceCategoryEnum.NETWORK_L2_3_ROUTERS, getUser());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ArtifactInfo artifact = new ArtifactInfo(filePath, HEAT_FILE_YAML_NAME, DESCRIPTION, ARTIFACT_LABEL, ArtifactTypeEnum.SNMP_POLL.getType());
ArtifactInfo artifactUpdate = new ArtifactInfo(filePath, HEAT_FILE_YAML_UPDATE_NAME, DESCRIPTION, ARTIFACT_LABEL_UPDATE, ArtifactTypeEnum.DCAE_INVENTORY_DOC.getType());
CanvasElement computeElement = createServiceWithRiArtifact(atomicResourceMetaData, serviceMetadata, artifact);
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
checkInService(serviceMetadata);
ResourceGeneralPage.clickCheckoutButton();
clickOncanvasElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
List<WebElement> actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
deleteAndVerifyArtifact(actualArtifactList);
// upload new artifact
addDeploymentArtifact(artifactUpdate, CanvasManager.getCanvasManager(), computeElement);
checkArtifactIfAdded(1, HEAT_FILE_YAML_UPDATE_NAME);
// change container version
GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.GeneralElementsEnum.VERSION_HEADER.getValue());
GeneralPageElements.selectVersion("V0.1");
clickOncanvasElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
checkArtifactIfAdded(1, HEAT_FILE_YAML_NAME);
}
public void clickOncanvasElement(CanvasElement computeElement) {
CanvasManager canvasManager = CanvasManager.getCanvasManager();
canvasManager.clickOnCanvaElement(computeElement);
}
public void checkInService(ServiceReqDetails serviceMetadata) throws Exception {
ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName());
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
}
public static void deleteAndVerifyArtifact(List<WebElement> actualArtifactList) {
if (actualArtifactList.size() > 0) {
GeneralUIUtils.hoverOnAreaByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.ARTIFACT_ITEM.getValue() + ARTIFACT_LABEL);
SetupCDTest.getExtendTest().log(Status.INFO, "Going to delete " + HEAT_FILE_YAML_NAME + " artifact" + " and check if deleted");
GeneralUIUtils.clickOnElementByTestId(DataTestIdEnum.DeploymentArtifactCompositionRightMenu.DELETE.getValue() + ARTIFACT_LABEL);
GeneralPageElements.clickOKButton();
assertTrue("Artifact does not deleted", !GeneralUIUtils.waitForElementInVisibilityByTestId(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME)));
}
}
public void checkArtifactIfAdded(Integer expectedNumOfARtifacts, String expectedArtifactName) {
List<WebElement> actualArtifactList;
actualArtifactList = GeneralUIUtils.getWebElementsListBy(By.className(GET_ARTIFACT_LIST_BY_CLASS_NAME));
assertTrue("Expected artifact count is: " + expectedNumOfARtifacts + ", but was " + actualArtifactList.size(), expectedNumOfARtifacts == actualArtifactList.size());
if (expectedNumOfARtifacts != 0) {
for (WebElement actualArtifactFileName : CompositionPage.getAllAddedArtifacts()) {
assertTrue("Artifact name does not match, expected " + expectedArtifactName + ", but was " + actualArtifactFileName.getText(), expectedArtifactName.equals(actualArtifactFileName.getText()));
}
}
}
public CanvasElement createServiceWithRiArtifact(ResourceReqDetails atomicResourceMetaData, ServiceReqDetails serviceMetadata, ArtifactInfo artifact) throws Exception, AWTException {
ResourceUIUtils.createVF(atomicResourceMetaData, getUser());
//TODO Andrey should click on certify button
ResourceGeneralPage.clickCertifyButton(atomicResourceMetaData.getName());
ServiceUIUtils.createService(serviceMetadata);
DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
CanvasManager canvasManager = CanvasManager.getCanvasManager();
CompositionPage.searchForElement(atomicResourceMetaData.getName());
CanvasElement computeElement = canvasManager.createElementOnCanvas(atomicResourceMetaData.getName());
addDeploymentArtifact(artifact, canvasManager, computeElement);
return computeElement;
}
public void addDeploymentArtifact(ArtifactInfo artifact, CanvasManager canvasManager, CanvasElement computeElement) throws Exception {
canvasManager.clickOnCanvaElement(computeElement);
CompositionPage.showDeploymentArtifactTab();
CompositionPage.clickAddArtifactButton();
ArtifactUIUtils.fillAndAddNewArtifactParameters(artifact, CompositionPage.artifactPopup());
}
@Test
public void isDisabledAndReadOnlyInCheckin() throws Exception {
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
GeneralPageElements.clickCheckinButton(serviceMetadata.getName());
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
ServiceMetadataEnum[] fieldsForCheck = {ServiceMetadataEnum.SERVICE_NAME,
ServiceMetadataEnum.CONTACT_ID,
ServiceMetadataEnum.DESCRIPTION,
ServiceMetadataEnum.PROJECT_CODE,
ServiceMetadataEnum.TAGS};
for (ServiceMetadataEnum field : fieldsForCheck) {
assertTrue(GeneralUIUtils.isElementReadOnly(field.getValue()));
}
assertTrue(GeneralUIUtils.isElementDisabled(ServiceMetadataEnum.CATEGORY.getValue()));
assertTrue(GeneralUIUtils.isElementDisabled(DataTestIdEnum.LifeCyleChangeButtons.CREATE.getValue()));
}
// future removed from ui
@Test(enabled = false)
public void inputsTest() throws Exception {
String fileName = "service_input_test_VF2.csar";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.VF, getUser());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName, getUser());
GeneralPageElements.clickCheckinButton(resourceMetaData.getName());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
String selectedInstanceName = addResourceToServiceInCanvas(resourceMetaData);
GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
DeploymentArtifactPage.getLeftMenu().moveToInputsScreen();
InputsPage.addInputToService(selectedInstanceName, "volume_id");
InputsPage.deleteServiceInput(selectedInstanceName, "volume_id");
// Trying to find deleted service input
try {
InputsPage.getServiceInput(selectedInstanceName, "volume_id");
assert (false);
} catch (TestException e) {
}
}
@Test()
public void deploymentViewServiceTest() throws Exception {
User user = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);
String fileName2 = "vSeGWNew.csar";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
Resource resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceMetaData.getName(), "0.1");
// update group property max_vf_module_instances of VF Module to 100
List<GroupDefinition> groups = resource.getGroups();
for (GroupDefinition group : groups) {
if (group.getType().equals("org.openecomp.groups.VfModule")) {
for (PropertyDataDefinition property : group.getProperties()) {
if (property.getName().equals("max_vf_module_instances")) {
// property.setValue("100");
// List<PropertyDataDefinition> propertyList = new ArrayList<>();
// propertyList.add(property);
// todo pass to method correct object instaed of value for custom json
AtomicOperationUtils.updateGroupPropertyOnResource("100", resource, group.getUniqueId(), user, true);
break;
}
}
}
}
ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
addResourceToServiceInCanvas(resourceMetaData);
GeneralUIUtils.clickOnElementByTestId("breadcrumbs-button-1");
DeploymentArtifactPage.getLeftMenu().moveToDeploymentViewScreen();
serviceMetadata.setVersion("0.1");
List<WebElement> instanceRowsFromTable = GeneralUIUtils.getElementsByCSS("div[data-tests-id^='hierarchy-instance'] span[class^='expand-collapse-title-text']");
for (WebElement instanceRow : instanceRowsFromTable) {
String instanceRowText = instanceRow.getText();
List<WebElement> instanceModulesList = DeploymentPage.getInstanceModulesList(instanceRowText);
for (WebElement instanceModule : instanceModulesList) {
String instanceModuleText = instanceModule.getText();
ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance");
ServiceVerificator.verifyDeploymentPageSubElements(instanceModuleText.split("\\.\\.")[2], new DeploymentViewVerificator(filePath + fileName2));
ServiceVerificator.verifyDisabledServiceProperties();
SetupCDTest.getExtendTest().log(Status.INFO, "Sent email to Edith Ronen, waiting for answer");
String isBaseValue = ServiceVerificator.getVFModulePropertyValue(serviceMetadata, "isBase", instanceModuleText);
if (isBaseValue.equals("false")) {
ServiceVerificator.verifyEnabledServiceProperties();
}
ResourceUIUtils.clickOnElementByText(instanceModuleText, "instance");
}
}
}
@Test
public void vfModuleCustomizationUUIDServiceTest() throws Exception {
String fileName2 = "vSeGW.csar";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
ResourceGeneralPage.clickCheckinButton(resourceMetaData.getName());
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
addResourceToServiceInCanvas(resourceMetaData);
serviceMetadata.setVersion("0.1");
ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata);
}
@Test
public void checkoutCertifyRemainSameCustomizationUUIDServiceTest() throws Exception {
String fileName2 = "vSeGW.csar";
ResourceReqDetails resourceMetaData = ElementFactory.getDefaultResourceByType("ciRes", NormativeTypesEnum.ROOT, ResourceCategoryEnum.APPLICATION_L4_DATABASE, getUser().getUserId(), ResourceTypeEnum.VF.toString());
ResourceUIUtils.importVfFromCsar(resourceMetaData, filePath, fileName2, getUser());
//TODO Andrey should click on certify button
ResourceGeneralPage.clickCertifyButton(resourceMetaData.getName());
/*reloginWithNewRole(UserRoleEnum.TESTER);
GeneralUIUtils.findComponentAndClick(resourceMetaData.getName());
TesterOperationPage.certifyComponent(resourceMetaData.getName());
reloginWithNewRole(UserRoleEnum.DESIGNER);*/
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createService(serviceMetadata);
addResourceToServiceInCanvas(resourceMetaData);
serviceMetadata.setVersion("0.1");
ServiceVerificator.verifyVFModuleCustomizationUUID(serviceMetadata);
List<String> allVFModuleCustomizationUUIDs = ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata);
ResourceGeneralPage.clickCheckinButton(serviceMetadata.getName());
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
GeneralPageElements.clickCheckoutButton();
serviceMetadata.setVersion("0.2");
assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata)));
ResourceGeneralPage.clickSubmitForTestingButton(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.TESTER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
TesterOperationPage.certifyComponent(serviceMetadata.getName());
reloginWithNewRole(UserRoleEnum.DESIGNER);
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
ResourceGeneralPage.clickCheckoutButton();
serviceMetadata.setVersion("1.1");
serviceMetadata.setUniqueId(null);
assertTrue(ServiceVerificator.isEqualCustomizationUUIDsAfterChanges(allVFModuleCustomizationUUIDs, ServiceVerificator.getAllVFModuleCustomizationUUIDs(serviceMetadata)));
}
@Test
public void createServiceWithALaCarteInstanTypeAndCheckItsTosca() throws Exception {
getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndCheckItsTosca.");
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser());
getExtendTest().log(Status.INFO, "Done creating service over the UI, "
+ "about to move into Tosca Artifacts section.");
ResourceGeneralPage.moveToToscaArtifactsSectionAndDownloadTosca();
getExtendTest().log(Status.INFO, "Downloaded Template YAML File.");
AssertJUnit.assertTrue(ServiceGeneralPage.parseToscaFileIntoServiceAndValidateProperties(serviceMetadata));
getExtendTest().log(Status.INFO, "Test is successful.");
}
@Test
public void createServiceWithALaCarteInstanTypeAndVerifyChosenValue() throws Exception {
getExtendTest().log(Status.INFO, "Starting the test: createServiceWithALaCarteInstanTypeAndVerifyChosenValue.");
ServiceReqDetails serviceMetadata = ElementFactory.getDefaultService();
ServiceUIUtils.createServiceWithDefaultTagAndUserId(serviceMetadata, getUser());
getExtendTest().log(Status.INFO, "Done creating service over the UI, "
+ "about to move into Home page.");
HomePage.navigateToHomePage();
GeneralUIUtils.findComponentAndClick(serviceMetadata.getName());
assertTrue(serviceMetadata.getInstantiationType().equals(ServiceGeneralPage.getInstantiationTypeChosenValue()));
}
public static synchronized String addResourceToServiceInCanvas(ResourceReqDetails resourceMetaData) throws Exception {
DeploymentArtifactPage.getLeftMenu().moveToCompositionScreen();
if (computeElement == null) {
computeElement = createCanvasElement(resourceMetaData);
}
CanvasManager.getCanvasManager().clickOnCanvaElement(computeElement);
return CompositionPage.getSelectedInstanceName();
}
private static synchronized CanvasElement createCanvasElement(ResourceReqDetails resourceMetaData) throws Exception {
CompositionPage.searchForElement(resourceMetaData.getName());
return CanvasManager.getCanvasManager().createElementOnCanvas(resourceMetaData.getName());
}
public static void changeDeleteAndValidateVersionOnGeneralPage(String previousVersion, String currentVersion, String serviceName) throws Exception {
GeneralPageElements.selectVersion("V" + previousVersion);
ServiceVerificator.verifyVersionUI(previousVersion);
GeneralUIUtils.clickJSOnElementByText("latest version");
ServiceVerificator.verifyVersionUI(currentVersion);
GeneralPageElements.clickTrashButtonAndConfirm();
GeneralUIUtils.findComponentAndClick(serviceName);
ServiceVerificator.verifyVersionUI(previousVersion);
}
@Override
protected UserRoleEnum getRole() {
return UserRoleEnum.DESIGNER;
}
}
|