mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-19 21:25:38 +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:
@@ -26,14 +26,12 @@ package com.iluwatar.pageobject;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.AlbumListPage;
|
||||
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());
|
||||
@@ -49,5 +47,4 @@ class AlbumListPageTest {
|
||||
albumPage.navigateToPage();
|
||||
assertTrue(albumPage.isAt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,12 @@ package com.iluwatar.pageobject;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.AlbumPage;
|
||||
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());
|
||||
@@ -46,16 +44,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
|
||||
@@ -64,5 +62,4 @@ class AlbumPageTest {
|
||||
albumListPage.navigateToPage();
|
||||
assertTrue(albumListPage.isAt());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,12 @@ package com.iluwatar.pageobject;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.htmlunit.WebClient;
|
||||
import com.iluwatar.pageobject.pages.LoginPage;
|
||||
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());
|
||||
@@ -45,12 +43,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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,15 +24,13 @@
|
||||
*/
|
||||
package com.iluwatar.pageobject.pages;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.html.HtmlAnchor;
|
||||
import org.htmlunit.html.HtmlPage;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Album List page (album-list.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Album List page (album-list.html) */
|
||||
public class AlbumListPage extends Page {
|
||||
|
||||
private static final String ALBUM_LIST_HTML_FILE = "album-list.html";
|
||||
@@ -40,15 +38,11 @@ public class AlbumListPage extends Page {
|
||||
|
||||
private HtmlPage page;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
/** Constructor */
|
||||
public AlbumListPage(WebClient webClient) {
|
||||
super(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to the Album List Page
|
||||
*
|
||||
@@ -63,9 +57,7 @@ public class AlbumListPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean isAt() {
|
||||
return "Album List".equals(page.getTitleText());
|
||||
@@ -92,6 +84,4 @@ public class AlbumListPage extends Page {
|
||||
}
|
||||
throw new IllegalArgumentException("No links with the album title: " + albumTitle);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,18 +24,15 @@
|
||||
*/
|
||||
package com.iluwatar.pageobject.pages;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.html.HtmlNumberInput;
|
||||
import org.htmlunit.html.HtmlOption;
|
||||
import org.htmlunit.html.HtmlPage;
|
||||
import org.htmlunit.html.HtmlSelect;
|
||||
import org.htmlunit.html.HtmlSubmitInput;
|
||||
import org.htmlunit.html.HtmlTextInput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Album Page (album-page.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Album Page (album-page.html) */
|
||||
public class AlbumPage extends Page {
|
||||
|
||||
private static final String ALBUM_PAGE_HTML_FILE = "album-page.html";
|
||||
@@ -43,15 +40,11 @@ public class AlbumPage extends Page {
|
||||
|
||||
private HtmlPage page;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
/** Constructor */
|
||||
public AlbumPage(WebClient webClient) {
|
||||
super(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Navigates to the album page
|
||||
*
|
||||
@@ -66,16 +59,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 +77,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the artist input text field
|
||||
*
|
||||
@@ -101,7 +89,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Selects the select's option value based on the year value given
|
||||
*
|
||||
@@ -115,7 +102,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the album rating input text field
|
||||
*
|
||||
@@ -140,7 +126,6 @@ public class AlbumPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cancel changes made by clicking the cancel button
|
||||
*
|
||||
@@ -156,7 +141,6 @@ public class AlbumPage extends Page {
|
||||
return new AlbumListPage(webClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves changes made by clicking the save button
|
||||
*
|
||||
@@ -171,5 +155,4 @@ public class AlbumPage extends Page {
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,16 +24,14 @@
|
||||
*/
|
||||
package com.iluwatar.pageobject.pages;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.htmlunit.WebClient;
|
||||
import org.htmlunit.html.HtmlPage;
|
||||
import org.htmlunit.html.HtmlPasswordInput;
|
||||
import org.htmlunit.html.HtmlSubmitInput;
|
||||
import org.htmlunit.html.HtmlTextInput;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Page Object encapsulating the Login Page (login.html)
|
||||
*/
|
||||
/** Page Object encapsulating the Login Page (login.html) */
|
||||
public class LoginPage extends Page {
|
||||
|
||||
private static final String LOGIN_PAGE_HTML_FILE = "login.html";
|
||||
@@ -64,15 +62,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
|
||||
*
|
||||
@@ -85,7 +80,6 @@ public class LoginPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Enters the password into the password input password field
|
||||
*
|
||||
@@ -98,7 +92,6 @@ public class LoginPage extends Page {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clicking on the login button to 'login'
|
||||
*
|
||||
@@ -114,5 +107,4 @@ public class LoginPage extends Page {
|
||||
}
|
||||
return new AlbumListPage(webClient);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,14 +26,10 @@ package com.iluwatar.pageobject.pages;
|
||||
|
||||
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 = "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();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user