use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShServerFactoriesTest method testGettersAndSettersPNR.
@Test
public void testGettersAndSettersPNR() throws Exception {
PushNotificationRequest pnr = shServerFactory.createPushNotificationRequest();
int nFailures = ShServerAvpAssistant.INSTANCE.testMethods(pnr, PushNotificationRequest.class);
assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientSubscriptionActivityImpl method createPushNotificationAnswer.
/*
* (non-Javadoc)
* @see net.java.slee.resource.diameter.sh.ShClientSubscriptionActivity#createPushNotificationAnswer()
*/
public PushNotificationAnswer createPushNotificationAnswer() {
PushNotificationAnswer pna = null;
for (int index = 0; index < stateMessages.size(); index++) {
if (stateMessages.get(index).getCommand().getCode() == PushNotificationAnswer.commandCode) {
PushNotificationRequest msg = (PushNotificationRequest) stateMessages.get(index);
pna = this.messageFactory.createPushNotificationAnswer(msg);
if (pna.getAuthSessionState() == null && this.authSessionState != null) {
pna.setAuthSessionState(this.authSessionState);
}
((DiameterShMessageImpl) pna).setData(msg);
break;
}
}
return pna;
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientActivityAnswerCreationTest method testShClientActivityAnswerCreation.
@Test
public void testShClientActivityAnswerCreation() throws Exception {
ClientShSession session = new ShClientSessionImpl(new ShClientSessionDataLocalImpl(), new IShMessageFactoryImpl(), (ISessionFactory) stack.getSessionFactory(), new ClientShSessionListenerImpl());
PushNotificationRequest pnr = new PushNotificationRequestImpl(stack.getSessionFactory().getNewSession().createRequest(PushNotificationRequest.commandCode, SH_APP_ID, "mobicents.org", "hss.mobicents"));
ArrayList<DiameterMessage> list = new ArrayList<DiameterMessage>();
list.add(pnr);
ShClientSubscriptionActivityImpl activity = new ShClientSubscriptionActivityImpl(new ShClientMessageFactoryImpl(session.getSessions().get(0), stack), new DiameterShAvpFactoryImpl(diameterAvpFactory), session, null, null);
DiameterActivityAnswerCreationHelper.testAnswerCreation(activity, "stateMessages", list);
}
use of net.java.slee.resource.diameter.sh.events.PushNotificationRequest in project jain-slee.diameter by RestComm.
the class ShClientFactoriesTest method testMessageFactoryApplicationIdChangePNA.
@Test
public void testMessageFactoryApplicationIdChangePNA() throws Exception {
long vendor = 10415L;
ApplicationId originalAppId = ((ShClientMessageFactoryImpl) shClientFactory).getApplicationId();
boolean isAuth = originalAppId.getAuthAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isAcct = originalAppId.getAcctAppId() != org.jdiameter.api.ApplicationId.UNDEFINED_VALUE;
boolean isVendor = originalAppId.getVendorId() != 0L;
assertTrue("Invalid Application-Id (" + originalAppId + "). Should only, and at least, contain either Auth or Acct value.", (isAuth && !isAcct) || (!isAuth && isAcct));
System.out.println("Default VENDOR-ID for Sh is " + originalAppId.getVendorId());
// let's create a message and see how it comes...
PushNotificationRequest pnr = createPushNotificationRequest();
PushNotificationAnswer originalPNA = shClientFactory.createPushNotificationAnswer(pnr);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalPNA);
// now we switch..
originalPNA = null;
isVendor = !isVendor;
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
// create a new message and see how it comes...
PushNotificationAnswer changedPNA = shClientFactory.createPushNotificationAnswer(pnr);
BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedPNA);
// revert back to default
((ShClientMessageFactoryImpl) shClientFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Aggregations