|
1 | | -// package integration.com.sap.cds.sdm; |
2 | | -// |
3 | | -// import static org.junit.jupiter.api.Assertions.fail; |
4 | | -// |
5 | | -// import java.io.*; |
6 | | -// import java.util.ArrayList; |
7 | | -// import java.util.List; |
8 | | -// import java.util.Random; |
9 | | -// |
10 | | -// public class IntegrationTestUtils { |
11 | | -// |
12 | | -// public String getDropDownValue() { |
13 | | -// ClassLoader classLoader = getClass().getClassLoader(); |
14 | | -// File csvFile = new File(classLoader.getResource("WDIRSCodeList.csv").getFile()); |
15 | | -// |
16 | | -// List<String> codes = new ArrayList<>(); |
17 | | -// |
18 | | -// try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) { |
19 | | -// String line; |
20 | | -// boolean firstLine = true; |
21 | | -// while ((line = br.readLine()) != null) { |
22 | | -// if (firstLine) { |
23 | | -// firstLine = false; // Skip header |
24 | | -// continue; |
25 | | -// } |
26 | | -// String[] parts = line.split(";"); |
27 | | -// if (parts.length >= 1 && !parts[0].trim().isEmpty()) { |
28 | | -// codes.add(parts[0].trim()); // Add the code (A, B, C) to list |
29 | | -// } |
30 | | -// } |
31 | | -// } catch (FileNotFoundException e) { |
32 | | -// throw new RuntimeException(e); |
33 | | -// } catch (IOException e) { |
34 | | -// throw new RuntimeException(e); |
35 | | -// } |
36 | | -// |
37 | | -// if (codes.isEmpty()) { |
38 | | -// fail("No valid dropdown code found in WDIRSCodeList.csv"); |
39 | | -// } |
40 | | -// |
41 | | -// // Return a random value from the list |
42 | | -// Random random = new Random(); |
43 | | -// return codes.get(random.nextInt(codes.size())); |
44 | | -// } |
45 | | -// } |
| 1 | +package integration.com.sap.cds.sdm; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.fail; |
| 4 | + |
| 5 | +import java.io.*; |
| 6 | +import java.util.ArrayList; |
| 7 | +import java.util.List; |
| 8 | +import java.util.Random; |
| 9 | + |
| 10 | +public class IntegrationTestUtils { |
| 11 | + |
| 12 | + public String getDropDownValue() { |
| 13 | + ClassLoader classLoader = getClass().getClassLoader(); |
| 14 | + File csvFile = new File(classLoader.getResource("WDIRSCodeList.csv").getFile()); |
| 15 | + |
| 16 | + List<String> codes = new ArrayList<>(); |
| 17 | + |
| 18 | + try (BufferedReader br = new BufferedReader(new FileReader(csvFile))) { |
| 19 | + String line; |
| 20 | + boolean firstLine = true; |
| 21 | + while ((line = br.readLine()) != null) { |
| 22 | + if (firstLine) { |
| 23 | + firstLine = false; // Skip header |
| 24 | + continue; |
| 25 | + } |
| 26 | + String[] parts = line.split(";"); |
| 27 | + if (parts.length >= 1 && !parts[0].trim().isEmpty()) { |
| 28 | + codes.add(parts[0].trim()); // Add the code (A, B, C) to list |
| 29 | + } |
| 30 | + } |
| 31 | + } catch (FileNotFoundException e) { |
| 32 | + throw new RuntimeException(e); |
| 33 | + } catch (IOException e) { |
| 34 | + throw new RuntimeException(e); |
| 35 | + } |
| 36 | + |
| 37 | + if (codes.isEmpty()) { |
| 38 | + fail("No valid dropdown code found in WDIRSCodeList.csv"); |
| 39 | + } |
| 40 | + |
| 41 | + // Return a random value from the list |
| 42 | + Random random = new Random(); |
| 43 | + return codes.get(random.nextInt(codes.size())); |
| 44 | + } |
| 45 | +} |
0 commit comments