Search in sources :

Example 1 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxClientSessionActivityImpl method createGxCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diametergx.GxClientSessionActivity#createGxCreditControlRequest(net.java.slee.resource.diameter.cca.events.avp.CcRequestType)
   */
public GxCreditControlRequest createGxCreditControlRequest(final CcRequestType type) {
    // Create the request
    final GxCreditControlRequest request = super.getGxMessageFactory().createGxCreditControlRequest(super.getSessionId());
    request.setCcRequestType(type);
    // If there's a Destination-Host, add the AVP
    if (destinationHost != null) {
        request.setDestinationHost(destinationHost);
    }
    if (destinationRealm != null) {
        request.setDestinationRealm(destinationRealm);
    }
    return request;
}
Also used : GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)

Example 2 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxClientSessionActivityImpl method sendUpdateGxCreditControlRequest.

/*
   * (non-Javadoc)
   * @see net.java.slee.resource.diametergx.GxClientSessionActivity#sendUpdateRoCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)
   */
public void sendUpdateGxCreditControlRequest(final GxCreditControlRequest ccr) throws IOException {
    // FIXME: Should this come already in the CCR?
    validateState(ccr);
    final DiameterMessageImpl msg = (DiameterMessageImpl) ccr;
    try {
        session.sendCreditControlRequest(new GxCreditControlRequestImpl((Request) msg.getGenericData()));
    } catch (org.jdiameter.api.validation.AvpNotAllowedException e) {
        throw new AvpNotAllowedException("Message validation failed.", e, e.getAvpCode(), e.getVendorId());
    } catch (Exception e) {
        throw new IOException("Failed to send message, due to: " + e);
    }
}
Also used : Request(org.jdiameter.api.Request) GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) GxReAuthRequest(net.java.slee.resource.diameter.gx.events.GxReAuthRequest) GxCreditControlRequestImpl(org.jdiameter.common.impl.app.gx.GxCreditControlRequestImpl) IOException(java.io.IOException) DiameterMessageImpl(org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException) IOException(java.io.IOException) DiameterException(net.java.slee.resource.diameter.base.DiameterException) AvpNotAllowedException(net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)

Example 3 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxMessageFactoryImpl method createGxCreditControlRequest.

/**
 * {@inheritDoc}
 */
@Override
public GxCreditControlRequest createGxCreditControlRequest(String sessionId) {
    final GxCreditControlRequest gx = this.createGxCreditControlRequest();
    gx.setSessionId(sessionId);
    return gx;
}
Also used : GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)

Example 4 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxFactoriesTest method testMessageFactoryApplicationIdChangeRAR.

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

Example 5 with GxCreditControlRequest

use of net.java.slee.resource.diameter.gx.events.GxCreditControlRequest in project jain-slee.diameter by RestComm.

the class GxFactoriesTest method testGettersAndSettersCCR.

@Test
public void testGettersAndSettersCCR() throws Exception {
    GxCreditControlRequest ccr = gxMessageFactory.createGxCreditControlRequest();
    int nFailures = GxAvpAssistant.INSTANCE.testMethods(ccr, GxCreditControlRequest.class);
    assertEquals("Some methods have failed. See logs for more details.", 0, nFailures);
}
Also used : GxCreditControlRequest(net.java.slee.resource.diameter.gx.events.GxCreditControlRequest) Test(org.junit.Test) BaseFactoriesTest(org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)

Aggregations

GxCreditControlRequest (net.java.slee.resource.diameter.gx.events.GxCreditControlRequest)16 Test (org.junit.Test)10 BaseFactoriesTest (org.mobicents.slee.resource.diameter.base.tests.factories.BaseFactoriesTest)9 GxReAuthRequest (net.java.slee.resource.diameter.gx.events.GxReAuthRequest)5 DiameterMessageImpl (org.mobicents.slee.resource.diameter.base.events.DiameterMessageImpl)5 IOException (java.io.IOException)4 DiameterException (net.java.slee.resource.diameter.base.DiameterException)4 AvpNotAllowedException (net.java.slee.resource.diameter.base.events.avp.AvpNotAllowedException)4 Request (org.jdiameter.api.Request)4 GxCreditControlRequestImpl (org.jdiameter.common.impl.app.gx.GxCreditControlRequestImpl)4 GxCreditControlAnswer (net.java.slee.resource.diameter.gx.events.GxCreditControlAnswer)3 ApplicationId (org.jdiameter.api.ApplicationId)3 GxMessageFactoryImpl (org.mobicents.slee.resource.diameter.gx.GxMessageFactoryImpl)3 GxServerSessionActivityImpl (org.mobicents.slee.resource.diameter.gx.GxServerSessionActivityImpl)2 ArrayList (java.util.ArrayList)1 DiameterAvp (net.java.slee.resource.diameter.base.events.avp.DiameterAvp)1 Message (org.jdiameter.api.Message)1