aboutsummaryrefslogtreecommitdiffstats
path: root/integration-tests/src/test/java/org/onap/sdc/frontend/ci/tests/execute/sanity/ArchiveRestoreTest.java
blob: 5f7910669debba34df4d8b9a6b33f2399152170b (plain)
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
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2019 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.onap.sdc.frontend.ci.tests.execute.sanity;

import com.aventstack.extentreports.Status;
import fj.data.Either;
import org.onap.sdc.backend.ci.tests.datatypes.http.RestResponse;
import org.onap.sdc.frontend.ci.tests.pages.CompositionPage;
import org.onap.sdc.frontend.ci.tests.pages.GeneralPageElements;
import org.onap.sdc.frontend.ci.tests.pages.HomePage;
import org.onap.sdc.frontend.ci.tests.pages.OpsOperationPage;
import org.onap.sdc.frontend.ci.tests.utilities.FileHandling;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.Service;
import org.openecomp.sdc.be.model.User;
import org.onap.sdc.frontend.ci.tests.datatypes.DataTestIdEnum;
import org.onap.sdc.backend.ci.tests.datatypes.ResourceReqDetails;
import org.onap.sdc.backend.ci.tests.datatypes.ServiceReqDetails;
import org.onap.sdc.frontend.ci.tests.datatypes.TopMenuButtonsEnum;
import org.onap.sdc.backend.ci.tests.datatypes.VendorLicenseModel;
import org.onap.sdc.backend.ci.tests.datatypes.VendorSoftwareProductObject;
import org.onap.sdc.backend.ci.tests.datatypes.enums.LifeCycleStatesEnum;
import org.onap.sdc.backend.ci.tests.datatypes.enums.UserRoleEnum;
import org.onap.sdc.frontend.ci.tests.execute.setup.SetupCDTest;
import org.onap.sdc.frontend.ci.tests.pages.GovernorOperationPage;
import org.onap.sdc.frontend.ci.tests.utilities.CatalogUIUtilitis;
import org.onap.sdc.frontend.ci.tests.utilities.GeneralUIUtils;
import org.onap.sdc.frontend.ci.tests.utilities.HomeUtils;
import org.onap.sdc.frontend.ci.tests.utilities.OnboardingUiUtils;
import org.onap.sdc.frontend.ci.tests.utilities.ResourceUIUtils;
import org.onap.sdc.backend.ci.tests.utils.general.AtomicOperationUtils;
import org.onap.sdc.backend.ci.tests.utils.general.ElementFactory;
import org.onap.sdc.backend.ci.tests.utils.general.OnboardingUtillViaApis;
import org.onap.sdc.backend.ci.tests.utils.general.VendorLicenseModelRestUtils;
import org.onap.sdc.backend.ci.tests.utils.general.VendorSoftwareProductRestUtils;
import org.testng.annotations.Test;

import static org.testng.AssertJUnit.assertTrue;

public class ArchiveRestoreTest extends SetupCDTest {

    private User sdncDesignerDetails = ElementFactory.getDefaultUser(UserRoleEnum.DESIGNER);


    @Test
    public void updateVSP_WhenVF_Archived() throws Throwable {

        String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";
        String vnfFile2 = "2-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0_Added2TestParameters.zip";

//      1. Import VSP v1.0
        String filePath = FileHandling.getUpdateVSPVnfRepositoryPath();
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails,
            vendorLicenseModel, null);
//		2. Create VF from VSP, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
//		3. Create Service add to it the certified VF and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
//		4. archive VF(1.0)
        GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
//      5. service certification should send error message - unable to certify, service contains archived resource  via UI
        HomeUtils.findComponentAndClick(service.getName());
        GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName());
//		6. Update VSP to v2.0 - onboard level
        getExtendTest().log(Status.INFO, "Upgrading the VSP with new file: " + vnfFile2);
        VendorSoftwareProductRestUtils.updateVendorSoftwareProductToNextVersion(vendorSoftwareProductObject, sdncDesignerDetails, filePath, vnfFile2);
        getExtendTest().log(Status.INFO, String.format("Validating VSP %s upgrade to version 2.0: ", vnfFile2));
        VendorSoftwareProductRestUtils.validateVspExist(vendorSoftwareProductObject, sdncDesignerDetails);
//		7. Update the VF from VSP when it archived  and restore - via UI
        getExtendTest().log(Status.INFO, String.format("Going to update VF %s with VSP v2.0", resourceReqDetails.getName()));
        CompositionPage.moveToHomeScreen();
        HomePage.showVspRepository();
        OnboardingUiUtils.updateVSP(vendorSoftwareProductObject, true);
//		8. Certify and update restored VF from with VSP v2.0
        GeneralPageElements.clickCertifyButton(resource.getName());
//		9. Update the Service with the VFi version 2.0 and certify
        HomeUtils.findComponentAndClick(service.getName());
        GeneralPageElements.clickSubmitForTestingButton(service.getName());
    }

    //    https://sdp.web.att.com/fa3qm1/web/console/Application_Development_Tools_QM_20.20.01#action=com.ibm.rqm.planning.home.actionDispatcher&subAction=viewTestScript&id=896098
    @Test
    public void certifyVF_WhenVSP_Archived() throws Exception {

        String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";

//      1. Import VSP v1.0
        String filePath = FileHandling.getUpdateVSPVnfRepositoryPath();
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails,
            vendorLicenseModel, null);
//		2. Create VF from VSP, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
//      3. Archive VSP (onboarding page-Amdocs side)
        getExtendTest().log(Status.INFO, String.format("Going to archive component OB side: %s", resource.getName()));
        VendorSoftwareProductRestUtils.archiveVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails);
        getExtendTest().log(Status.INFO, String.format("Succeed to archive component %s, OB side", resource.getName()));
//      4. chekout resource and check that VF is archived
        CatalogUIUtilitis.clickTopMenuButton(TopMenuButtonsEnum.CATALOG);
        HomeUtils.findComponentAndClick(resource.getName());
        GeneralPageElements.clickCheckoutButton();
        resource = AtomicOperationUtils.getResourceObject(resource.getUniqueId());
        getExtendTest().log(Status.INFO, String.format("Going to validate is VSP archived: %s", resource.getName()));
        assertTrue("Validate isVspArchived flag, expected: true, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(true));
        String expectedText = "VSP is archived";
        getExtendTest().log(Status.INFO, String.format("Going to validate text box message, expected: %s", expectedText));
        String actualElementText = GeneralPageElements.getWebElementTextByTestId(DataTestIdEnum.ResourceMetadataEnum.SELECT_VSP.getValue());
        assertTrue("Validate text box message, expected: [" + expectedText + "], but was: " + actualElementText, actualElementText.equals(expectedText));
//      5. certify new resource - should fail, via API
        getExtendTest().log(Status.INFO, String.format("Going to certify archived on OB side resource %s , expected failure certification", resource.getName()));
        GeneralPageElements.clickCertifyButtonNoUpgradePopupDismissErrorCase(resource.getName());
//      6. restore
        getExtendTest().log(Status.INFO, String.format("Going to restore component OB side: %s", resource.getName()));
        VendorSoftwareProductRestUtils.restoreVendorSoftwareProduct(vendorSoftwareProductObject, sdncDesignerDetails);
        SetupCDTest.getExtendTest().log(Status.INFO, String.format("Succeed to restore component %s, OB side", resource.getName()));
//      7. certify - should pass
        getExtendTest().log(Status.INFO, String.format("Going to certify resource %s ", resource.getName()));
        GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resource.getName());
        resource = AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resource.getName(), "2.0");
        assertTrue("Validate isVspArchived flag, expected: false, but was: " + resource.isVspArchived(), resource.isVspArchived().equals(false));
    }

    @Test
    public void distributeServiceIncludedArchivedResource() throws Exception {

        String vnfFile1 = "1-2017-404_vUSP_vCCF_AIC3.0-(VOIP)_v6.0.zip";
//      1. Import VSP v1.0
        String filePath = FileHandling.getUpdateVSPVnfRepositoryPath();
        VendorLicenseModel vendorLicenseModel = VendorLicenseModelRestUtils.createVendorLicense(sdncDesignerDetails);
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software License (VLM): %s v1.0", vendorLicenseModel
            .getVendorLicenseName()));
        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResource();
        getExtendTest().log(Status.INFO, String.format("Creating Vendor Software Product (VSP): %s v1.0 from heat file: %s ", resourceReqDetails.getName(), vnfFile1));
        VendorSoftwareProductObject vendorSoftwareProductObject = VendorSoftwareProductRestUtils.createAndFillVendorSoftwareProduct(resourceReqDetails, vnfFile1, filePath, this.sdncDesignerDetails,
            vendorLicenseModel, null);
