Advertisement
Ansis

Untitled

Jul 25th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.67 KB | None | 0 0
  1. package com.evolutiongaming.test.elements.casino;
  2.  
  3. import com.evolutiongaming.test.elements.games.lobby.Lobby;
  4. import com.evolutiongaming.test.elements.models.Account;
  5. import com.evolutiongaming.test.elements.user.Player;
  6. import com.evolutiongaming.test.elements.utils.CasinoUtil;
  7.  
  8. import static com.evolutiongaming.test.elements.element.ElementsFactory.provideLobby;
  9. import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly;
  10. import static java.util.concurrent.TimeUnit.SECONDS;
  11. import static org.testng.Assert.fail;
  12.  
  13. import com.evolutiongaming.test.elements.backoffice.tablemanagement.TableListPage;
  14. import com.evolutiongaming.test.elements.games.lobby.Lobby;
  15. import com.evolutiongaming.test.elements.models.Account;
  16. import com.evolutiongaming.test.elements.user.Admin;
  17. import com.evolutiongaming.test.elements.utils.CasinoUtil;
  18. import com.evolutiongaming.test.elements.utils.SystemSettingsUtil;
  19. import com.google.common.util.concurrent.Uninterruptibles;
  20.  
  21. import javax.inject.Inject;
  22. import javax.inject.Provider;
  23. import java.util.concurrent.TimeUnit;
  24. import static com.evolutiongaming.test.elements.element.ElementsFactory.provideLobby;
  25. import static com.evolutiongaming.test.elements.utils.CasinoUtil.acceptAlert;
  26. import static com.evolutiongaming.test.elements.utils.SystemSettingsUtil.getSystemPropertyTableName;
  27. import static com.evolutiongaming.test.elements.utils.SystemSettingsUtil.getSystemPropertyVTableName;
  28.  
  29.  
  30. public class DafabetCasino extends AbstractCasino {
  31.     @Inject
  32.     private Provider<Admin> adminProvider;
  33.     private Admin freshAdmin;
  34.  
  35.     public DafabetCasino() {
  36.         name = "Dafabet 1";
  37.         defaultBaseUrl = "https://dafabet1.uat1.evo-test.com";
  38.         defaultAccount = new Account("", "");
  39.         casinoOptions.setTableWhitelist(true);
  40.     }
  41.  
  42.     private String authUrl = defaultBaseUrl + "/ua/v1/dafabet100000001/test123";
  43.     private String authPart;
  44.  
  45.     @Override
  46.     public Lobby openLobby(Player player) {
  47.         driver = player.getDriver();
  48.  
  49.         // this is strange casino and operates only on virttables - make sure both table+vttable are in launch config
  50.         // here we are making table to disappear from flash lobby
  51.         freshAdmin = adminProvider.get();
  52.         TableListPage tableListPage = freshAdmin.getMainPage()
  53.                 .menu()
  54.                 .openMainPage()
  55.                 .openChangeCurrentCasinoPage()
  56.                 .selectCasinoByName(name)
  57.                 .clickSubmitButton()
  58.                 .openTableListPage();
  59.         String tableListPageUrl = tableListPage.getDriver().getCurrentUrl();
  60.  
  61.         //updating main table
  62.         String systemPropertyTableName = getSystemPropertyTableName();
  63.         String systemPropertyVTableName = getSystemPropertyVTableName();
  64.  
  65.         tableListPage.editTableByName(systemPropertyTableName);
  66.         Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
  67.  
  68.         String physTableConf = freshAdmin.getDriver().findElementById("table_data").getText();
  69.         freshAdmin.getDriver().findElementById("table_data").sendKeys("\ndisplay=0\n");
  70.         Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
  71.         freshAdmin.getDriver().findElementByXPath("//input[@value='Set Table Config']").click();
  72.         Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
  73.  
  74.         //updating virtualTable
  75.         freshAdmin.getDriver().get(tableListPageUrl);
  76.         tableListPage.openVirtualTableListPageByTableName(systemPropertyTableName)
  77.                 .editVirtualTableByName(systemPropertyVTableName);
  78.         String vtId = freshAdmin.getDriver().getCurrentUrl().split("vt_id=")[1].split("&")[0];
  79.       //  SystemSettingsUtil.setProperty("vtable.id", vtId);//forgive me, if you can
  80.         Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
  81.         freshAdmin.getDriver().findElementById("table_data").clear();
  82.         freshAdmin.getDriver().findElementById("table_data").sendKeys(physTableConf + "\ndisplay=as_physical_table" +
  83.                 "\nsiteAssignedTable=3"); //check in Dolphin for corresponding siteAssignedTable parameter for test user
  84.         Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
  85.         freshAdmin.getDriver().findElementByXPath("//input[@value='Save changes']").click();
  86.         acceptAlert(getDriver());
  87.         Uninterruptibles.sleepUninterruptibly(5, TimeUnit.SECONDS);
  88.  
  89.         freshAdmin.quit();
  90.  
  91.  
  92.         try {
  93.             authPart = CasinoUtil.getEvoStdSsid(authUrl,
  94.                     "{ \"uuid\":\"bd0e960b-d898-4297-9927-fcb37c2489a1\"," +
  95.                             "\"player\": {\"id\": \"2392474\",\"update\": false,\"firstName\": \"EVOQA001\",\"lastName\": \"EVOQA001\"," +
  96.                             "\"country\": \"CN\",\"language\": \"en\",\"currency\": \"CNY\"," +
  97.                             "\"session\": {\"id\": \"eb4ba253-cfc1-44ed-aa94-2a34af22cffe@internet\",\"ip\": \"192.168.0.1\"}}," +
  98.                             "\"config\": {\"brand\": {\"id\": \"1\",\"skin\": \"1\"},\"channel\":"+
  99.                             " {\"mobile\": false, \"wrapped\": true}}}").responseMessage;
  100.         } catch (Exception ex) {
  101.             fail("Something went wrong. Lobby should've opened: " + ex.getMessage());
  102.         }
  103.  
  104.         driver.get(defaultBaseUrl + authPart);
  105.         String currentUrl = driver.getCurrentUrl();
  106.         logger.info("Current Url - \n[{}]", currentUrl);
  107.  
  108.         sleepUninterruptibly(5, SECONDS);
  109.  
  110.         driver.get("https://dafabet1.uat1.evo-test.com/entry?game=blackjack");
  111.         playerConfiguration = CasinoUtil.readPlayerConfiguration(driver, casinoOptions);
  112.         return provideLobby(player, playerConfiguration);
  113.  
  114.     }
  115.  
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement