aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/vid/automation/test/test/ALaCarteflowTest.java
blob: 69c619b2a6a65d73458054f86e38397f827f3923 (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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
package vid.automation.test.test;

import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.ATT_NC;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.MDT_1;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_MDT1_TO_ATT_NC;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.PRESET_SOME_LEGACY_REGION_TO_ATT_AIC;
import static org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetCloudOwnersByCloudRegionId.SOME_LEGACY_REGION;
import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.Assert;
import org.onap.sdc.ci.tests.datatypes.UserCredentials;
import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
import org.onap.simulator.presetGenerator.presets.BasePresets.BaseMSOPreset;
import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet;
import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVfModuleOldViewEdit;
import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVnfALaCarteOldViewEdit;
import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateVolumeGroupOldViewEdit;
import org.openqa.selenium.WebElement;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import vid.automation.test.Constants;
import vid.automation.test.infra.Get;
import vid.automation.test.infra.SelectOption;
import vid.automation.test.model.ServiceModel;
import vid.automation.test.model.User;
import vid.automation.test.sections.SideMenu;
import vid.automation.test.sections.VidBasePage;
import vid.automation.test.sections.ViewEditPage;
import vid.automation.test.services.ServicesService;
import vid.automation.test.services.SimulatorApi;


public class ALaCarteflowTest extends CreateInstanceDialogBaseTest {
    static final String SUBSCRIBER = "Emanuel";
    static final String SERVICE_NAME = "ggghhh";
    static final String SERVICE_ID = "537d3eb0-b7ab-4fe8-a438-6166ab6af49b";
    static final String VNF_ID = "0eb38f69-d96b-4d5e-b8c9-3736c292f0f7";
    static final String DEFAULT_TEST_API_VALUE = "VNF_API";
    public static final String SERVICE_INSTANCE_ID = "SERVICE_INSTANCE_ID";
    public static final String A_LACARTE_FLOW_GET_ORCHESTRATION = "aLacarteFlow/get_orchestration_request_status.json";
    public static final String ORCHESTRATION_REQUEST_ID = "orchestrationRequestId";
    public static final String STATUS_MESSAGE = "status_message";
    public static final String REQUEST_TYPE = "REQUEST-TYPE";
    public static final String CREATE = "Create";
    public static final String AAIAIC_25 = "JANET25";
    public static final String AIC = "AIC";
    public static final String TENANT = "092eb9e8e4b7412e8787dd091bc58e86";
    public static final String FALSE = "false";
    public static final String NODE_INSTANCE = "VSP1710PID298109_vWINIFRED 0";
    public static final String MODEL = "959a7ba0-89ee-4984-9af6-65d5bdda4b0e";
    private static final String CREATE_VNF_REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873dfbd";


    @BeforeClass
    protected void registerToSimulator() {
        SimulatorApi.clearAll();
        SimulatorApi.registerExpectation(APPEND,
                "ecompportal_getSessionSlotCheckInterval.json",
                "search_for_service_instance/aai_get_services.json"
                , "create_configuration/aai_get_tenants.json"
                , "sanity/get_aai_sub_details.json"
                , "aLacarteFlow/get_aai_search_named_query.json"
                , "aLacarteFlow/get_sdc_catalog_services_ggghhh.json"
        );
        SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.APPEND);
    }


    @Test(dataProvider = "msoTestApiOptions")
    private void testAddVfModule(String msoTestApiOption, String msoTestApiValue) {
        withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
            final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bddd";
            final String MODEL_UUID = "d205e01d-e5da-4e68-8c52-f95cb0607959";

            String vfModuleName = viewEditPage.generateInstanceName(Constants.ViewEdit.VF_MODULE_INSTANCE_NAME_PREFIX);

            SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
                    PRESET_MDT1_TO_ATT_NC,
                    new PresetMSOCreateVfModuleOldViewEdit(
                            REQUEST_ID,
                            BaseMSOPreset.DEFAULT_INSTANCE_ID,
                            SERVICE_ID,
                            VNF_ID,
                            vfModuleName,
                            msoTestApiValue,
                            ATT_NC)),
                    SimulatorApi.RegistrationStrategy.APPEND);


            SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
                    ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VF_MODULE_CREATED_SUCCESSFULLY_TEXT,
                            REQUEST_TYPE, CREATE), APPEND);
            GeneralUIUtils.ultimateWait();
            goToInstance();
            ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
            addVFModule("Vsp1710pid298109Vmmsc..mmsc_mod1_ltm..module-8", vfModuleName, AAIAIC_25, AIC,
                    TENANT, FALSE, MDT_1, getCurrentUser().tenants, serviceInstance);

        });
    }

    @Test
    private void testTenant() throws Exception {
        ViewEditPage viewEditPage = new ViewEditPage();
        User user = usersService.getUser("Emanuel_with_tenant");
        relogin(user.credentials);
        goToInstance();
        viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
        viewEditPage.setInstanceName("New and fun instance");
        viewEditPage.selectProductFamily("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
        viewEditPage.selectLcpRegion("hvf6", AIC);
        List<WebElement> tenantOptions = Get.byClass(Constants.ViewEdit.TENANT_OPTION_CLASS);
        List<WebElement> enabledTenantOption = tenantOptions.stream().filter(webElement -> webElement.isEnabled()).collect(Collectors.toList());
        Assert.assertTrue(enabledTenantOption.size() == 1);
        Assert.assertTrue(enabledTenantOption.get(0).getText().equals("test-hvf6-09"));

        //        SimulatorApi.registerExpectation("aLacarteFlow/get_sdc_catalog_services_ggghhh.json",APPEND);
    }

    @Test(dataProvider = "msoTestApiOptions")
    private void testAddVnf(String msoTestApiOption, String msoTestApiValue) {
        withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
            final String MODEL_UUID = MODEL;
            String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
            SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
                    PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
                    new PresetMSOCreateVnfALaCarteOldViewEdit(
                            CREATE_VNF_REQUEST_ID,
                            SERVICE_ID,
                            instanceName,
                            true,
                            msoTestApiValue)),
                    SimulatorApi.RegistrationStrategy.APPEND);
            SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
                    ImmutableMap.of(ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd", STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
                            REQUEST_TYPE, CREATE), APPEND);
            GeneralUIUtils.ultimateWait();
            goToInstance();
            ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
            addVNF(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
                    FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, new ArrayList<>(Arrays.asList("ONAP")), serviceInstance, instanceName);
        });
    }

    @Test(dataProvider = "msoTestApiOptions")
    private void requiredLineOfBussiness_confirmVnfWithNoLob(String msoTestApiOption, String msoTestApiValue) throws Exception {
        withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
            goToInstance();
            String instanceName = new VidBasePage().generateInstanceName(Constants.ViewEdit.VNF_INSTANCE_NAME_PREFIX);
            SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
                    PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
                    new PresetMSOCreateVnfALaCarteOldViewEdit(
                            CREATE_VNF_REQUEST_ID,
                            SERVICE_ID,
                            instanceName,
                            false,
                            msoTestApiValue)),
                    SimulatorApi.RegistrationStrategy.APPEND);
            SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION, ImmutableMap.of(
                    ORCHESTRATION_REQUEST_ID, "dbe54591-c8ed-46d3-abc7-d3a24873dfbd",
                    STATUS_MESSAGE, Constants.ViewEdit.VNF_CREATED_SUCCESSFULLY_TEXT,
                    REQUEST_TYPE, CREATE
            ), APPEND);
            openAndFillVnfPopup(NODE_INSTANCE, AAIAIC_25, AIC, TENANT,
                    FALSE, SOME_LEGACY_REGION, "ebc3bc3d-62fd-4a3f-a037-f619df4ff034", "platform", getCurrentUser().tenants, null, null, instanceName);
            assertConfirmShowMissingDataErrorOnCurrentPopup(Constants.ViewEdit.LINE_OF_BUSINESS_TEXT);
            successConfirmVnfAndClosePopup();
        });
    }

    @Test
    private void emptyLobAfterReopenCreateVnfDialog() throws Exception {
        final String lobToSelect = "ONAP";
        goToInstance();
        ViewEditPage viewEditPage = new ViewEditPage();
        viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
        GeneralUIUtils.ultimateWait();
        SelectOption.selectOptionsFromMultiselectById(Constants.OwningEntity.LOB_SELECT_TEST_ID, new ArrayList<>(Arrays.asList(lobToSelect)));
        viewEditPage.clickCancelButtonByTestID();
        viewEditPage.selectNodeInstanceToAdd(NODE_INSTANCE);
        GeneralUIUtils.ultimateWait();
        AssertUnselectedOptionInMultiselectById(Constants.OwningEntity.LOB_SELECT_TEST_ID, lobToSelect);
        viewEditPage.clickCancelButtonByTestID();
    }

    @Test(dataProvider = "msoTestApiOptions")
    private void testAddVolumeGroup(String msoTestApiOption, String msoTestApiValue) throws Exception {
        withMsoTestApiConfiguration(msoTestApiOption, msoTestApiValue, () -> {
            final String REQUEST_ID = "dbe54591-c8ed-46d3-abc7-d3a24873bdaa";
            final String MODEL_UUID = "13f022c4-651e-4326-b8e1-61e9a8c7a7ad";
            String vgName = viewEditPage.generateInstanceName(Constants.ViewEdit.VOLUME_GROUP_INSTANCE_NAME_PREFIX);
            SimulatorApi.registerExpectationFromPresets(ImmutableList.of(
                    PRESET_SOME_LEGACY_REGION_TO_ATT_AIC,
                    new PresetMSOCreateVolumeGroupOldViewEdit(
                            REQUEST_ID,
                            BaseMSOPreset.DEFAULT_INSTANCE_ID,
                            SERVICE_ID,
                            VNF_ID,
                            vgName,
                            msoTestApiValue)),
                    SimulatorApi.RegistrationStrategy.APPEND);
            SimulatorApi.registerExpectation(A_LACARTE_FLOW_GET_ORCHESTRATION,
                    ImmutableMap.of(ORCHESTRATION_REQUEST_ID, REQUEST_ID, STATUS_MESSAGE, Constants.ViewEdit.VOLUME_GROUP_CREATED_SUCCESSFULLY_TEXT,
                            REQUEST_TYPE, CREATE), SimulatorApi.RegistrationStrategy.APPEND);
            GeneralUIUtils.ultimateWait();
            goToInstance();
            ServiceModel serviceInstance = new ServicesService().getServiceModel(MODEL_UUID);
            addVolumeGroup("Vsp1710pid298109Vmmsc..mmsc_mod6_eca_oam..module-3", vgName, AAIAIC_25, AIC, TENANT,
                    FALSE, SOME_LEGACY_REGION, getCurrentUser().tenants, serviceInstance);
        });
    }

    private User getCurrentUser() {
        return usersService.getUser(Constants.Users.EMANUEL_vWINIFRED);
    }

    private void goToInstance() {
        SideMenu.navigateToSearchExistingPage();
        goToExistingInstanceBySubscriber(SUBSCRIBER, SERVICE_NAME, SERVICE_ID);

    }

    @Override
    protected UserCredentials getUserCredentials() {
        User user = getCurrentUser();
        return new UserCredentials(user.credentials.userId, user.credentials.password, Constants.Users.EMANUEL_vWINIFRED, "", "");
    }

    @DataProvider
    public static Object[][] msoTestApiOptions() {
        return new Object[][]{
                {"VNF_API (old)", DEFAULT_TEST_API_VALUE}
                , {"GR_API (new)", "GR_API"}
        };
    }

    private void withMsoTestApiConfiguration(String msoTestApiOption, String msoTestApiValue, Runnable test) {
        if (msoTestApiValue.equals(DEFAULT_TEST_API_VALUE)) {
            test.run();
        } else {
            try {
                selectMsoTestApiOption(msoTestApiOption);
                test.run();
            } finally {
                // back to default
                selectMsoTestApiOption("VNF_API (old)");
            }
        }
    }


}