//		2. Create VF from VSP, certify - v1.0 is created
        resourceReqDetails = OnboardingUtillViaApis.prepareOnboardedResourceDetailsBeforeCreate(resourceReqDetails, vendorSoftwareProductObject);
        getExtendTest().log(Status.INFO, String.format("Creating Virtual Function (VF): %s v1.0", resourceReqDetails.getName()));
        Resource resource = OnboardingUtillViaApis.createResourceFromVSP(resourceReqDetails);
        getExtendTest().log(Status.INFO, String.format("Certify the VF"));
        resource = (Resource) AtomicOperationUtils.changeComponentState(resource, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();
//		3. Create Service add to it the certified VF and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding VF instance to Service"));
        service = (Service) AtomicOperationUtils.changeComponentState(service, UserRoleEnum.DESIGNER, LifeCycleStatesEnum.CERTIFY, true).getLeft();

        reloginWithNewRole(UserRoleEnum.GOVERNOR);
        GeneralUIUtils.findComponentAndClick(service.getName());
        GovernorOperationPage.approveService(service.getName());
//		4. archive VF(1.0)
        reloginWithNewRole(UserRoleEnum.DESIGNER);
        GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
//      5. Distribute service - should pass
        reloginWithNewRole(UserRoleEnum.OPS);
        GeneralUIUtils.findComponentAndClick(service.getName());
        OpsOperationPage.distributeService();

    }


    @Test
    public void certificationOfArchivedCR() throws Exception {

        ResourceReqDetails resourceReqDetails = ElementFactory.getDefaultResourceByType(ResourceTypeEnum.CR, getUser());
        ResourceUIUtils.createCR(resourceReqDetails, sdncDesignerDetails);
        GeneralPageElements.clickCertifyButtonNoUpgradePopupDismiss(resourceReqDetails.getName());
        GeneralUIUtils.ultimateWait();
        Resource resource = (Resource) AtomicOperationUtils.getResourceObjectByNameAndVersion(UserRoleEnum.DESIGNER, resourceReqDetails.getName(), "1.0");
//		1. Create Service add to it the certified CR and certify the Service v1.0
        ServiceReqDetails serviceReqDetails = ElementFactory.getDefaultService();
        org.openecomp.sdc.be.model.Service service = AtomicOperationUtils.createCustomService(serviceReqDetails, UserRoleEnum.DESIGNER, true).left().value();
        getExtendTest().log(Status.INFO, String.format("Creating Service: %s v1.0", serviceReqDetails.getName()));
        Either<ComponentInstance, RestResponse> addComponentInstanceToComponentContainer = AtomicOperationUtils.addComponentInstanceToComponentContainer(resource, service, UserRoleEnum.DESIGNER, true);
        ComponentInstance componentInstance = addComponentInstanceToComponentContainer.left().value();
        getExtendTest().log(Status.INFO, String.format("Adding CR instance to Service"));
//		2. archive CR(1.0)
        GeneralPageElements.clickArchivedButtonFromCatalog(resource.getName());
//      3. service certification should send error message - unable to certify, service contains archived resource  via UI
        HomeUtils.findComponentAndClick(service.getName());
        GeneralPageElements.clickSubmitForTestingButtonErrorCase(service.getName());
//      4. restore CR
        GeneralPageElements.restoreComponentFromArchivedCatalog(resource.getName());
//		5. Certify and update restored CR(v2.0)
        GeneralPageElements.clickCheckoutButton();
        GeneralPageElements.clickCertifyButton(resource.getName());
//		6. Update the Service with the CRi version 2.0 and certify service
        HomeUtils.findComponentAndClick(service.getName());
        GeneralPageElements.clickSubmitForTestingButton(service.getName());
    }

}