Advertisement
Guest User

PentruGeani

a guest
Oct 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.31 KB | None | 0 0
  1. <version>4.12</version>
  2. <scope>test</scope>
  3. </dependency>
  4. <dependency>
  5. <groupId>com.fasterxml.jackson.core</groupId>
  6. <artifactId>jackson-databind</artifactId>
  7. <version>2.7.0</version>
  8. </dependency>
  9. </dependencies>
  10.  
  11. <!--
  12. }
  13. return value;
  14. }
  15. public MobileElement getLabelElementByName(String labelName){
  16. for(int i=0;i<accountOptionLabel.size();i++){
  17. String text=CommonTask.getText(accountOptionLabel.get(i),"");
  18. testInfo("label name " + text);
  19. if(text.equals(labelName)){
  20. return accountOptionLabel.get(i);
  21. }
  22. }
  23. return null;
  24. }
  25.  
  26. public Integer getLabelPositionByName(String labelName){
  27. for(int i=0;i<accountOptionLabel.size();i++){
  28. String text=CommonTask.getText(accountOptionLabel.get(i),"");
  29. testInfo("position by name: " + text);
  30. if(text.equals(labelName)){
  31. return i;
  32. }
  33. }
  34. return null;
  35. }
  36.  
  37. public String getValueByName(String name){
  38. Integer i=getLabelPositionByName(name);
  39. String text=CommonTask.getText(accountOptionValue.get(i),"");
  40. testInfo("value by name : " + text);
  41. return text;
  42. }
  43. public Integer getWSGarnishmentNbr(){
  44. JsonArray jsonArray = getAccountListFor(AccountType.CURRENT_ACCOUNT, AccountFetchOption.NICKNAME_PRODUCT_GARNISHMENT);
  45.  
  46. for (JsonElement anAccountListArray : jsonArray) {
  47. JsonObject idObj = anAccountListArray.getAsJsonObject();
  48. if (idObj.get("holds") != null) {
  49. JsonArray holdsFirstArray = idObj.get("holds").getAsJsonArray();
  50. return holdsFirstArray.size();
  51. }
  52. }
  53.  
  54. return null;
  55. }
  56.  
  57. }
  58. package com.athena.appium.pages.templates;
  59.  
  60. import com.athena.appium.pages.templates.beans.Template;
  61. import com.athena.appium.pages.templates.beans.TemplateValues;
  62. import com.athena.appium.utils.commonMethods.CommonTask;
  63. import com.athena.appium.utils.testdata.TestData;
  64. import io.appium.java_client.AppiumDriver;
  65. import io.appium.java_client.MobileElement;
  66. import io.appium.java_client.pagefactory.AndroidFindAll;
  67. import io.appium.java_client.pagefactory.AndroidFindBy;
  68.  
  69. import java.util.ArrayList;
  70. import java.util.List;
  71.  
  72. public class TemplateDetailsPage extends TemplatesPage {
  73.  
  74. @AndroidFindAll({@AndroidFindBy(id= TestData.APP_LOCATOR_PRE + ":id/tv_toolbar_title"),
  75. @AndroidFindBy(id= TestData.APP_LOCATOR + ":id/tv_toolbar_title")})
  76. private MobileElement templateDetailsHeader;
  77.  
  78.  
  79. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/ib_favourite"),
  80. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/ib_favourite")})
  81. private MobileElement templateDetailsFavourite;
  82.  
  83.  
  84. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/contact_image"),
  85. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/contact_image")})
  86. private MobileElement templateDetailsContactImg;
  87.  
  88.  
  89. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/contact_name"),
  90. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/contact_name")})
  91. private MobileElement templateDetailsContactName;
  92.  
  93.  
  94. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/new_payment_button"),
  95. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/new_payment_button")})
  96. private MobileElement templateDetailsPaymentButton;
  97.  
  98. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/row_title"),
  99. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/row_title")})
  100. private List<MobileElement> templateDetailsRowTitle;
  101.  
  102.  
  103. @AndroidFindAll({@AndroidFindBy(id=TestData.APP_LOCATOR_PRE + ":id/row_details"),
  104. @AndroidFindBy(id=TestData.APP_LOCATOR + ":id/row_details")})
  105. private List<MobileElement> templateDetailsRow;
  106.  
  107.  
  108. public TemplateDetailsPage(AppiumDriver driver) {
  109. super(driver);
  110. }
  111.  
  112. public List<String> getDetailsPageLabels(){
  113. List<String> lst = new ArrayList<>();
  114. for(int i=0;i<templateDetailsRowTitle.size();i++){
  115. lst.add(CommonTask.getText(templateDetailsRowTitle.get(i),"det page labels"));
  116. }
  117. return lst;
  118. }
  119. public TemplateValues getTemplateLabels(String actionId){
  120. TemplateValues labels = new TemplateValues();
  121. labels.setName(CommonTask.getText(templateDetailsRowTitle.get(0),"get template name label"));
  122. labels.setFromAccount(CommonTask.getText(templateDetailsRowTitle.get(1),"get template from account " +
  123. "label"));
  124. CommonTask.shortSwipeVertical(driver);
  125. labels.setToAccount(CommonTask.getText(templateDetailsRowTitle.get(2),"get template to account " +
  126. "label"));
  127.  
  128.  
  129. if(actionId.equals("0111")|| actionId.equals("0137")){
  130. labels.setBeneficiary(CommonTask.getText(templateDetailsRowTitle.get(3), "get template " +
  131. "beneficiary name label"));
  132. CommonTask.shortSwipeVertical(driver);
  133. labels.setDetails(CommonTask.getText(templateDetailsRowTitle.get(4), "get template details " +
  134. "label"));
  135. }
  136.  
  137. if(actionId.equals("0003")|| actionId.equals("0009")||actionId.equals("0110")){
  138. labels.setDetails(CommonTask.getText(templateDetailsRowTitle.get(3), "get template details " +
  139. "label"));
  140. }
  141. return labels;
  142. }
  143.  
  144. public TemplateValues getTemplateValues(String actionId){
  145. TemplateValues labels = new TemplateValues();
  146. labels.setName(CommonTask.getText(templateDetailsRow.get(0),"get template name value"));
  147. labels.setFromAccount(CommonTask.getText(templateDetailsRow.get(1),"get template from account" +
  148. " value"));
  149.  
  150. labels.setToAccount(CommonTask.getText(templateDetailsRow.get(2),"get template to account value"));
  151. CommonTask.shortSwipeVertical(driver);
  152. if(actionId.equals("0111")|| actionId.equals("0137")){
  153. labels.setBeneficiary(CommonTask.getText(templateDetailsRow.get(3), "get template " +
  154. "beneficiary name value"));
  155. CommonTask.shortSwipeVertical(driver);
  156. labels.setDetails(CommonTask.getText(templateDetailsRow.get(4), "get template details value"));
  157. }
  158.  
  159.  
  160. if(actionId.equals("0003")|| actionId.equals("0009")||actionId.equals("0110")){
  161. labels.setDetails(CommonTask.getText(templateDetailsRow.get(3), "get template details value"));
  162. }
  163. return labels;
  164. }
  165.  
  166. public List<String> getDetailsPageValues(){
  167. List<String> ls=new ArrayList<>();
  168. for(int i=0;i<templateDetailsRow.size();i++){
  169. ls.add(CommonTask.getText(templateDetailsRow.get(i),"det page values"));
  170. }
  171. return ls;
  172. }
  173. }
  174. package com.athena.appium.pages.templates;
  175.  
  176. public class TemplatesConstants {
  177.  
  178.  
  179. //general
  180.  
  181. public static final String TEMPLATE_NAME1="conturiproprii";
  182. // public static final String TEMPLATE_NAME2="testluci";
  183. public static final String TEMPLATE_NAME3="test";
  184. public static final String TEMPLATE_NAME4="testluci";
  185.  
  186.  
  187. //labels EN
  188.  
  189. public static final String TEMPLATES_TAB_NAME_EN="Templates";
  190. public static final String TEMPLATES_HEADER_NAME_EN="Templates";
  191. public static final String TEMPLATES_FAVOURITES_TITLE_EN="Favourites";
  192. public static final String TEMPLATES_ALLTEMPLATES_TITLE_EN="All templates";
  193. public static final String TEMPLATES_ALLFAVOURITES_EN="All favourites";
  194. public static final String TEMPLATE_DETAILS_TEMPLATE_NAME_EN="TEMPLATE NAME";
  195. public static final String TEMPLATE_DETAILS_FROM_ACCOUNT_EN="FROM ACCOUNT";
  196. public static final String TEMPLATE_DETAILS_TO_ACCOUNT_EN="TO ACCOUNT";
  197. public static final String TEMPLATE_DETAILS_PAYMENT_DETAILS_EN="PAYMENT DETAILS";
  198. public static final String TEMPLATE_DETAILS_BENEFICIARY_NAME_EN="BENEFICIARY NAME";
  199.  
  200.  
  201. //labels RO
  202.  
  203. public static final String TEMPLATES_TAB_NAME_RO="Sabloane";
  204. public static final String TEMPLATES_HEADER_NAME_RO="Sabloane";
  205. public static final String TEMPLATES_FAVOURITES_TITLE_RO="Favorite";
  206. public static final String TEMPLATES_ALLTEMPLATES_TITLE_RO="Toate sabloanele";
  207. public static final String TEMPLATES_ALLFAVOURITES_RO="Toate sabloanele favorite";
  208. public static final String TEMPLATE_DETAILS_TEMPLATE_NAME_RO="NUME SABLON";
  209. public static final String TEMPLATE_DETAILS_FROM_ACCOUNT_RO="DIN CONTUL";
  210. public static final String TEMPLATE_DETAILS_TO_ACCOUNT_RO="IN CONTUL";
  211. public static final String TEMPLATE_DETAILS_PAYMENT_DETAILS_RO="DETALII PLATA";
  212. public static final String TEMPLATE_DETAILS_BENEFICIARY_NAME_RO="NUME BENEFICIAR";
  213.  
  214. }
  215. package com.athena.appium.pages.templates;
  216.  
  217. import com.athena.appium.utils.Log4Test;
  218. import com.athena.appium.utils.commonMethods.CommonRestTask;
  219. import com.athena.appium.utils.commonMethods.CommonTask;
  220. import com.athena.appium.utils.enums.EndPoint;
  221. import com.athena.appium.utils.testdata.TestData;
  222. import com.athena.appium.pages.DashboardPage;
  223.  
  224. import com.athena.appium.pages.templates.beans.AccountsInfo;
  225. import com.athena.appium.pages.templates.beans.Template;
  226. import com.fasterxml.jackson.core.type.TypeReference;
  227. import io.appium.java_client.AppiumDriver;
  228. import io.appium.java_client.MobileBy;
  229. import io.appium.java_client.MobileElement;
  230. import io.appium.java_client.pagefactory.AndroidFindAll;
  231. import io.appium.java_client.pagefactory.AndroidFindBy;
  232. import com.fasterxml.jackson.databind.ObjectMapper;
  233. import org.apache.log4j.Logger;
  234. import org.testng.Assert;
  235.  
  236. import java.io.IOException;
  237. import java.util.Collections;
  238. import java.util.List;
  239.  
  240. /**
  241. * Created by LucianaD
  242. */
  243.  
  244. public class TemplatesPage extends DashboardPage {
  245. private static final Logger LOGGER = Logger.getLogger(TemplatesPage.class);
  246.  
  247.  
  248. public TemplatesPage(AppiumDriver driver) {
  249. super(driver);
  250. }
  251.  
  252. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/nav_templates_btn"),
  253. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/nav_templates_btn")})
  254. private MobileElement templatesBtn;
  255.  
  256.  
  257. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/template_label"),
  258. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/template_label")})
  259. private MobileElement templatesTab;
  260.  
  261.  
  262. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/tv_toolbar_title"),
  263. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/tv_toolbar_title")})
  264. private MobileElement templatesHeader;
  265.  
  266.  
  267. @AndroidFindAll({ @AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/search_src_text"),
  268. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/search_src_text")})
  269. private MobileElement templatesSearch;
  270.  
  271.  
  272. @AndroidFindAll({ @AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/search_close_btn"),
  273. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/search_close_btn")})
  274. private MobileElement templatesSearchCloseButton;
  275.  
  276.  
  277. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/fav_contact_image"),
  278. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/fav_contact_image")})
  279. private List<MobileElement> templatesFavContactImage;
  280.  
  281.  
  282. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/favourites_title"),
  283. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/favourites_title")})
  284. private MobileElement templatesFavouritesTitle;
  285.  
  286.  
  287. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/show_more_textview"),
  288. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/show_more_textview")})
  289. private MobileElement templatesAllFavourites;
  290.  
  291.  
  292. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/templates_title"),
  293. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/templates_title")})
  294. private MobileElement templatesAllTemplatesTitle;
  295.  
  296.  
  297. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/contact_image"),
  298. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/contact_image")})
  299. private List<MobileElement> templatesContactImage;
  300.  
  301.  
  302. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/contact_name"),
  303. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/contact_name")})
  304. private List<MobileElement> templatesContactName;
  305.  
  306.  
  307. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/contact_iban"),
  308. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/contact_iban")})
  309. private List<MobileElement> templatesContactIban;
  310.  
  311.  
  312. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/new_payment_button"),
  313. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/new_payment_button")})
  314. private List<MobileElement> templatesNewPaymentButton;
  315.  
  316.  
  317. @AndroidFindAll({@AndroidFindBy( id = TestData.APP_LOCATOR_PRE + ":id/add_to_favourites_button"),
  318. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/add_to_favourites_button")})
  319. private List<MobileElement> templatesAddToFavButton;
  320.  
  321.  
  322. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/delete_contact_button"),
  323. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/delete_contact_button")})
  324. private List<MobileElement> templatesDeleteContactButton;
  325.  
  326.  
  327. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/contact_row"),
  328. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/contact_row")})
  329. private List<MobileElement> templatesContactRow;
  330.  
  331.  
  332. @AndroidFindAll({@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/no_templates_title"),
  333. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/no_templates_title")})
  334. private MobileElement noTemplatesLabel;
  335.  
  336.  
  337. @AndroidFindBy(id = "android:id/button1")
  338. private MobileElement templatesDeleteButton;
  339.  
  340. @AndroidFindBy(id = "android:id/button2")
  341. private MobileElement templatesDeleteCancelButton;
  342.  
  343.  
  344. @AndroidFindAll( {@AndroidFindBy(id = TestData.APP_LOCATOR_PRE + ":id/tv_message"),
  345. @AndroidFindBy(id = TestData.APP_LOCATOR + ":id/tv_message")})
  346. private MobileElement templatesConfirmationDeleteMessage;
  347.  
  348.  
  349.  
  350. private ObjectMapper mapper = new ObjectMapper();
  351.  
  352.  
  353. public String getTextNoTemplates() {
  354. String textNoTemp = CommonTask.getText(noTemplatesLabel, "no templates text");
  355. return textNoTemp;
  356. }
  357.  
  358. public String getTextTemplatesTab() {
  359. String textTempTab = CommonTask.getText(templatesTab, "templates tab");
  360. return textTempTab;
  361. }
  362.  
  363. public Boolean isEnabledTemplatesTab() {
  364. Boolean enabledTempTab = CommonTask.isEnabled(templatesBtn, "templates tab enabled");
  365. return enabledTempTab;
  366.  
  367. }
  368.  
  369. public String getTextTemplatesHeader() {
  370. String textTempHeader = CommonTask.getText(templatesHeader, "templates header");
  371. return textTempHeader;
  372. }
  373.  
  374. public String getTextAllTemplatesTitle() {
  375. String textAllTemp = CommonTask.getText(templatesAllTemplatesTitle, "all templates ");
  376. return textAllTemp;
  377.  
  378. }
  379.  
  380. public String getTextFavouritesTitle() {
  381. String textFav = CommonTask.getText(templatesFavouritesTitle, "favourites title");
  382. return textFav;
  383. }
  384.  
  385. public String getTextTemplateName() {
  386. if (templatesContactName.size() > 0) {
  387. return CommonTask.getText(templatesContactName.get(0), "template name");
  388. }
  389. return null;
  390. }
  391.  
  392. public Boolean isEditableTemplatesSearch() {
  393. return CommonTask.isElementEnabledAndDisplayed(templatesSearch, "search Icon");
  394. }
  395.  
  396.  
  397. public void tapTemplatesFilter() {
  398. CommonTask.tapButton(driver, templatesSearch, "templates filter");
  399. }
  400.  
  401. public void setTemplatesSearchField(String textToSearch) {
  402. CommonTask.sendKeys(templatesSearch, textToSearch, "templates search field");
  403. driver.hideKeyboard();
  404. }
  405.  
  406. public void clearTemplatesSearchField() {
  407. CommonTask.tapButton(driver, templatesSearchCloseButton, "templates close");
  408. }
  409.  
  410.  
  411. /**
  412. * Returns the position of the given contactLabelName in the templates contact name list
  413. * Returns null if not found
  414. *
  415. * @param contactLabelName
  416. * @return
  417. */
  418. private Integer getIndexTemplatesContactName(String contactLabelName) {
  419. for (int i = 0; i < templatesContactName.size(); i++) {
  420. String textFound = CommonTask.getText(templatesContactName.get(i), "");
  421.  
  422. if (textFound.equalsIgnoreCase(contactLabelName)) {
  423. return i;
  424. }
  425. }
  426. return null;
  427. }
  428. public boolean hasTemplatesContactName(String contactLabelName) {
  429. for (int i = 0; i < templatesContactName.size(); i++) {
  430. String textFound = CommonTask.getText(templatesContactName.get(i), "");
  431.  
  432. if (textFound.equalsIgnoreCase(contactLabelName)) {
  433. return true;
  434. }
  435. }
  436. return false;
  437. }
  438.  
  439. public void clickTemplatesContactNameLabel(String contactName) {
  440. Integer index = getIndexTemplatesContactName(contactName);
  441. if (index != null) {
  442. templatesContactName.get(index).click();
  443.  
  444. }
  445.  
  446. }
  447.  
  448. public void clickTemplatesFavouriteButton(String contactName) {
  449. Integer index = getIndexTemplatesContactName(contactName);
  450. if (index != null) {
  451. CommonTask.tapButton(driver, templatesAddToFavButton.get(index), "add to favourite button");
  452.  
  453. }
  454. }
  455.  
  456. /**
  457. * Active the favourite if is not already enabled.
  458. * @param template
  459. */
  460. public void enableTemplateFavouriteButton(Template template){
  461. if(!template.getFavorite()){
  462. clickTemplatesFavouriteButton(template.getName());
  463. }
  464. }
  465. public void clickTemplatesNewPaymentButton(String contactName) {
  466. Integer index = getIndexTemplatesContactName(contactName);
  467. if (index != null) {
  468. CommonTask.tapButton(driver, templatesNewPaymentButton.get(index), " new payment button");
  469. }
  470. }
  471.  
  472. public void deleteTemplatesContactButton(String contactName) {
  473. Integer index = getIndexTemplatesContactName(contactName);
  474. if (index != null) {
  475. CommonTask.tapButton(driver, templatesDeleteContactButton.get(index), " delete contact button");
  476. }
  477. }
  478.  
  479. public void deleteTemplatesConfirmation() {
  480. CommonTask.tapButton(driver, templatesDeleteButton, "delete template");
  481. CommonTask.getText(templatesConfirmationDeleteMessage, "confirmation delete template message");
  482. }
  483.  
  484. public void deleteTemplatesCancel() {
  485. CommonTask.tapButton(driver, templatesDeleteButton, "camcel delete template");
  486. }
  487.  
  488. public List<Template> getListOfTemplatesFromWS() {
  489. String response = CommonRestTask.getStringFromEndpoint(EndPoint.TEMPLATES.getValue(), cookie);
  490. Log4Test.info(response);
  491. List<Template> templates = null;
  492. if (response != null && !response.isEmpty()) {
  493. try {
  494. templates = mapper.readValue(response, new TypeReference<List<Template>>() {
  495. });
  496. // Collections.sort(templates);;
  497. } catch (IOException e) {
  498. LOGGER.warn("Read value exception", e);
  499. Assert.fail("Cannot read templates from WS");
  500. }
  501. }
  502. return templates;
  503. }
  504.  
  505. public List<AccountsInfo> getListOfAccountsFromWS() {
  506. String response = CommonRestTask.getStringFromEndpoint(EndPoint.ACCOUNT_LIST_OPT.getValue(), cookie);
  507. Log4Test.info(EndPoint.ACCOUNT_LIST_OPT.getValue());
  508. Log4Test.info(response);
  509. List<AccountsInfo> accounts = null;
  510. if (response != null && !response.isEmpty()) {
  511. try {
  512. accounts = mapper.readValue(response, new TypeReference<List<AccountsInfo>>() {
  513. });
  514. //Collections.sort(accounts);;
  515. } catch (IOException e) {
  516. LOGGER.warn("Read value exception", e);
  517. Assert.fail("Cannot read templates from WS");
  518. }
  519. }
  520. return accounts;
  521. }
  522.  
  523.  
  524. public String getAllTemplatesTitle(){
  525. List<Template> listOfTemplatesFromWS = getListOfTemplatesFromWS();
  526. if (listOfTemplatesFromWS != null && listOfTemplatesFromWS.size() > 0) {
  527. return getTextAllTemplatesTitle();
  528.  
  529. } else {
  530. return TemplatesConstants.TEMPLATES_ALLTEMPLATES_TITLE_EN;
  531. }
  532. }
  533.  
  534. public Template getFirstTemplateFromWs(){
  535. List<Template> templates = getListOfTemplatesFromWS();
  536. if(templates!=null && templates.size()>0) {
  537. return templates.get(0);
  538. }else{
  539. Assert.fail("No templates defined in WS!");
  540. return null;
  541. }
  542. }
  543. public Template getSecondTemplateFromWs(){
  544. List<Template> templates = getListOfTemplatesFromWS();
  545. if(templates!=null && templates.size()>1) {
  546. return templates.get(1);
  547. }else{
  548. Assert.fail("No templates defined in WS!");
  549. return null;
  550. }
  551. }
  552.  
  553. public Template getTemplateFromWSWithActId(String actionId){
  554. List<Template> templates = getListOfTemplatesFromWS();
  555. for(int i=0;i<templates.size();i++){
  556. Template temp=templates.get(i);
  557. if(actionId.equals(temp.getActionId())){
  558. return temp;
  559. }
  560. }
  561. return null;
  562. }
  563. public AccountsInfo getAccountDetailsFromWS(String iban) {
  564. String accountId = TemplatesUtils.getAccountIdFromIban(iban);
  565. String response = CommonRestTask.getStringFromEndpoint
  566. (EndPoint.ACCOUNT_LIST.getValue("?id=" + accountId + "&typeId=20&fetchOptions=NICKNAME"), cookie);
  567.  
  568.  
  569. Log4Test.info("getAccountDetailsFromWS ##############" + response);
  570. Log4Test.info("getAccountDetailsFromWS ##############" + EndPoint.ACCOUNT_LIST
  571. .getValue("?id=" + accountId + "&fetchOptions=NICKNAME"));
  572. AccountsInfo info = null;
  573. if (response != null && !response.isEmpty()) {
  574. try {
  575. info = mapper.readValue(response, AccountsInfo.class);
  576.  
  577. } catch (IOException e) {
  578. LOGGER.warn("Read value exception", e);
  579. }
  580. }
  581. Log4Test.info(response);
  582.  
  583.  
  584. return info;
  585. }
  586.  
  587.  
  588. }
  589.  
  590.  
  591.  
  592.  
  593. package com.athena.appium.pages.templates;
  594.  
  595. public class TemplatesUtils {
  596. public final static int ACCOUNT_ID_LENGTH=10;
  597.  
  598. public static String getAccountIdFromIban(String iban){
  599.  
  600. int x=iban.length();
  601. int z=x-ACCOUNT_ID_LENGTH;
  602. return iban.substring(z);
  603. }
  604.  
  605. }
  606. package com.athena.appium.pages.templates.beans;
  607.  
  608. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  609.  
  610. @JsonIgnoreProperties(ignoreUnknown = true)
  611. public class AccountsInfo {
  612.  
  613. private String iban;
  614. private String nickname;
  615.  
  616. public String getIban() {
  617. return iban;
  618. }
  619.  
  620. public void setIban(String iban) {
  621. this.iban = iban;
  622. }
  623.  
  624. public String getNickname() {
  625. return nickname;
  626. }
  627.  
  628. public void setNickname(String nickname) {
  629. this.nickname = nickname;
  630. }
  631. }
  632. package com.athena.appium.pages.templates.beans;
  633.  
  634. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  635.  
  636. @JsonIgnoreProperties(ignoreUnknown = true)
  637. public class Payee {
  638. private String fullName;
  639.  
  640. public String getFullName() {
  641. return fullName;
  642. }
  643.  
  644. public void setFullName(String fullName) {
  645. this.fullName = fullName;
  646. }
  647. }
  648. package com.athena.appium.pages.templates.beans;
  649.  
  650. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  651.  
  652. import java.util.List;
  653.  
  654. @JsonIgnoreProperties(ignoreUnknown = true)
  655. public class Template implements Comparable<Template>{
  656. private String actionId;
  657. private String currency;
  658. private List<String> details;
  659. private TemplateAccount fromAccount;
  660. private TemplateAccount toAccount;
  661. private Long templateId;
  662. private String name;
  663. private String beneficiaryName;
  664. private Boolean smAvailability;
  665. private Boolean favorite;
  666. private String avatarName;
  667. private Payee payee;
  668.  
  669. public String getCurrency() {
  670. return currency;
  671. }
  672.  
  673. public void setCurrency(String currency) {
  674. this.currency = currency;
  675. }
  676.  
  677. public TemplateAccount getFromAccount() {
  678. return fromAccount;
  679. }
  680.  
  681. public void setFromAccount(TemplateAccount fromAccount) {
  682. this.fromAccount = fromAccount;
  683. }
  684.  
  685. public TemplateAccount getToAccount() {
  686. return toAccount;
  687. }
  688.  
  689. public void setToAccount(TemplateAccount toAccount) {
  690. this.toAccount = toAccount;
  691. }
  692.  
  693. public Long getTemplateId() {
  694. return templateId;
  695. }
  696.  
  697. public void setTemplateId(Long templateId) {
  698. this.templateId = templateId;
  699. }
  700.  
  701. public String getName() {
  702. return name;
  703. }
  704.  
  705. public void setName(String name) {
  706. this.name = name;
  707. }
  708.  
  709. public String getBeneficiaryName() {
  710. return beneficiaryName;
  711. }
  712.  
  713. public void setBeneficiaryName(String beneficiaryName) {
  714. this.beneficiaryName = beneficiaryName;
  715. }
  716.  
  717. public Boolean getSmAvailability() {
  718. return smAvailability;
  719. }
  720.  
  721. public void setSmAvailability(Boolean smAvailability) {
  722. this.smAvailability = smAvailability;
  723. }
  724.  
  725. public Boolean getFavorite() {
  726. return favorite;
  727. }
  728.  
  729. public void setFavorite(Boolean favorite) {
  730. this.favorite = favorite;
  731. }
  732.  
  733. public String getAvatarName() {
  734. return avatarName;
  735. }
  736.  
  737. public void setAvatarName(String avatarName) {
  738. this.avatarName = avatarName;
  739. }
  740.  
  741. public String getActionId() {
  742. return actionId;
  743. }
  744.  
  745. public void setActionId(String actionId) {
  746. this.actionId = actionId;
  747. }
  748.  
  749. public List<String> getDetails() {
  750. return details;
  751. }
  752.  
  753. public void setDetails(List<String> details) {
  754. this.details = details;
  755. }
  756.  
  757. public Payee getPayee() {
  758. return payee;
  759. }
  760.  
  761. public void setPayee(Payee payee) {
  762. this.payee = payee;
  763. }
  764.  
  765. @Override
  766. public int compareTo(Template o) {
  767. return this.getName().compareTo(o.getName());
  768. }
  769. }
  770. package com.athena.appium.pages.templates.beans;
  771.  
  772. import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  773.  
  774. @JsonIgnoreProperties(ignoreUnknown = true)
  775. public class TemplateAccount {
  776. private String iban;
  777. private String owner;
  778.  
  779.  
  780. public String getIban() {
  781. return iban;
  782. }
  783.  
  784. public void setIban(String iban) {
  785. this.iban = iban;
  786. }
  787.  
  788. public String getOwner() {
  789. return owner;
  790. }
  791.  
  792. public void setOwner(String owner) {
  793. this.owner = owner;
  794. }
  795. }
  796. package com.athena.appium.pages.templates.beans;
  797.  
  798. public class TemplateValues {
  799. private String name;
  800. private String toAccount;
  801. private String fromAccount;
  802. private String details;
  803. private String beneficiary;
  804.  
  805. public String getName() {
  806. return name;
  807. }
  808.  
  809. public void setName(String name) {
  810. this.name = name;
  811. }
  812.  
  813. public String getToAccount() {
  814. return toAccount;
  815. }
  816.  
  817. public void setToAccount(String toAccount) {
  818. this.toAccount = toAccount;
  819. }
  820.  
  821. public String getFromAccount() {
  822. return fromAccount;
  823. }
  824.  
  825. public void setFromAccount(String fromAccount) {
  826. this.fromAccount = fromAccount;
  827. }
  828.  
  829. public String getDetails() {
  830. return details;
  831. }
  832.  
  833. public void setDetails(String details) {
  834. this.details = details;
  835. }
  836.  
  837. public String getBeneficiary() {
  838. return beneficiary;
  839. }
  840.  
  841. public void setBeneficiary(String beneficiary) {
  842. this.beneficiary = beneficiary;
  843. }
  844. }
  845. package com.athena.appium.tests.pf_tests;
  846.  
  847. import com.athena.appium.utils.enums.Language;
  848. import com.athena.appium.utils.testdata.TestData;
  849. import com.athena.appium.listeners.ExtentTestListener;
  850. import com.athena.appium.pages.product_and_product_attributes.Accounts.AccountFetchOption;
  851. import com.athena.appium.pages.product_and_product_attributes.Accounts.AccountType;
  852. import com.athena.appium.pages.product_and_product_attributes.Details.DetailsPage;
  853. import com.athena.appium.pages.product_and_product_attributes.Garnishments.GarnishmentAccountOverviewPage;
  854. import com.google.gson.JsonArray;
  855. import io.appium.java_client.AppiumDriver;
  856. import io.appium.java_client.MobileElement;
  857. import org.testng.Assert;
  858. import org.testng.annotations.Test;
  859.  
  860. public class GarnishmentDetailesTest extends ExtentTestListener {
  861. private static final String GARNISH_POPRIRI_RO="Popriri";
  862.  
  863. @Test(description = " RO Verify garnishment account ")
  864. public void testGarnishmentROPF() throws Exception {
  865.  
  866. AppiumDriver driver = getDriver();
  867. DetailsPage garAccOver =new DetailsPage(driver);
  868. garAccOver.selectLanguageProfile(Language.RO);
  869. garAccOver.login(TestData.PF,TestData.PI_AUTO_USER,TestData.GENERAL_PASSWORD_02);
  870. garAccOver.tapAccount(TestData.PF, garAccOver.getAccountTypeName(AccountType.CURRENT_ACCOUNT_WITH_GARNISHMENT));
  871. garAccOver.tapOnDetailsButton();
  872. MobileElement elem =garAccOver.getLabelElementByName(GARNISH_POPRIRI_RO);
  873. Assert.assertNotNull(elem);
  874. String nbrOfGarnishment=garAccOver.getValueByName(GARNISH_POPRIRI_RO);
  875. String wsNbr=garAccOver.getWSGarnishmentNbr()+"";
  876. Assert.assertEquals(nbrOfGarnishment,wsNbr);
  877. testInfo("nbr of garnishment from ui: " + nbrOfGarnishment + " nbr of garnishment from WS : " + wsNbr);
  878.  
  879.  
  880.  
  881.  
  882.  
  883. }
  884. }
  885. }
  886. return endPointResult;
  887. }
  888. public static String getStringFromEndpoint(String endPoint, Map<String, String> cookies) {
  889.  
  890. Response endPointResult = given()
  891. .urlEncodingEnabled(false)
  892. .header("Content-Type", TestData.APP_JSON)
  893. .cookies(cookies)
  894. .when()
  895. .get(endPoint)
  896. .then()
  897. .extract().response();
  898.  
  899. return endPointResult.asString();
  900.  
  901. }
  902. }
  903. DIRECT_DEBIT_LIST("/directdebit/v1/mandate/list"),
  904. QUICK_PAYMENTS("/payments-ws/v1/quick-payments/payments?includeBalance=true"),
  905. DEPOSIT_ELIGIBLE_ACCOUNTS("/accounts-ws/v2/accounts/eligible/tm"),
  906. WS_TIME("/utils-service/v1/now");
  907. WS_TIME("/utils-service/v1/now"),
  908. TEMPLATES("/payment-templates/v1/template/list"),
  909. ACCOUNTS_BY_ID("/accounts-ws/v1/accounts"),
  910. ACCOUNT_LIST_OPT("/accounts-ws/v1/accounts/list?fetchOptions=NICKNAME");
  911.  
  912.  
  913. public static final String baseURI = "https://ro-" + TestData.ENV + ".rbro.rbg.cc/services";
  914. public static final String TEST_AUTO_USER_05 = "testautouser05";
  915. public static final String TEST_AUTO_USER_06 = "testautouser07";
  916.  
  917. public static final String Test_AUTO="vn-84-vly";
  918. public static final String GENERAL_PASSWORD_02="test1234";
  919.  
  920.  
  921. // -------------- PRELIVE USERS ----------------------
  922.  
  923. public static final String TEST_AUTO_PRE_06 = "testpf16";
  924. public static final String TEST_AUTO_PRE_01 = "testpf16";
  925. public static final String TEST_AUTO_PF_PRE = "testpf16";
  926. public static final String PI_AUTO_USER = "testpf16";
  927. public static final String TEST_PF_34 = "testpf34";
  928.  
  929. public static final String PI_AUTO_USER16 = "testpf16";
  930. public static final String PI_AUTO_USER17 = "testpf17";
  931. public static final String PI_AUTO_USER10 = "testpf10";
  932.  
  933.  
  934. // --------------- GENERAL USER PRE/TEST --------------
  935. public static final String USER_PROFILE_GROUP = "UserProfile";
  936. public static final String ACCOUNT_STATEMENT_GROUP = "AccountStatement";
  937. public static final String NEED_HELP_GROUP = "NeedHelp";
  938. public static final String TEMPLATES_GROUP ="Templates";
  939. // ---------- Type Group
  940. public static final String LABELS_GROUP = "UI";
  941. public static final String FNCT_GROUP = "Functionality";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement