Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. package lmp.test.comms.inbound;
  2.  
  3. import static org.junit.Assert.assertTrue;
  4.  
  5. import java.util.ArrayList;
  6. import java.util.Collection;
  7.  
  8. import obj.AccountData;
  9. import obj.CallPathData;
  10. import obj.DialerInitiativeData;
  11. import obj.comms.nodes.NodeRepQueue;
  12. import obj.comms.nodes.NodeStart;
  13.  
  14. import org.echarts.test.sip.CATState;
  15. import org.json.JSONException;
  16. import org.json.JSONObject;
  17. import org.junit.After;
  18. import org.junit.Before;
  19. import org.junit.Test;
  20. import org.junit.runner.RunWith;
  21. import org.junit.runners.Parameterized;
  22. import org.junit.runners.Parameterized.Parameters;
  23.  
  24. import util.SipPhone;
  25. import util.Text;
  26. import lmp.actions.Account;
  27. import lmp.actions.CallPath;
  28. import lmp.actions.DialerInitiative;
  29. import lmp.actions.Lead;
  30. import lmp.actions.PowerDialer;
  31. import lmp.actions.DialerInitiative.DataQueries.TimeBlockQuery;
  32. import lmp.actions.PowerDialer.InboundCall;
  33. import lmp.test.TestBase;
  34.  
  35. @RunWith(Parameterized.class)
  36. public class InboundScreenPops extends TestBase
  37. {
  38.  
  39. private SipPhone agent, client;
  40. private Account acc;
  41. private AccountData accData;
  42. private CallPath callPath;
  43. private CallPathData callPathData;
  44. private PowerDialer pd;
  45. private Lead lead;
  46. private DialerInitiative di;
  47. private String dialerInitiativeName;
  48.  
  49. public InboundScreenPops(String _data)
  50. {
  51. try
  52. {
  53. JSONObject json = new JSONObject(_data);
  54. testCase = json.getJSONArray("testCase");
  55. dialerInitiativeName = json.getString("dialerInitiativeName");
  56. } catch (JSONException e)
  57. {
  58. e.printStackTrace();
  59. }
  60. }
  61.  
  62. @Parameters
  63. public static Collection<String[]> data()
  64. {
  65. return TestBase.data("ui_" + InboundScreenPops.class.getSimpleName() + ".json", "ui_" + InboundScreenPops.class.getSimpleName(), "/");
  66. }
  67.  
  68. @Before
  69. public void setup()
  70. {
  71. // Initialize the base class.
  72. super.setup();
  73.  
  74. // Create SIP Phones
  75. System.out.println("Creating SIP Phones...");
  76. agent = new SipPhone();
  77. client = new SipPhone();
  78.  
  79. // Create the Account
  80. System.out.println("Creating Account...");
  81. AccountData accData = new AccountData();
  82. accData.setPhone(client.getPhoneNumber());
  83. Account acc = new Account(sm, accData);
  84.  
  85. // Create a Call Path
  86. System.out.println("Creating Call Path...");
  87. callPath = new CallPath(sm);
  88. callPathData = callPath.getData();
  89.  
  90. // Create a call path
  91. NodeStart startNode = new NodeStart();
  92. NodeRepQueue repQueueNode = new NodeRepQueue();
  93.  
  94. // Configure rep queue properties
  95. repQueueNode.setName("Ad Rep Queue");
  96. repQueueNode.setFailoverTime(15);
  97. repQueueNode.setPopScreenType("Account");
  98. repQueueNode.setAnswerTime(15);
  99. repQueueNode.setRouteType("Round Robin");
  100. ArrayList<String> attendees = new ArrayList<>();
  101. attendees.add(user.getName());
  102. repQueueNode.addAllAttendees();
  103. repQueueNode.setAttendees(attendees);
  104. repQueueNode.setDefaultRecordOwner(user.getName());
  105.  
  106. startNode.addChildNode(repQueueNode);
  107. callPathData.addNode(startNode);
  108. callPathData.addNode(repQueueNode);
  109.  
  110. // Call Path: Set Data & Create
  111. callPath.setData(callPathData);
  112. callPath.add();
  113.  
  114. // Create lead for the dialer initiative to launch PD
  115. lead = new Lead(sm);
  116.  
  117. // Create a Dialer Iniative
  118. di = new DialerInitiative(sm);
  119. di
  120. .open()
  121. // Set the Dialer Initiative Information.
  122. .createLeadDialerInitiative()
  123. .setName(dialerInitiativeName)
  124. .setDialerPanel(dialerPanel)
  125. .setStartDate(startDate)
  126. .setEndDate(endDate)
  127. .setCallbackGotoAfterTimeout("Initiative Attendees")
  128. .setApplyAttemptLimits(false)
  129. .updateAttendees(attendees)
  130. .setDaysActive(null)
  131. .setHoursBetweenCalls(0)
  132. .setMinutesBetweenCalls(0)
  133. .setAgentHoursBetweenCalls(0)
  134. .setAgentMinutesBetweenCalls(0)
  135. .next()
  136. // Set the Phone Fields.
  137. .removePhoneFromThePrioritizeList("Home Phone")
  138. .addPhoneToThePrioritizeList("Home Phone")
  139. .next()
  140. // Set the Data Queries.
  141. .next()
  142. // Set the Tic Sheet Queries.
  143. .next()
  144. // Set the Employee Statuses
  145. .next()
  146. // Set the Layout.
  147. .finish();
  148.  
  149. }
  150.  
  151. @After
  152. public void tearDown()
  153. {
  154. // Clean up SIPPhones
  155. agent.release();
  156. client.release();
  157. agent.quit();
  158.  
  159. // Clean up CallPath
  160. if (callPath != null)
  161. callPath.delete();
  162.  
  163. // Clean up lead
  164. if (lead != null)
  165. lead.delete();
  166.  
  167. // Clean up Account
  168. if (acc != null)
  169. acc.delete();
  170.  
  171. // Cleanup Dialer Initiative?
  172. di
  173. .open()
  174. .delete()
  175. .purge();
  176. }
  177.  
  178. @Test
  179. public void testInboundScreenPops()
  180. {
  181. // Launch PD, make available for inbound
  182. pd
  183. .outboundAgentLogin()
  184. .openSettings()
  185. .setStationPhoneNumber(agent.getPhoneNumber())
  186. .setOutboundList(di.getName())
  187. .save()
  188. .setAgentStatus("Ready for Inbound")
  189. .connectToDialer();
  190.  
  191. agent.waitForIncomingCall();
  192.  
  193. // Client calls inbound
  194. client.makePhoneCall(callPath.getData().getInboundNumber());
  195. client.waitForStatus(CATState.CallEstablished);
  196.  
  197. // Agent answers, verify record pop
  198. InboundCall pdInbound = pd.acceptInboundCall();
  199. String accName = acc.getData().getName();
  200. String inboundName = pd.getCurrentRecord();
  201. assertTrue("The wrong Account record popped: " + inboundName + ". Expecting " + accName, accName.equals(inboundName));
  202. pd.getCurrentRecord();
  203.  
  204. pdInbound.closeInbound();
  205. }
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement