Skip to content

Commit

Permalink
refactor: rename Page.page to differ from class
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan-Zollinger committed Mar 24, 2024
1 parent 7ee0049 commit 19d6581
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/graqr/threshr/Threshr.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public Store getStore(String storeId) throws ThreshrException {
@Get("/stores/id")
@SingleResult
public Store getStore(String storeId, String channel, Page page) throws ThreshrException {
return checkForNull(threshrClient.getStore(storeId, channel, page.getPage())).data().store();
return checkForNull(threshrClient.getStore(storeId, channel, page.getName())).data().store();
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/com/graqr/threshr/model/queryparam/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
@Getter
public class Page {
private String page;
private String name;

/**
* Sets string value as "/c/" + provided value.
Expand All @@ -17,24 +17,24 @@ public class Page {
* @throws ThreshrException if string contains anything other than letters or is empty
*/
public Page(String page) throws ThreshrException {
setPage(page);
setName(page);
}

/**
* Sets string value as "/c/" + provided value.
*
* @param page Query parameter in redsky api to specify from where an api call is made in the browser
* @param name Query parameter in redsky api to specify from where an api call is made in the browser
* @throws ThreshrException if string contains anything other than letters or is empty
*/
public void setPage(String page) throws ThreshrException {
String tempPage = page.trim().toLowerCase();
public void setName(String name) throws ThreshrException {
String tempPage = name.trim().toLowerCase();
if (tempPage.startsWith("/c/")) {
tempPage = tempPage.substring(3);
}
if (tempPage.matches(".+([^(a-z|\\-)]).+") || tempPage.isEmpty()) {
throw new ThreshrException(String.format(
"Expected only letters for the page value, but received \"%s\".", tempPage));
}
this.page = "/c/" + tempPage;
this.name = "/c/" + tempPage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ class PageSpec extends Specification {
page = new Page(pageValue) //assumed data has "/c/" prepended to string

then:
page.getPage() == pageValue
page.getName() == pageValue

and:
page.setPage(pageValue.replace("/c/", ""))
page.setName(pageValue.replace("/c/", ""))

then:
page.getPage() == pageValue
page.getName() == pageValue

where:
pageValue << Stream.of(expectedPages).map(it -> {
Expand Down

0 comments on commit 19d6581

Please sign in to comment.