Search in sources :

Example 1 with NotifyRequest

use of net.java.slee.resource.diameter.s6a.events.NotifyRequest in project jain-slee.diameter by RestComm.

the class S6aServerSessionImpl method createNotifyAnswer.

public NotifyAnswer createNotifyAnswer() {
    // Make sure we have the correct type of Request
    if (!(lastRequest instanceof NotifyRequest)) {
        logger.warn("Invalid type of answer for this activity.");
        return null;
    }
    try {
        // Create the answer
        NotifyAnswer aia = (NotifyAnswer) this.s6aMessageFactory.createS6aMessage(lastRequest.getHeader(), new DiameterAvp[] {}, NotifyAnswer.COMMAND_CODE, s6aMessageFactory.getApplicationId());
        // Fill session related AVPs, if present
        fillSessionAVPs(aia);
        return aia;
    } catch (InternalException e) {
        logger.error("Failed to create Notify-Answer.", e);
    }
    return null;
}
Also used : DiameterAvp(net.java.slee.resource.diameter.base.events.avp.DiameterAvp) NotifyRequest(net.java.slee.resource.diameter.s6a.events.NotifyRequest) NotifyAnswer(net.java.slee.resource.diameter.s6a.events.NotifyAnswer) InternalException(org.jdiameter.api.InternalException)

Example 2 with NotifyRequest

use of net.java.slee.resource.diameter.s6a.events.NotifyRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testMessageFactoryApplicationIdChangeNOR.

@Test
public void testMessageFactoryApplicationIdChangeNOR() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((S6aMessageFactoryImpl) s6aMessageFactory).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 S6a is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    NotifyRequest originalNOR = s6aMessageFactory.createNotifyRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalNOR);
    // now we switch..
    originalNOR = null;
    isVendor = !isVendor;
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    NotifyRequest changedNOR = s6aMessageFactory.createNotifyRequest();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedNOR);
    // revert back to default
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : S6aMessageFactoryImpl(org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl) NotifyRequest(net.java.slee.resource.diameter.s6a.events.NotifyRequest) ApplicationId(org.jdiameter.api.ApplicationId) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 3 with NotifyRequest

use of net.java.slee.resource.diameter.s6a.events.NotifyRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testGettersAndSettersNOR.

@Test
public void testGettersAndSettersNOR() throws Exception {
    NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
    int nFailures = S6aAvpAssistant.INSTANCE.testMethods(nor, NotifyRequest.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : NotifyRequest(net.java.slee.resource.diameter.s6a.events.NotifyRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 4 with NotifyRequest

use of net.java.slee.resource.diameter.s6a.events.NotifyRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method testServerSessionApplicationIdChangeNOA.

@Test
public void testServerSessionApplicationIdChangeNOA() throws Exception {
    long vendor = 10415L;
    ApplicationId originalAppId = ((S6aMessageFactoryImpl) s6aMessageFactory).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 S6a is " + originalAppId.getVendorId());
    // let's create a message and see how it comes...
    NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
    serverSession.fetchSessionData(nor);
    NotifyAnswer originalNOA = serverSession.createNotifyAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, originalNOA);
    // now we switch..
    originalNOA = null;
    isVendor = !isVendor;
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(isVendor ? vendor : 0L, isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
    // create a new message and see how it comes...
    NotifyAnswer changedNOA = serverSession.createNotifyAnswer();
    BaseFactoriesTest.checkCorrectApplicationIdAVPs(isVendor, isAuth, isAcct, changedNOA);
    // revert back to default
    ((S6aMessageFactoryImpl) s6aMessageFactory).setApplicationId(originalAppId.getVendorId(), isAuth ? originalAppId.getAuthAppId() : originalAppId.getAcctAppId());
}
Also used : S6aMessageFactoryImpl(org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl) NotifyRequest(net.java.slee.resource.diameter.s6a.events.NotifyRequest) ApplicationId(org.jdiameter.api.ApplicationId) NotifyAnswer(net.java.slee.resource.diameter.s6a.events.NotifyAnswer) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Example 5 with NotifyRequest

use of net.java.slee.resource.diameter.s6a.events.NotifyRequest in project jain-slee.diameter by RestComm.

the class S6aFactoriesTest method isRequestNOR.

@Test
public void isRequestNOR() throws Exception {
    NotifyRequest nor = s6aMessageFactory.createNotifyRequest();
    assertTrue("Request Flag in Notify-Request is not set.", nor.getHeader().isRequest());
}
Also used : NotifyRequest(net.java.slee.resource.diameter.s6a.events.NotifyRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

NotifyRequest (net.java.slee.resource.diameter.s6a.events.NotifyRequest)13 Test (org.junit.Test)11 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)11 NotifyAnswer (net.java.slee.resource.diameter.s6a.events.NotifyAnswer)8 ApplicationId (org.jdiameter.api.ApplicationId)2 S6aMessageFactoryImpl (org.mobicents.slee.resource.diameter.s6a.S6aMessageFactoryImpl)2 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 InternalException (org.jdiameter.api.InternalException)1