mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-05 18:16:53 +00:00
deps: Refactor dependencies (#3224)
* remove spring dep move junit, logging, mockito under dep mgmt * upgrade anti-corruption-layer deps * async method invocation * balking, bloc * bridge to bytecode * caching * callback - cqrs * component - health check * hexagonal - metadata mapping * rest of the patterns * remove checkstyle, take spotless into use
This commit is contained in:
+3
-13
@@ -31,9 +31,7 @@ import org.htmlunit.WebClient;
|
||||
import org.htmlunit.html.HtmlAnchor;
|
||||
import org.htmlunit.html.HtmlPage;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Album List page (album-list.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Album List page (album-list.html) */
|
||||
@Slf4j
|
||||
public class AlbumListPage extends Page {
|
||||
private static final String ALBUM_LIST_HTML_FILE = "album-list.html";
|
||||
@@ -41,15 +39,11 @@ public class AlbumListPage extends Page {
|
||||
|
||||
private HtmlPage page;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
/** Constructor. */
|
||||
public AlbumListPage(WebClient webClient) {
|
||||
super(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to the Album List Page.
|
||||
*
|
||||
@@ -64,9 +58,7 @@ public class AlbumListPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isAt() {
|
||||
return "Album List".equals(page.getTitleText());
|
||||
@@ -93,6 +85,4 @@ public class AlbumListPage extends Page {
|
||||
}
|
||||
throw new IllegalArgumentException("No links with the album title: " + albumTitle);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,9 +33,7 @@ import org.htmlunit.html.HtmlSelect;
|
||||
import org.htmlunit.html.HtmlSubmitInput;
|
||||
import org.htmlunit.html.HtmlTextInput;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Album Page (album-page.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Album Page (album-page.html) */
|
||||
@Slf4j
|
||||
public class AlbumPage extends Page {
|
||||
private static final String ALBUM_PAGE_HTML_FILE = "album-page.html";
|
||||
@@ -43,15 +41,11 @@ public class AlbumPage extends Page {
|
||||
|
||||
private HtmlPage page;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
/** Constructor. */
|
||||
public AlbumPage(WebClient webClient) {
|
||||
super(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to the album page.
|
||||
*
|
||||
@@ -66,16 +60,12 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isAt() {
|
||||
return "Album Page".equals(page.getTitleText());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the album title input text field.
|
||||
*
|
||||
@@ -88,7 +78,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the artist input text field.
|
||||
*
|
||||
@@ -101,7 +90,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects the select's option value based on the year value given.
|
||||
*
|
||||
@@ -115,7 +103,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the album rating input text field.
|
||||
*
|
||||
@@ -140,7 +127,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cancel changes made by clicking the cancel button.
|
||||
*
|
||||
@@ -156,7 +142,6 @@ public class AlbumPage extends Page {
|
||||
return new AlbumListPage(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves changes made by clicking the save button.
|
||||
*
|
||||
@@ -171,5 +156,4 @@ public class AlbumPage extends Page {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,9 +32,7 @@ import org.htmlunit.html.HtmlPasswordInput;
|
||||
import org.htmlunit.html.HtmlSubmitInput;
|
||||
import org.htmlunit.html.HtmlTextInput;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Login Page (login.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Login Page (login.html) */
|
||||
@Slf4j
|
||||
public class LoginPage extends Page {
|
||||
private static final String LOGIN_PAGE_HTML_FILE = "login.html";
|
||||
@@ -65,15 +63,12 @@ public class LoginPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isAt() {
|
||||
return "Login".equals(page.getTitleText());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enters the username into the username input text field.
|
||||
*
|
||||
@@ -86,7 +81,6 @@ public class LoginPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enters the password into the password input password field.
|
||||
*
|
||||
@@ -99,7 +93,6 @@ public class LoginPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clicking on the login button to 'login'.
|
||||
*
|
||||
@@ -115,5 +108,4 @@ public class LoginPage extends Page {
|
||||
}
|
||||
return new AlbumListPage(webClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,10 @@ package com.iluwatar.pageobject;
|
||||
|
||||
import org.htmlunit.WebClient;
|
||||
|
||||
/**
|
||||
* Encapsulation for a generic 'Page'.
|
||||
*/
|
||||
/** Encapsulation for a generic 'Page'. */
|
||||
public abstract class Page {
|
||||
|
||||
/**
|
||||
* Application Under Test path This directory location is where html web pages are located.
|
||||
*/
|
||||
/** Application Under Test path This directory location is where html web pages are located. */
|
||||
public static final String AUT_PATH = "../sample-application/src/main/resources/sample-ui/";
|
||||
|
||||
protected final WebClient webClient;
|
||||
@@ -53,6 +49,4 @@ public abstract class Page {
|
||||
* @return true if so, otherwise false
|
||||
*/
|
||||
public abstract boolean isAt();
|
||||
|
||||
|
||||
}
|
||||
|
||||
+1
-4
@@ -30,9 +30,7 @@ import org.htmlunit.WebClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test Album Selection and Album Listing
|
||||
*/
|
||||
/** Test Album Selection and Album Listing */
|
||||
class AlbumListPageTest {
|
||||
|
||||
private final AlbumListPage albumListPage = new AlbumListPage(new WebClient());
|
||||
@@ -48,5 +46,4 @@ class AlbumListPageTest {
|
||||
albumPage.navigateToPage();
|
||||
assertTrue(albumPage.isAt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+9
-12
@@ -30,9 +30,7 @@ import org.htmlunit.WebClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test Album Page Operations
|
||||
*/
|
||||
/** Test Album Page Operations */
|
||||
class AlbumPageTest {
|
||||
|
||||
private final AlbumPage albumPage = new AlbumPage(new WebClient());
|
||||
@@ -45,16 +43,16 @@ class AlbumPageTest {
|
||||
@Test
|
||||
void testSaveAlbum() {
|
||||
|
||||
var albumPageAfterChanges = albumPage
|
||||
.changeAlbumTitle("25")
|
||||
.changeArtist("Adele Laurie Blue Adkins")
|
||||
.changeAlbumYear(2015)
|
||||
.changeAlbumRating("B")
|
||||
.changeNumberOfSongs(20)
|
||||
.saveChanges();
|
||||
var albumPageAfterChanges =
|
||||
albumPage
|
||||
.changeAlbumTitle("25")
|
||||
.changeArtist("Adele Laurie Blue Adkins")
|
||||
.changeAlbumYear(2015)
|
||||
.changeAlbumRating("B")
|
||||
.changeNumberOfSongs(20)
|
||||
.saveChanges();
|
||||
|
||||
assertTrue(albumPageAfterChanges.isAt());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,5 +61,4 @@ class AlbumPageTest {
|
||||
albumListPage.navigateToPage();
|
||||
assertTrue(albumListPage.isAt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-8
@@ -30,9 +30,7 @@ import org.htmlunit.WebClient;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Test Login Page Object
|
||||
*/
|
||||
/** Test Login Page Object */
|
||||
class LoginPageTest {
|
||||
|
||||
private final LoginPage loginPage = new LoginPage(new WebClient());
|
||||
@@ -44,12 +42,8 @@ class LoginPageTest {
|
||||
|
||||
@Test
|
||||
void testLogin() {
|
||||
var albumListPage = loginPage
|
||||
.enterUsername("admin")
|
||||
.enterPassword("password")
|
||||
.login();
|
||||
var albumListPage = loginPage.enterUsername("admin").enterPassword("password").login();
|
||||
albumListPage.navigateToPage();
|
||||
assertTrue(albumListPage.isAt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user