Created
June 23, 2015 18:11
-
-
Save tdharris/7c0ac34ca15f1d42b1d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sf.test.telephony.us.transfers.warm; | |
import static org.junit.Assert.assertTrue; | |
import java.util.Collection; | |
import org.echarts.test.sip.CATException; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import org.junit.After; | |
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.junit.runners.Parameterized; | |
import org.junit.runners.Parameterized.Parameters; | |
import sf.actions.ClickToCall; | |
import sf.actions.DominoList; | |
import sf.actions.Lead; | |
import sf.actions.PowerDialer; | |
import sf.actions.ClickToCall.C2CTransfer.C2CTransferDialing; | |
import sf.actions.PowerDialer.PowerDialerTransfer.PowerDialerTransferDialing; | |
import sf.test.TestBase; | |
import util.SFUtils; | |
import util.SeleniumManager; | |
import util.SipPhone; | |
import util.SystemProperties; | |
import util.Text; | |
import util.Utils; | |
@RunWith(Parameterized.class) | |
public class WarmTransferToEmployeeAgentsNextCallNotAffectSpecialistPD extends TestBase | |
{ | |
private ClickToCall c2c1; | |
private ClickToCall c2c2; | |
private static SipPhone agent1; | |
private static SipPhone agent2; | |
private static SipPhone client1; | |
private static SipPhone client2; | |
private PowerDialer pd; | |
private static Lead lead1, lead2; | |
private DominoList dominoList; | |
private String dominoListName; | |
private String firstName, lastName, company; | |
private SeleniumManager sm2 = null; | |
public WarmTransferToEmployeeAgentsNextCallNotAffectSpecialistPD(String _data) | |
{ | |
try | |
{ | |
JSONObject json = new JSONObject(_data); | |
testCase = json.getJSONArray("testCase"); | |
dominoListName = json.getString("dominoName"); | |
firstName = json.getString("firstName"); | |
lastName = json.getString("lastName"); | |
company = Text.getRandomText(json.getString("company"), 3); | |
} catch (JSONException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
@Parameters | |
public static Collection<String[]> data() | |
{ | |
return TestBase.data("ui_" + WarmTransferToEmployeeAgentsNextCallNotAffectSpecialistPD.class.getSimpleName() + ".json", "ui_" + WarmTransferToEmployeeAgentsNextCallNotAffectSpecialistPD.class.getSimpleName(), "/"); | |
} | |
@Before | |
public void setup() | |
{ | |
// Initialize the base class. | |
super.setup(); | |
// Get Phones | |
agent1 = new SipPhone(); | |
agent2 = new SipPhone(); | |
client1 = new SipPhone(); | |
client2 = new SipPhone(); | |
// Create Sales Force leads. | |
lead1 = new Lead(sm) | |
.create() | |
.setFirstName(Text.getRandomText(firstName, 3)) | |
.setLastName(Text.getRandomText(lastName, 3)) | |
.setCompany(company) | |
.setPhone(client1.getPhoneNumber()) | |
.save(); | |
lead2 = new Lead(sm) | |
.create() | |
.setFirstName(Text.getRandomText(firstName, 3)) | |
.setLastName(Text.getRandomText(lastName, 3)) | |
.setCompany(company) | |
.setPhone(client2.getPhoneNumber()) | |
.save(); | |
// Create the domino list that should include the created Lead. | |
dominoList = new DominoList(sm) | |
.open() | |
.newDominoList() | |
.setQueryName(Text.getRandomText(dominoListName, 3)) | |
.setVisibilityToAllUsers() | |
.addFilter("Company", DominoList.CONTAINS_OPERATOR, company) | |
.save(); | |
} | |
@After | |
public void tearDown() | |
{ | |
System.out.println("Releasing SIP phones..."); | |
agent1.release(); | |
agent2.release(); | |
client1.release(); | |
client2.release(); | |
agent1.quit(); | |
if (lead1 != null) | |
lead1.delete(); | |
if (lead2 != null) | |
lead2.delete(); | |
if (sm2 != null) | |
sm2.stop(); | |
} | |
@Test | |
public void testWarmTransferToEmployeeAgentsNextCallNotAffectSpecialistC2C() | |
{ | |
// Launch the Domino list. | |
pd = dominoList | |
.launch() | |
.openSettings() | |
.setStationPhoneNumber(agent1.getPhoneNumber()) | |
.save() | |
.connectToDialer(); | |
agent1.waitForIncomingCall(); | |
pd.dial(); | |
// set up agent 2 | |
sm2 = new SeleniumManager(); | |
sm2.start(); | |
SFUtils.login(sm2, SystemProperties.getSf2_username(), SystemProperties.getSf2_password()); | |
String emp = SFUtils.getCurrentEmployee(sm2).toString(); | |
c2c2 = new ClickToCall(sm2); | |
c2c2 | |
.openSettings() | |
.setStationPhoneNumber(agent2.getPhoneNumber()) | |
.disconnectAgentLeg() | |
.save(); | |
// Transfer the call to agent 2 | |
PowerDialerTransferDialing pdTransfer = pd | |
.transfer() | |
.warmTransfer() | |
.transferToEmployee() | |
.setEmployee(emp) | |
.transfer(); | |
// Agent 2: Accept transfer call request | |
agent2.waitForIncomingCall(); | |
try | |
{ | |
// Wait for the message to play | |
Utils.wait(5); | |
agent2.getSipAgent().sendDTMF("1#"); | |
} catch (CATException e) | |
{ | |
e.printStackTrace(); | |
} | |
pd = pdTransfer | |
.mergeCalls() | |
.dropOffCall(); | |
// dial another number | |
pd | |
.nextCall() | |
.dial(); | |
agent1.waitForIncomingCall(); | |
client2.waitForIncomingCall(); | |
// get the connection state of the agent and client | |
String state = client1.getSipAgent().getCurrentState().toString(); | |
assertTrue("Call not established for the client phone.", state.equalsIgnoreCase("CallEstablished")); | |
state = agent2.getSipAgent().getCurrentState().toString(); | |
assertTrue("Call not established for the agent phone.", state.equalsIgnoreCase("CallEstablished")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment