forked from hub4j/github-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGHRepositoryRuleTest.java
More file actions
124 lines (111 loc) · 4.3 KB
/
Copy pathGHRepositoryRuleTest.java
File metadata and controls
124 lines (111 loc) · 4.3 KB
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
package org.kohsuke.github;
import org.junit.Test;
import org.kohsuke.github.GHRepositoryRule.AlertsThreshold;
import org.kohsuke.github.GHRepositoryRule.CodeScanningTool;
import org.kohsuke.github.GHRepositoryRule.Operator;
import org.kohsuke.github.GHRepositoryRule.Parameter;
import org.kohsuke.github.GHRepositoryRule.Parameters;
import org.kohsuke.github.GHRepositoryRule.SecurityAlertsThreshold;
import org.kohsuke.github.GHRepositoryRule.StatusCheckConfiguration;
import org.kohsuke.github.GHRepositoryRule.StringParameter;
import org.kohsuke.github.GHRepositoryRule.WorkflowFileReference;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThrows;
/**
* Test class for GHRepositoryRule.
*/
public class GHRepositoryRuleTest extends AbstractGitHubWireMockTest {
/**
* Create default GHRepositoryRuleTest instance
*/
public GHRepositoryRuleTest() {
}
/**
* Tests to cover AlertsThreshold enum.
*/
@Test
public void testAlertsThreshold() {
assertThat(AlertsThreshold.ERRORS, is(notNullValue()));
}
/**
* Tests to cover CodeScanningTool class.
*/
@Test
public void testCodeScanningTool() {
CodeScanningTool codeScanningTool = new CodeScanningTool();
codeScanningTool = new CodeScanningTool();
assertThat(codeScanningTool.getAlertsThreshold(), is(nullValue()));
assertThat(codeScanningTool.getSecurityAlertsThreshold(), is(nullValue()));
assertThat(codeScanningTool.getTool(), is(nullValue()));
}
/**
* Tests to cover Operator enum.
*/
@Test
public void testOperator() {
assertThat(Operator.ENDS_WITH, is(notNullValue()));
}
/**
* Tests that apply on null JsonNode returns null.
*
* @throws Exception
* if something goes wrong.
*/
@Test
public void testParameterReturnsNullOnNullArg() throws Exception {
Parameter<String> parameter = new StringParameter("any");
assertThat(parameter.apply(null, null), is(nullValue()));
}
/**
* Test to cover the constructor of the Parameters class.
*
* @throws Exception
* if something goes wrong.
*/
@Test
public void testParameters() throws Exception {
assertThat(Parameters.REQUIRED_DEPLOYMENT_ENVIRONMENTS, is(notNullValue()));
assertThat(Parameters.REQUIRED_STATUS_CHECKS, is(notNullValue()));
assertThat(Parameters.OPERATOR, is(notNullValue()));
assertThat(Parameters.WORKFLOWS, is(notNullValue()));
assertThat(Parameters.CODE_SCANNING_TOOLS, is(notNullValue()));
assertThat(Parameters.CODE_SCANNING_TOOLS.apply("[]", this.gitHub), is(notNullValue()));
assertThat(new StringParameter("any"), is(notNullValue()));
assertThrows(GHException.class, () -> new GHRepositoryRule.ListParameter<Object>("") {
});
assertThrows(GHException.class, () -> new GHRepositoryRule.Parameter<Object>("") {
});
}
/**
* Tests to cover SecurityAlertsThreshold enum.
*/
@Test
public void testSecurityAlertsThreshold() {
assertThat(SecurityAlertsThreshold.HIGH_OR_HIGHER, is(notNullValue()));
}
/**
* Tests to cover StatusCheckConfiguration class.
*/
@Test
public void testStatusCheckConfiguration() {
StatusCheckConfiguration statusCheckConfiguration = new StatusCheckConfiguration();
statusCheckConfiguration = new StatusCheckConfiguration();
assertThat(statusCheckConfiguration.getContext(), is(nullValue()));
assertThat(statusCheckConfiguration.getIntegrationId(), is(nullValue()));
}
/**
* Tests to cover WorkflowFileReference class.
*/
@Test
public void testWorkflowFileReference() {
WorkflowFileReference workflowFileReference = new WorkflowFileReference();
assertThat(workflowFileReference.getPath(), is(nullValue()));
assertThat(workflowFileReference.getRef(), is(nullValue()));
assertThat(workflowFileReference.getRepositoryId(), is(equalTo(0L)));
assertThat(workflowFileReference.getSha(), is(nullValue()));
}
}