|
1 | | -//package org.kohsuke.github; |
| 1 | +// package org.kohsuke.github; |
2 | 2 | // |
3 | | -//import org.junit.Assume; |
4 | | -//import org.junit.Before; |
5 | | -//import org.junit.Test; |
| 3 | +// import org.junit.Assume; |
| 4 | +// import org.junit.Before; |
| 5 | +// import org.junit.Test; |
6 | 6 | // |
7 | | -//import java.io.IOException; |
8 | | -//import java.util.List; |
| 7 | +// import java.io.IOException; |
| 8 | +// import java.util.List; |
9 | 9 | // |
10 | | -//import static org.hamcrest.Matchers.equalTo; |
11 | | -//import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
12 | | -//import static org.hamcrest.Matchers.is; |
13 | | -//import static org.hamcrest.Matchers.not; |
| 10 | +// import static org.hamcrest.Matchers.equalTo; |
| 11 | +// import static org.hamcrest.Matchers.greaterThanOrEqualTo; |
| 12 | +// import static org.hamcrest.Matchers.is; |
| 13 | +// import static org.hamcrest.Matchers.not; |
14 | 14 | // |
15 | | -///** |
| 15 | +/// ** |
16 | 16 | // * <p> |
17 | 17 | // * Note : As the code scanning alerts cannot be tailored as part of test setup, lot of the test cases are dependent on |
18 | 18 | // * manual setup of the mock repo. Assertions and verifications will often simply check that the values are non-null |
19 | 19 | // * rather than depending on hard-coded values, to prevent making the tests flimsy |
20 | 20 | // * </p> |
21 | 21 | // */ |
22 | | -//public class GHCodeScanningAlertTest extends AbstractGitHubWireMockTest { |
23 | | -// private static final String REPO_NAME = "Pixi"; |
24 | | -// private GHRepository repo; |
25 | | -// |
26 | | -// /** |
27 | | -// * Gets the mock repo |
28 | | -// * |
29 | | -// * @throws Exception |
30 | | -// * the exception |
31 | | -// */ |
32 | | -// @Before |
33 | | -// public void setUp() throws Exception { |
34 | | -// repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); |
35 | | -// } |
36 | | -// |
37 | | -// /** |
38 | | -// * Test list code scanning alert payload |
39 | | -// */ |
40 | | -// @Test |
41 | | -// public void testListCodeScanningAlerts() { |
42 | | -// // Arrange |
43 | | -// |
44 | | -// // Act - Search by filtering on code scanning tool |
45 | | -// List<GHCodeScanningAlert> codeQlAlerts = repo.listCodeScanningAlerts("CodeQL")._iterator(2).nextPage(); |
46 | | -// |
47 | | -// // Assert |
48 | | -// assertThat(codeQlAlerts.size(), equalTo(2)); // This assertion is based on manual setup done on repo to |
49 | | -// // guarantee there are atleast 2 issues |
50 | | -// |
51 | | -// GHCodeScanningAlert alert = codeQlAlerts.get(0); |
52 | | -// |
53 | | -// // Verify the code scanning tool details |
54 | | -// assertThat(alert.getTool(), not((Object) null)); |
55 | | -// GHCodeScanningAlert.Tool tool = alert.getTool(); |
56 | | -// assertThat(tool.getName(), is("CodeQL")); |
57 | | -// assertThat(tool.getVersion(), not((Object) null)); |
58 | | -// |
59 | | -// // Verify that fields of the code scanning rule are non-null |
60 | | -// assertThat(alert.getRule(), not((Object) null)); |
61 | | -// GHCodeScanningAlert.Rule rule = alert.getRule(); |
62 | | -// assertThat(rule.getId(), not((Object) null)); |
63 | | -// assertThat(rule.getName(), not((Object) null)); |
64 | | -// assertThat(rule.getSeverity(), not((Object) null)); |
65 | | -// |
66 | | -// // Act - Search by filtering on alert status |
67 | | -// List<GHCodeScanningAlert> openAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.OPEN) |
68 | | -// ._iterator(2) |
69 | | -// .nextPage(); // This assertion is based on manual setup done on repo to |
70 | | -// // guarantee there are atleast 2 issues |
71 | | -// |
72 | | -// // Assert |
73 | | -// assertThat(openAlerts.size(), equalTo(2)); |
74 | | -// GHCodeScanningAlert openAlert = openAlerts.get(0); |
75 | | -// assertThat(openAlert.getState(), is(GHCodeScanningAlertState.OPEN)); |
76 | | -// } |
77 | | -// |
78 | | -// /** |
79 | | -// * Test get code scanning alert payload |
80 | | -// * |
81 | | -// * @throws IOException |
82 | | -// * Signals that an I/O exception has occurred. |
83 | | -// */ |
84 | | -// @Test |
85 | | -// public void testGetCodeScanningAlert() throws IOException { |
86 | | -// // Arrange |
87 | | -// List<GHCodeScanningAlert> dismissedAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.DISMISSED) |
88 | | -// ._iterator(1) |
89 | | -// .nextPage(); |
90 | | -// Assume.assumeThat(dismissedAlerts.size(), greaterThanOrEqualTo(1)); |
91 | | -// GHCodeScanningAlert dismissedAlert = dismissedAlerts.get(0); |
92 | | -// long idOfDismissed = dismissedAlert.getId(); |
93 | | -// |
94 | | -// // Act |
95 | | -// GHCodeScanningAlert result = repo.getCodeScanningAlert(idOfDismissed); |
96 | | -// |
97 | | -// // Assert |
98 | | -// assertThat(result, not((Object) null)); |
99 | | -// assertThat(result.getId(), equalTo(idOfDismissed)); |
100 | | -// assertThat(result.getDismissedReason(), equalTo(dismissedAlert.getDismissedReason())); |
101 | | -// assertThat(result.getDismissedAt(), equalTo(dismissedAlert.getDismissedAt())); |
102 | | -// assertThat(result.getDismissedBy().login, equalTo(dismissedAlert.getDismissedBy().login)); |
103 | | -// } |
104 | | -// |
105 | | -//} |
| 22 | +// public class GHCodeScanningAlertTest extends AbstractGitHubWireMockTest { |
| 23 | +// private static final String REPO_NAME = "Pixi"; |
| 24 | +// private GHRepository repo; |
| 25 | +// |
| 26 | +// /** |
| 27 | +// * Gets the mock repo |
| 28 | +// * |
| 29 | +// * @throws Exception |
| 30 | +// * the exception |
| 31 | +// */ |
| 32 | +// @Before |
| 33 | +// public void setUp() throws Exception { |
| 34 | +// repo = gitHub.getRepository(GITHUB_API_TEST_ORG + "/" + REPO_NAME); |
| 35 | +// } |
| 36 | +// |
| 37 | +// /** |
| 38 | +// * Test list code scanning alert payload |
| 39 | +// */ |
| 40 | +// @Test |
| 41 | +// public void testListCodeScanningAlerts() { |
| 42 | +// // Arrange |
| 43 | +// |
| 44 | +// // Act - Search by filtering on code scanning tool |
| 45 | +// List<GHCodeScanningAlert> codeQlAlerts = repo.listCodeScanningAlerts("CodeQL")._iterator(2).nextPage(); |
| 46 | +// |
| 47 | +// // Assert |
| 48 | +// assertThat(codeQlAlerts.size(), equalTo(2)); // This assertion is based on manual setup done on repo to |
| 49 | +// // guarantee there are atleast 2 issues |
| 50 | +// |
| 51 | +// GHCodeScanningAlert alert = codeQlAlerts.get(0); |
| 52 | +// |
| 53 | +// // Verify the code scanning tool details |
| 54 | +// assertThat(alert.getTool(), not((Object) null)); |
| 55 | +// GHCodeScanningAlert.Tool tool = alert.getTool(); |
| 56 | +// assertThat(tool.getName(), is("CodeQL")); |
| 57 | +// assertThat(tool.getVersion(), not((Object) null)); |
| 58 | +// |
| 59 | +// // Verify that fields of the code scanning rule are non-null |
| 60 | +// assertThat(alert.getRule(), not((Object) null)); |
| 61 | +// GHCodeScanningAlert.Rule rule = alert.getRule(); |
| 62 | +// assertThat(rule.getId(), not((Object) null)); |
| 63 | +// assertThat(rule.getName(), not((Object) null)); |
| 64 | +// assertThat(rule.getSeverity(), not((Object) null)); |
| 65 | +// |
| 66 | +// // Act - Search by filtering on alert status |
| 67 | +// List<GHCodeScanningAlert> openAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.OPEN) |
| 68 | +// ._iterator(2) |
| 69 | +// .nextPage(); // This assertion is based on manual setup done on repo to |
| 70 | +// // guarantee there are atleast 2 issues |
| 71 | +// |
| 72 | +// // Assert |
| 73 | +// assertThat(openAlerts.size(), equalTo(2)); |
| 74 | +// GHCodeScanningAlert openAlert = openAlerts.get(0); |
| 75 | +// assertThat(openAlert.getState(), is(GHCodeScanningAlertState.OPEN)); |
| 76 | +// } |
| 77 | +// |
| 78 | +// /** |
| 79 | +// * Test get code scanning alert payload |
| 80 | +// * |
| 81 | +// * @throws IOException |
| 82 | +// * Signals that an I/O exception has occurred. |
| 83 | +// */ |
| 84 | +// @Test |
| 85 | +// public void testGetCodeScanningAlert() throws IOException { |
| 86 | +// // Arrange |
| 87 | +// List<GHCodeScanningAlert> dismissedAlerts = repo.listCodeScanningAlerts(GHCodeScanningAlertState.DISMISSED) |
| 88 | +// ._iterator(1) |
| 89 | +// .nextPage(); |
| 90 | +// Assume.assumeThat(dismissedAlerts.size(), greaterThanOrEqualTo(1)); |
| 91 | +// GHCodeScanningAlert dismissedAlert = dismissedAlerts.get(0); |
| 92 | +// long idOfDismissed = dismissedAlert.getId(); |
| 93 | +// |
| 94 | +// // Act |
| 95 | +// GHCodeScanningAlert result = repo.getCodeScanningAlert(idOfDismissed); |
| 96 | +// |
| 97 | +// // Assert |
| 98 | +// assertThat(result, not((Object) null)); |
| 99 | +// assertThat(result.getId(), equalTo(idOfDismissed)); |
| 100 | +// assertThat(result.getDismissedReason(), equalTo(dismissedAlert.getDismissedReason())); |
| 101 | +// assertThat(result.getDismissedAt(), equalTo(dismissedAlert.getDismissedAt())); |
| 102 | +// assertThat(result.getDismissedBy().login, equalTo(dismissedAlert.getDismissedBy().login)); |
| 103 | +// } |
| 104 | +// |
| 105 | +// } |
0 commit comments