@@ -35,6 +35,7 @@ public class ServerPreviewTest {
3535 private static final String EDIT_URL_LABEL = "Edit URL" ;
3636 private static final String CUSTOM_URL_ICON_CLASS = "fa-external-link" ;
3737 private static final String DEFAULT_URL_ICON_CLASS = "pficon-server" ;
38+ private static final String RESET_BTN_ID = "server-url-form-server-url-form-reset" ;
3839
3940 @ AfterClass
4041 public static void cleanUp () throws IOException {
@@ -50,19 +51,23 @@ public static void cleanUp() throws IOException {
5051
5152 @ Test
5253 public void editUrl () throws IOException {
53- String url = Random .name ();
54+ String host = Random .name ();
5455 FinderFragment fragment = getMainAttributesFinder ();
55- editUrlInFinder (url , fragment );
56+ resetUrlInFinder (fragment );
57+ editHostInFinder (host , fragment );
5658 ServerPreviewFragment serverPreviewFragment = fragment .preview (ServerPreviewFragment .class );
57- Assert .assertEquals ("\" URL\" field contains value set by test" ,
58- serverPreviewFragment .getUrlAttributeItem ().getValueElement ().getText (), url );
59+ Assert .assertTrue ("\" URL\" field contains value set by test" ,
60+ serverPreviewFragment .getUrlAttributeItem ().getValueElement ().getText (). contains ( host ) );
5961 }
6062
6163 @ Test
6264 public void editUrlAndVerifyIsClickable () throws IOException {
63- String url = String .format ("http://localhost:%d" , AvailablePortFinder .getNextAvailableTCPPort ());
65+ String host = "localhost" ;
66+ int port = AvailablePortFinder .getNextAvailableTCPPort ();
67+ String url = String .format ("https://%s:%d" , host , port );
6468 FinderFragment fragment = getMainAttributesFinder ();
65- editUrlInFinder (url , fragment );
69+ resetUrlInFinder (fragment );
70+ editUrlInFinder ("https" , host , port , fragment );
6671 fragment .preview (ServerPreviewFragment .class ).getUrlAttributeItem ().getValueElement ()
6772 .findElement (By .partialLinkText (url )).click ();
6873 verifyBrowserRedirected (url , "Browser should be redirected after clicking on the \" URL\" attribute" );
@@ -73,25 +78,14 @@ public void editUrlAndVerifyIconChanged() throws IOException {
7378 FinderFragment fragment = getMainAttributesFinder ();
7479 selectServer (fragment );
7580 ServerPreviewFragment serverPreviewFragment = fragment .preview (ServerPreviewFragment .class );
76- String className = serverPreviewFragment .getUrlAttributeItem ().getValueElement ()
77- .findElement (ByJQuery .selector ("span > span" ))
78- .getAttribute ("class" );
79- if (className .contains (DEFAULT_URL_ICON_CLASS )) {
80- editUrlInFinder (Random .name (), fragment );
81- verifyIconClass (serverPreviewFragment , CUSTOM_URL_ICON_CLASS ,
82- "Icon for the URL should be custom" );
83- } else if (className .contains (CUSTOM_URL_ICON_CLASS )) {
84- editUrlInFinder ("" , fragment );
85- verifyIconClass (serverPreviewFragment , DEFAULT_URL_ICON_CLASS ,
86- "Icon for the URL should be the one provided by model" );
87- } else {
88- Assert .fail ("Unrecognised icon class" );
89- }
90- }
9181
92- @ Test
93- public void openPorts () {
94- ServerPreviewFragment preview = getMainAttributesFinder ().preview (ServerPreviewFragment .class );
82+ resetUrlInFinder (fragment );
83+ editHostInFinder (Random .name (), fragment );
84+ verifyIconClass (serverPreviewFragment , CUSTOM_URL_ICON_CLASS ,
85+ "Icon for the URL should be custom" );
86+ resetUrlInFinder (fragment );
87+ verifyIconClass (serverPreviewFragment , DEFAULT_URL_ICON_CLASS ,
88+ "Icon for the URL should be the one provided by model" );
9589 }
9690
9791 private void verifyIconClass (ServerPreviewFragment serverPreviewFragment , String iconClass , String assertMessage ) {
@@ -133,10 +127,25 @@ private ItemFragment selectServer(FinderFragment fragment) throws IOException {
133127 }
134128 }
135129
136- private void editUrlInFinder (String url , FinderFragment fragment ) throws IOException {
130+ private void editUrlInFinder (String scheme , String host , int port , FinderFragment fragment ) throws IOException {
137131 selectServer (fragment ).dropdown ().click (EDIT_URL_LABEL );
138132 AddResourceDialogFragment editURLDialog = console .addResourceDialog ();
139- editURLDialog .getForm ().text ("url" , url );
133+ editURLDialog .getForm ().select ("scheme" , scheme );
134+ editURLDialog .getForm ().text ("host" , host );
135+ editURLDialog .getForm ().number ("port" , port );
140136 editURLDialog .add ();
141137 }
138+
139+ private void editHostInFinder (String host , FinderFragment fragment ) throws IOException {
140+ selectServer (fragment ).dropdown ().click (EDIT_URL_LABEL );
141+ AddResourceDialogFragment editURLDialog = console .addResourceDialog ();
142+ editURLDialog .getForm ().text ("host" , host );
143+ editURLDialog .add ();
144+ }
145+
146+ private void resetUrlInFinder (FinderFragment fragment ) throws IOException {
147+ selectServer (fragment ).dropdown ().click (EDIT_URL_LABEL );
148+ AddResourceDialogFragment editURLDialog = console .addResourceDialog ();
149+ editURLDialog .getRoot ().findElement (By .id (RESET_BTN_ID )).click ();
150+ }
142151}
0 commit comments