Created
July 10, 2015 16:57
-
-
Save tdharris/88d3d31a33924b7acd03 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 lmp.test.comms.inbound; | |
import static org.junit.Assert.assertTrue; | |
import java.util.ArrayList; | |
import java.util.Collection; | |
import obj.AccountData; | |
import obj.CallPathData; | |
import obj.DialerInitiativeData; | |
import obj.comms.nodes.NodeRepQueue; | |
import obj.comms.nodes.NodeStart; | |
import org.echarts.test.sip.CATState; | |
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 util.SipPhone; | |
import util.Text; | |
import lmp.actions.Account; | |
import lmp.actions.CallPath; | |
import lmp.actions.DialerInitiative; | |
import lmp.actions.Lead; | |
import lmp.actions.PowerDialer; | |
import lmp.actions.DialerInitiative.DataQueries.TimeBlockQuery; | |
import lmp.actions.PowerDialer.InboundCall; | |
import lmp.test.TestBase; | |
@RunWith(Parameterized.class) | |
public class InboundScreenPops extends TestBase | |
{ | |
private SipPhone agent, client; | |
private Account acc; | |
private AccountData accData; | |
private CallPath callPath; | |
private CallPathData callPathData; | |
private PowerDialer pd; | |
private Lead lead; | |
private DialerInitiative di; | |
private String dialerInitiativeName; | |
public InboundScreenPops(String _data) | |
{ | |
try | |
{ | |
JSONObject json = new JSONObject(_data); | |
testCase = json.getJSONArray("testCase"); | |
dialerInitiativeName = json.getString("dialerInitiativeName"); | |
} catch (JSONException e) | |
{ | |
e.printStackTrace(); | |
} | |
} | |
@Parameters | |
public static Collection<String[]> data() | |
{ | |
return TestBase.data("ui_" + InboundScreenPops.class.getSimpleName() + ".json", "ui_" + InboundScreenPops.class.getSimpleName(), "/"); | |
} | |
@Before | |
public void setup() | |
{ | |
// Initialize the base class. | |
super.setup(); | |
// Create SIP Phones | |
System.out.println("Creating SIP Phones..."); | |
agent = new SipPhone(); | |
client = new SipPhone(); | |
// Create the Account | |
System.out.println("Creating Account..."); | |
AccountData accData = new AccountData(); | |
accData.setPhone(client.getPhoneNumber()); | |
Account acc = new Account(sm, accData); | |
// Create a Call Path | |
System.out.println("Creating Call Path..."); | |
callPath = new CallPath(sm); | |
callPathData = callPath.getData(); | |
// Create a call path | |
NodeStart startNode = new NodeStart(); | |
NodeRepQueue repQueueNode = new NodeRepQueue(); | |
// Configure rep queue properties | |
repQueueNode.setName("Ad Rep Queue"); | |
repQueueNode.setFailoverTime(15); | |
repQueueNode.setPopScreenType("Account"); | |
repQueueNode.setAnswerTime(15); | |
repQueueNode.setRouteType("Round Robin"); | |
ArrayList<String> attendees = new ArrayList<>(); | |
attendees.add(user.getName()); | |
repQueueNode.addAllAttendees(); | |
repQueueNode.setAttendees(attendees); | |
repQueueNode.setDefaultRecordOwner(user.getName()); | |
startNode.addChildNode(repQueueNode); | |
callPathData.addNode(startNode); | |
callPathData.addNode(repQueueNode); | |
// Call Path: Set Data & Create | |
callPath.setData(callPathData); | |
callPath.add(); | |
// Create lead for the dialer initiative to launch PD | |
lead = new Lead(sm); | |
// Create a Dialer Iniative | |
di = new DialerInitiative(sm); | |
di | |
.open() | |
// Set the Dialer Initiative Information. | |
.createLeadDialerInitiative() | |
.setName(dialerInitiativeName) | |
.setDialerPanel(dialerPanel) | |
.setStartDate(startDate) | |
.setEndDate(endDate) | |
.setCallbackGotoAfterTimeout("Initiative Attendees") | |
.setApplyAttemptLimits(false) | |
.updateAttendees(attendees) | |
.setDaysActive(null) | |
.setHoursBetweenCalls(0) | |
.setMinutesBetweenCalls(0) | |
.setAgentHoursBetweenCalls(0) | |
.setAgentMinutesBetweenCalls(0) | |
.next() | |
// Set the Phone Fields. | |
.removePhoneFromThePrioritizeList("Home Phone") | |
.addPhoneToThePrioritizeList("Home Phone") | |
.next() | |
// Set the Data Queries. | |
.next() | |
// Set the Tic Sheet Queries. | |
.next() | |
// Set the Employee Statuses | |
.next() | |
// Set the Layout. | |
.finish(); | |
} | |
@After | |
public void tearDown() | |
{ | |
// Clean up SIPPhones | |
agent.release(); | |
client.release(); | |
agent.quit(); | |
// Clean up CallPath | |
if (callPath != null) | |
callPath.delete(); | |
// Clean up lead | |
if (lead != null) | |
lead.delete(); | |
// Clean up Account | |
if (acc != null) | |
acc.delete(); | |
// Cleanup Dialer Initiative? | |
di | |
.open() | |
.delete() | |
.purge(); | |
} | |
@Test | |
public void testInboundScreenPops() | |
{ | |
// Launch PD, make available for inbound | |
pd | |
.outboundAgentLogin() | |
.openSettings() | |
.setStationPhoneNumber(agent.getPhoneNumber()) | |
.setOutboundList(di.getName()) | |
.save() | |
.setAgentStatus("Ready for Inbound") | |
.connectToDialer(); | |
agent.waitForIncomingCall(); | |
// Client calls inbound | |
client.makePhoneCall(callPath.getData().getInboundNumber()); | |
client.waitForStatus(CATState.CallEstablished); | |
// Agent answers, verify record pop | |
InboundCall pdInbound = pd.acceptInboundCall(); | |
String accName = acc.getData().getName(); | |
String inboundName = pd.getCurrentRecord(); | |
assertTrue("The wrong Account record popped: " + inboundName + ". Expecting " + accName, accName.equals(inboundName)); | |
pd.getCurrentRecord(); | |
pdInbound.closeInbound(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment