Skip to content

Instantly share code, notes, and snippets.

@tdharris
Created June 9, 2015 21:01
Show Gist options
  • Save tdharris/db9f9c3bc176d28092be to your computer and use it in GitHub Desktop.
Save tdharris/db9f9c3bc176d28092be to your computer and use it in GitHub Desktop.
package sf.test.telephony.us.transfers.warm;
import java.util.Collection;
import lmp.actions.CallPath;
import obj.CallPathData;
import obj.comms.nodes.NodeForward;
import obj.comms.nodes.NodeStart;
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.test.TestBase;
import sf.actions.ClickToCall;
import util.SipPhone;
@RunWith(Parameterized.class)
public class WarmTransferToCallPathC2C extends TestBase
{
private ClickToCall c2c;
private static SipPhone agent;
private static SipPhone forward;
private static SipPhone client;
private CallPath action;
private CallPathData data;
public WarmTransferToCallPathC2C(String _data)
{
try
{
System.out.println("Fetching JSON Object...");
JSONObject json = new JSONObject(_data);
testCase = json.getJSONArray("testCase");
// System.out.println("Creating new sipPhones...");
// agent = new SipPhone();
// forward = new SipPhone();
// client = new SipPhone();
System.out.println("Creating CallPath...");
action = new CallPath(sm);
System.out.println("Getting action data...");
data = action.getData();
} catch (JSONException e)
{
e.printStackTrace();
}
}
@Parameters
public static Collection<String[]> data()
{
return TestBase.data("ui_" + WarmTransferToCallPathC2C.class.getSimpleName() + ".json", "ui_" + WarmTransferToCallPathC2C.class.getSimpleName(), "/");
}
@Before
public void setup()
{
// Create a Call Path to Transfer to
// Navigate to Manage Call Paths | Create New Call Path
//String url = sm.getBaseURL() + "/apex/InsideSales_Setup?target_page=dialer/manager/CallPathManager";
//sm.navigate(url, By.id("start_0"));
//layout = driver.findElement(By.id("new_call_path_button"));
// Create nodes
System.out.println("Creating nodes...");
NodeStart startNode = new NodeStart();
NodeForward forwardNode = new NodeForward();
// setup the call forward node
System.out.println("Configuring nodes...");
forwardNode.setCallerIdDisplay("Caller's Number");
forwardNode.setForwardNumber(forward.getPhoneNumber());
// Connect the nodes properly
System.out.println("Connecting nodes...");
startNode.addChildNode(forwardNode);
// Add the proper nodes to the data
System.out.println("Adding nodes...");
data.addNode(startNode);
data.addNode(forwardNode);
// Set the data for the call path action class
System.out.println("Setting action data...");
action.setData(data);
// Add the call path
System.out.println("Adding the call path...");
action.add();
// action.validate();
}
@After
public void tearDown()
{
// agent.release();
// forward.release();
// client.release();
// agent.quit();
// clean up Call Path
action.clear();
action.delete();
}
@Test
public void testWarmTransferToCallPathUS()
{
// System.out.println("C2C Stuff...");
// c2c = new ClickToCall(sm);
// c2c
// .openSettings()
// .setStationPhoneNumber(agent.getPhoneNumber())
// .save()
// .setPhoneNumberToDial(client.getPhoneNumber())
// .disconnectAgentLeg()
// .connectToDialer()
// .dial()
// // Close the Record Lookup panel
// .cancel();
//
// // connect the agent and client legs for agent 2
// agent.waitForIncomingCall();
// client.waitForIncomingCall();
//
// // Transfer to Call Path
// C2CTransferDialing c2cTD = c2c
// .transfer()
// .warmTransfer()
// .transferToCallPath()
// .setCallPath(action.getDataObject().getName())
// .transfer();
//
// forward.waitForIncomingCall();
//
// c2cTD
// .mergeCalls()
// .dropOffCall();
//
// String state = client.getSipAgent().getCurrentState().toString();
// assertTrue("Call not established for the client phone.", state.equalsIgnoreCase("CallEstablished"));
//
// state = forward.getSipAgent().getCurrentState().toString();
// assertTrue("Call not established for the client phone.", state.equalsIgnoreCase("CallEstablished"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment