blob: b11f8d19efaa3c266de39290e693fc1812a413b7 (
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
|
package org.openecomp.sdc.uici.scripts;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.openecomp.sdc.uici.tests.datatypes.CleanTypeEnum;
import org.openecomp.sdc.uici.tests.execute.base.SetupCDTest;
import org.openecomp.sdc.uici.tests.utilities.GeneralUIUtils;
import org.openecomp.sdc.uici.tests.utilities.OnboardUtility;
import org.openecomp.sdc.ci.tests.datatypes.enums.UserRoleEnum;
import org.openecomp.sdc.common.datastructure.FunctionalInterfaces;
import com.google.gson.GsonBuilder;
/**
* This Class functions to load mass zip files to vfs through onboarding.<br>
* It uses both BE & UI APIs
*
* @author mshitrit
*
*/
public class CreateVfsFromOnboarding extends SetupCDTest {
public static void main(String[] args) {
CreateVfsFromOnboarding manager = new CreateVfsFromOnboarding();
FunctionalInterfaces.swallowException(() -> manager.setEnvParameters(CleanTypeEnum.NONE.name()));
// String folderPath = args[0];
String folderPath = "C:\\onboardingTest\\onBoardingZips";
File folder = new File(folderPath);
File[] listOfFiles = folder.listFiles();
List<String> zipFileNames = Arrays.asList(listOfFiles).stream().map(file -> file.getName())
.filter(fileName -> fileName.endsWith(".zip")).collect(Collectors.toList());
Map<String, String> filesSuccessMap = new HashMap<>();
for (String fileName : zipFileNames) {
try {
// Before
manager.beforeState(null);
manager.setBrowserBeforeTest();
createSingleVfFromOnboarding(folderPath, fileName);
filesSuccessMap.put(fileName, "SUCCESS");
} catch (Exception e) {
filesSuccessMap.put(fileName, "FAIL");
} finally {
FunctionalInterfaces.swallowException(() -> manager.afterState(null));
manager.quitAfterTest();
}
}
Path file = Paths.get("RunResults.txt");
String stringDataModel = new GsonBuilder().setPrettyPrinting().create().toJson(filesSuccessMap);
FunctionalInterfaces.swallowException(() -> Files.write(file, stringDataModel.getBytes()));
}
private static void createSingleVfFromOnboarding(String filePath, String zipFileName) {
String userId = UserRoleEnum.DESIGNER.getUserId();
OnboardUtility.createVfFromOnboarding(userId, zipFileName, filePath);
GeneralUIUtils.submitForTestingElement("Vf From Onboarding");
}
}
|