35
35
import org .junit .Test ;
36
36
import org .junit .runners .model .Statement ;
37
37
import org .jvnet .hudson .test .RestartableJenkinsRule ;
38
+ import org .jvnet .hudson .test .RestartableJenkinsRule .Step ;
38
39
39
40
import static org .junit .Assert .assertFalse ;
40
41
import static org .junit .Assert .assertNotNull ;
@@ -69,12 +70,10 @@ private boolean IsWindowsOS() {
69
70
*/
70
71
@ Test
71
72
public void testNegotiateHasConfigPage () {
72
- rule .addStep (new Statement () {
73
- @ Override public void evaluate () throws Throwable {
74
- HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
75
- HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
76
- assertNotNull ("Negotiate configuration page missing." , enabled );
77
- }
73
+ rule .then (r -> {
74
+ HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
75
+ HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
76
+ assertNotNull ("Negotiate configuration page missing." , enabled );
78
77
});
79
78
80
79
}
@@ -84,13 +83,11 @@ public void testNegotiateHasConfigPage() {
84
83
*/
85
84
@ Test
86
85
public void testEnableNegotiate () {
87
- rule .addStep (new Statement () {
88
- @ Override public void evaluate () throws Throwable {
89
- HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
90
- HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
91
- enabled .fireEvent ("click" );
92
- assertNotNull ("Optional block wasn't expanded." , currentPage .getElementByName ("_.redirectEnabled" ));
93
- }
86
+ rule .then (r -> {
87
+ HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
88
+ HtmlElement enabled = currentPage .getElementByName ("_.enabled" );
89
+ enabled .fireEvent ("click" );
90
+ assertNotNull ("Optional block wasn't expanded." , currentPage .getElementByName ("_.redirectEnabled" ));
94
91
});
95
92
}
96
93
@@ -100,32 +97,30 @@ public void testEnableNegotiate() {
100
97
*/
101
98
@ Test
102
99
public void testIfConfigCanBeUpdated () throws Exception {
103
- rule .addStep (new Statement () {
104
- @ Override public void evaluate () throws Throwable {
105
- assertFalse ("Plugin already enabled" , NegotiateSSO .getInstance ().getEnabled ());
106
-
107
- HtmlPage currentPage = rule .j .createWebClient ().goTo ("configureSecurity" );
108
- HtmlForm form = currentPage .getFormByName ("config" );
109
- assertNotNull (form );
100
+ rule .then (r -> {
101
+ assertFalse ("Plugin already enabled" , NegotiateSSO .getInstance ().getEnabled ());
110
102
111
- form . getInputByName ( "_.enabled" ). click ( );
112
- form . getSelectByName ( "_.principalFormat" ). setSelectedAttribute ( "both" , true );
113
- form . getSelectByName ( "_.roleFormat" ). setSelectedAttribute ( "sid" , true );
103
+ HtmlPage currentPage = rule . j . createWebClient (). goTo ( "configureSecurity" );
104
+ HtmlForm form = currentPage . getFormByName ( "config" );
105
+ assertNotNull ( form );
114
106
115
- try {
116
- rule .j .submit (form );
117
- // CS IGNORE EmptyBlock FOR NEXT 3 LINES. REASON: Mocks Tests.
118
- } catch (FailingHttpStatusCodeException e ) {
119
- // Expected since filter cannot be added to Jenkins rule.
120
- }
107
+ form .getInputByName ("_.enabled" ).click ();
108
+ form .getSelectByName ("_.principalFormat" ).setSelectedAttribute ("both" , true );
109
+ form .getSelectByName ("_.roleFormat" ).setSelectedAttribute ("sid" , true );
121
110
122
- boolean wasEnabled = NegotiateSSO .getInstance ().getEnabled ();
123
- if (IsWindowsOS ()) {
124
- assertTrue ("Plugin wasn't enabled after saving the new config" , wasEnabled );
125
- }
126
- else {
127
- assertFalse ("Plugin was enabled on a non-Windows OS" , wasEnabled );
128
- }
111
+ try {
112
+ rule .j .submit (form );
113
+ // CS IGNORE EmptyBlock FOR NEXT 3 LINES. REASON: Mocks Tests.
114
+ } catch (FailingHttpStatusCodeException e ) {
115
+ // Expected since filter cannot be added to Jenkins rule.
116
+ }
117
+
118
+ boolean wasEnabled = NegotiateSSO .getInstance ().getEnabled ();
119
+ if (IsWindowsOS ()) {
120
+ assertTrue ("Plugin wasn't enabled after saving the new config" , wasEnabled );
121
+ }
122
+ else {
123
+ assertFalse ("Plugin was enabled on a non-Windows OS" , wasEnabled );
129
124
}
130
125
});
131
126
}
0 commit comments