output
stringlengths
7
516k
instruction
stringclasses
1 value
input
stringlengths
6
884k
```package org.restcomm.protocols.ss7.cap.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.CalledPartyBCDNumber; import org.restcomm.protocols.ss7.cap.api.primitives.TimeAndTimezone; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.EventTypeSMS; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.SMSAddressString; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPDataCodingScheme; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPProtocolIdentifier; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPShortMessageSpecificInfo; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPValidityPeriod; import org.restcomm.protocols.ss7.cap.primitives.CAPExtensionsTest; import org.restcomm.protocols.ss7.cap.primitives.CalledPartyBCDNumberImpl; import org.restcomm.protocols.ss7.cap.primitives.TimeAndTimezoneImpl; import org.restcomm.protocols.ss7.cap.service.sms.InitialDPSMSRequestImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.SMSAddressStringImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPDataCodingSchemeImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPProtocolIdentifierImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPShortMessageSpecificInfoImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPValidityPeriodImpl; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.IMEI; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.callhandling.CallReferenceNumber; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.GPRSMSClass; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformationGPRS; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.MSClassmark2; import org.restcomm.protocols.ss7.map.primitives.CellGlobalIdOrServiceAreaIdOrLAIImpl; import org.restcomm.protocols.ss7.map.primitives.IMEIImpl; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.LAIFixedLengthImpl; import org.restcomm.protocols.ss7.map.service.callhandling.CallReferenceNumberImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.GPRSMSClassImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.GeodeticInformationImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.GeographicalInformationImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.LocationInformationGPRSImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.LocationInformationImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.MSClassmark2Impl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.MSNetworkCapabilityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.MSRadioAccessCapabilityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.RAIdentityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.LSAIdentityImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class InitialDPSMSRequestTest { public byte[] getData() { return new byte[] { 48, -126, 1, 15, -128, 1, 2, -127, 7, -111, 20, -121, 8, 80, 64, -9, -126, 9, -111, 33, 67, 101, -121, 25, 50, 84, 118, -125, 1, 3, -124, 5, 17, 17, 33, 34, 34, -91, 3, 2, 1, 111, -90, 57, -96, 7, -127, 5, 82, -16, 16, 17, 92, -127, 6, 11, 12, 13, 14, 15, 16, -126, 8, 31, 32, 33, 34, 35, 36, 37, 38, -125, 4, -111, 86, 52, 18, -124, 3, 91, 92, 93, -122, 0, -121, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -120, 0, -119, 1, 13, -121, 6, -111, 34, 112, 87, 0, 112, -120, 8, 2, 80, 17, 66, 49, 1, 101, 0, -119, 1, 5, -118, 1, 5, -117, 1, 5, -116, 6, 1, 2, 3, 4, 5, 6, -83, 18, 48, 5, 2, 1, 2, -127, 0, 48, 9, 2, 1, 3, 10, 1, 1, -127, 1, -1, -114, 6, 1, 2, 3, 4, 5, 6, -113, 6, -111, 34, 112, 87, 0, -128, -112, 6, -111, 34, 112, 87, 0, -112, -111, 3, 1, 2, 3, -90, 57, -96, 7, -127, 5, 82, -16, 16, 17, 92, -127, 6, 11, 12, 13, 14, 15, 16, -126, 8, 31, 32, 33, 34, 35, 36, 37, 38, -125, 4, -111, 86, 52, 18, -124, 3, 91, 92, 93, -122, 0, -121, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -120, 0, -119, 1, 13, -78, 11, -128, 3, 1, 2, 3, -127, 4, 11, 22, 33, 44, -109, 8, 17, 34, 51, 68, 85, 102, 119, -120, -108, 6, -111, 34, 112, 87, 0, 1 }; }; private byte[] getGeographicalInformation() { return new byte[] { 31, 32, 33, 34, 35, 36, 37, 38 }; } private byte[] getEncodedDataRAIdentity() { return new byte[] { 11, 12, 13, 14, 15, 16 }; } private byte[] getEncodedDataLSAIdentity() { return new byte[] { 91, 92, 93 }; } private byte[] getGeodeticInformation() { return new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; } private byte[] getTPValidityPeriod() { return new byte[] { 1, 2, 3, 4, 5, 6 }; } private byte[] getCallReferenceNumber() { return new byte[] { 1, 2, 3, 4, 5, 6 }; } private byte[] getMSClassmark2() { return new byte[] { 1, 2, 3 }; } private byte[] getEncodedDataNetworkCapability() { return new byte[] { 1, 2, 3 }; } private byte[] getEncodedDataRadioAccessCapability() { return new byte[] { 11, 22, 33, 44 }; } @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); InitialDPSMSRequestImpl prim = new InitialDPSMSRequestImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); int serviceKey = prim.getServiceKey(); CalledPartyBCDNumber destinationSubscriberNumber = prim.getDestinationSubscriberNumber(); SMSAddressString callingPartyNumber = prim.getCallingPartyNumber(); EventTypeSMS eventTypeSMS = prim.getEventTypeSMS(); IMSI imsi = prim.getImsi(); LocationInformation locationInformationMSC = prim.getLocationInformationMSC(); // LocationInformationGPRS locationInformationGPRS = // prim.getLocationInformationGPRS(); ISDNAddressString smscCAddress = prim.getSMSCAddress(); // TimeAndTimezone timeAndTimezone = prim.getTimeAndTimezone(); TPShortMessageSpecificInfo tPShortMessageSpecificInfo = prim.getTPShortMessageSpecificInfo(); TPProtocolIdentifier tPProtocolIdentifier = prim.getTPProtocolIdentifier(); TPDataCodingScheme tPDataCodingScheme = prim.getTPDataCodingScheme(); TPValidityPeriod tPValidityPeriod = prim.getTPValidityPeriod(); // CAPExtensions extensions = prim.getExtensions(); CallReferenceNumber smsReferenceNumber = prim.getSmsReferenceNumber(); ISDNAddressString mscAddress = prim.getMscAddress(); ISDNAddressString sgsnNumber = prim.getSgsnNumber(); MSClassmark2 mSClassmark2 = prim.getMSClassmark2(); GPRSMSClass gprsMSClass = prim.getGPRSMSClass(); IMEI imei = prim.getImei(); ISDNAddressString calledPartyNumber = prim.getCalledPartyNumber(); assertEquals(serviceKey, 2); assertNotNull(destinationSubscriberNumber); assertTrue(destinationSubscriberNumber.getAddress().equals("41788005047")); assertNotNull(callingPartyNumber); assertTrue(callingPartyNumber.getAddress().equals("1234567891234567")); assertEquals(eventTypeSMS, EventTypeSMS.oSmsSubmission); // getImsi assertTrue(imsi.getData().equals("1111122222")); assertNotNull(locationInformationMSC); // locationInformationGPRS assertEquals(prim.getLocationInformationGPRS().getCellGlobalIdOrServiceAreaIdOrLAI().getLAIFixedLength() .getMCC(), 250); assertEquals(prim.getLocationInformationGPRS().getCellGlobalIdOrServiceAreaIdOrLAI().getLAIFixedLength() .getMNC(), 1); assertEquals(prim.getLocationInformationGPRS().getCellGlobalIdOrServiceAreaIdOrLAI().getLAIFixedLength() .getLac(), 4444); assertTrue(Arrays.equals(prim.getLocationInformationGPRS().getRouteingAreaIdentity().getData(), this.getEncodedDataRAIdentity())); assertTrue(Arrays.equals(prim.getLocationInformationGPRS().getGeographicalInformation().getData(), this.getGeographicalInformation())); assertTrue(prim.getLocationInformationGPRS().getSGSNNumber().getAddress().equals("654321")); assertTrue(Arrays.equals(prim.getLocationInformationGPRS().getLSAIdentity().getData(), this.getEncodedDataLSAIdentity())); assertTrue(prim.getLocationInformationGPRS().isSaiPresent()); assertTrue(Arrays.equals(prim.getLocationInformationGPRS().getGeodeticInformation().getData(), this.getGeodeticInformation())); assertTrue(prim.getLocationInformationGPRS().isCurrentLocationRetrieved()); assertEquals((int) prim.getLocationInformationGPRS().getAgeOfLocationInformation(), 13); assertNotNull(smscCAddress); assertTrue(smscCAddress.getAddress().equals("2207750007")); // gprsMSClass assertTrue(Arrays .equals(gprsMSClass.getMSNetworkCapability().getData(), this.getEncodedDataNetworkCapability())); assertTrue(Arrays.equals(gprsMSClass.getMSRadioAccessCapability().getData(), this.getEncodedDataRadioAccessCapability())); // getTimeAndTimezone assertEquals(prim.getTimeAndTimezone().getYear(), 2005); assertEquals(prim.getTimeAndTimezone().getMonth(), 11); assertEquals(prim.getTimeAndTimezone().getDay(), 24); assertEquals(prim.getTimeAndTimezone().getHour(), 13); assertEquals(prim.getTimeAndTimezone().getMinute(), 10); assertEquals(prim.getTimeAndTimezone().getSecond(), 56); assertEquals(prim.getTimeAndTimezone().getTimeZone(), 0); assertEquals(tPShortMessageSpecificInfo.getData(), 5); assertEquals(tPProtocolIdentifier.getData(), 5); assertEquals(tPDataCodingScheme.getData(), 5); assertTrue(Arrays.equals(tPValidityPeriod.getData(), this.getTPValidityPeriod())); // extensions CAPExtensionsTest.checkTestCAPExtensions(prim.getExtensions()); assertTrue(Arrays.equals(smsReferenceNumber.getData(), this.getCallReferenceNumber())); assertNotNull(mscAddress); assertTrue(mscAddress.getAddress().equals("2207750008")); assertNotNull(sgsnNumber); assertTrue(sgsnNumber.getAddress().equals("2207750009")); // getImei assertTrue(prim.getImei().getIMEI().equals("1122334455667788")); assertNotNull(calledPartyNumber); assertTrue(calledPartyNumber.getAddress().equals("2207750010")); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { int serviceKey = 2; CalledPartyBCDNumber destinationSubscriberNumber = new CalledPartyBCDNumberImpl( AddressNature.international_number, NumberingPlan.ISDN, "41788005047"); SMSAddressString callingPartyNumber = new SMSAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1234567891234567"); EventTypeSMS eventTypeSMS = EventTypeSMS.oSmsSubmission; IMSI imsi = new IMSIImpl("1111122222"); LocationInformation locationInformationMSC = new LocationInformationImpl(111, null, null, null, null, null, null, null, null, false, false, null, null); // locationInformationGPRS LAIFixedLengthImpl lai = new LAIFixedLengthImpl(250, 1, 4444); CellGlobalIdOrServiceAreaIdOrLAIImpl cgi = new CellGlobalIdOrServiceAreaIdOrLAIImpl(lai); RAIdentityImpl ra = new RAIdentityImpl(this.getEncodedDataRAIdentity()); GeographicalInformationImpl ggi = new GeographicalInformationImpl(this.getGeographicalInformation()); ISDNAddressStringImpl sgsn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "654321"); LSAIdentityImpl lsa = new LSAIdentityImpl(this.getEncodedDataLSAIdentity()); GeodeticInformationImpl gdi = new GeodeticInformationImpl(this.getGeodeticInformation()); LocationInformationGPRS locationInformationGPRS = new LocationInformationGPRSImpl(cgi, ra, ggi, sgsn, lsa, null, true, gdi, true, 13); ISDNAddressString smscCAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2207750007"); TimeAndTimezone timeAndTimezone = new TimeAndTimezoneImpl(2005, 11, 24, 13, 10, 56, 0); TPShortMessageSpecificInfo tPShortMessageSpecificInfo = new TPShortMessageSpecificInfoImpl(5); TPProtocolIdentifier tPProtocolIdentifier = new TPProtocolIdentifierImpl(5); TPDataCodingScheme tPDataCodingScheme = new TPDataCodingSchemeImpl(5); TPValidityPeriod tPValidityPeriod = new TPValidityPeriodImpl(getTPValidityPeriod()); CAPExtensions extensions = CAPExtensionsTest.createTestCAPExtensions(); CallReferenceNumber smsReferenceNumber = new CallReferenceNumberImpl(getCallReferenceNumber()); ISDNAddressString mscAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2207750008"); ISDNAddressString sgsnNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2207750009"); MSClassmark2 mSClassmark2 = new MSClassmark2Impl(getMSClassmark2()); // gprsMSClass MSNetworkCapabilityImpl nc = new MSNetworkCapabilityImpl(this.getEncodedDataNetworkCapability()); MSRadioAccessCapabilityImpl rac = new MSRadioAccessCapabilityImpl(this.getEncodedDataRadioAccessCapability()); GPRSMSClass gprsMSClass = new GPRSMSClassImpl(nc, rac); IMEI imei = new IMEIImpl("1122334455667788"); ISDNAddressString calledPartyNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2207750010"); InitialDPSMSRequestImpl prim = new InitialDPSMSRequestImpl(serviceKey, destinationSubscriberNumber, callingPartyNumber, eventTypeSMS, imsi, locationInformationMSC, locationInformationGPRS, smscCAddress, timeAndTimezone, tPShortMessageSpecificInfo, tPProtocolIdentifier, tPDataCodingScheme, tPValidityPeriod, extensions, smsReferenceNumber, mscAddress, sgsnNumber, mSClassmark2, gprsMSClass, imei, calledPartyNumber); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.CalledPartyBCDNumber; import org.restcomm.protocols.ss7.cap.api.primitives.TimeAndTimezone; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.EventTypeSMS; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.SMSAddressString; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPDataCodingScheme; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPProtocolIdentifier; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPShortMessageSpecificInfo; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.TPValidityPeriod; import org.restcomm.protocols.ss7.map.api.primitives.IMEI; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.service.callhandling.CallReferenceNumber; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.GPRSMSClass; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformationGPRS; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.MSClassmark2; /** * initialDPSMS {PARAMETERS-BOUND : bound} OPERATION ::= { ARGUMENT InitialDPSMSArg {bound} RETURN RESULT FALSE ERRORS {missingCustomerRecord | missingParameter | parameterOutOfRange | systemFailure | taskRefused | unexpectedComponentSequence | unexpectedDataValue | unexpectedParameter} CODE opcode-initialDPSMS} -- Direction: gsmSSF or gprsSSF -> gsmSCF, Timer: Tidpsms -- This operation is used after a TDP to indicate request for service. InitialDPSMSArg {PARAMETERS-BOUND : bound} ::= SEQUENCE { serviceKey [0] ServiceKey, destinationSubscriberNumber [1] CalledPartyBCDNumber {bound} OPTIONAL, callingPartyNumber [2] SMS-AddressString OPTIONAL, eventTypeSMS [3] EventTypeSMS OPTIONAL, iMSI [4] IMSI OPTIONAL, locationInformationMSC [5] LocationInformation OPTIONAL, locationInformationGPRS [6] LocationInformationGPRS OPTIONAL, sMSCAddress [7] ISDN-AddressString OPTIONAL, timeAndTimezone [8] TimeAndTimezone {bound} OPTIONAL, tPShortMessageSpecificInfo [9] TPShortMessageSpecificInfo OPTIONAL, tPProtocolIdentifier [10] TPProtocolIdentifier OPTIONAL, tPDataCodingScheme [11] TPDataCodingScheme OPTIONAL, tPValidityPeriod [12] TPValidityPeriod OPTIONAL, extensions [13] Extensions {bound} OPTIONAL, ..., smsReferenceNumber [14] CallReferenceNumber OPTIONAL, mscAddress [15] ISDN-AddressString OPTIONAL, sgsn-Number [16] ISDN-AddressString OPTIONAL, ms-Classmark2 [17] MS-Classmark2 OPTIONAL, gPRSMSClass [18] GPRSMSClass OPTIONAL, iMEI [19] IMEI OPTIONAL, calledPartyNumber [20] ISDN-AddressString OPTIONAL } * * ServiceKey ::= Integer4 * * * * @author sergey vetyutnev * */ public interface InitialDPSMSRequest extends SmsMessage { int getServiceKey(); CalledPartyBCDNumber getDestinationSubscriberNumber(); SMSAddressString getCallingPartyNumber(); EventTypeSMS getEventTypeSMS(); IMSI getImsi(); LocationInformation getLocationInformationMSC(); LocationInformationGPRS getLocationInformationGPRS(); ISDNAddressString getSMSCAddress(); TimeAndTimezone getTimeAndTimezone(); TPShortMessageSpecificInfo getTPShortMessageSpecificInfo(); TPProtocolIdentifier getTPProtocolIdentifier(); TPDataCodingScheme getTPDataCodingScheme(); TPValidityPeriod getTPValidityPeriod(); CAPExtensions getExtensions(); CallReferenceNumber getSmsReferenceNumber(); ISDNAddressString getMscAddress(); ISDNAddressString getSgsnNumber(); MSClassmark2 getMSClassmark2(); GPRSMSClass getGPRSMSClass(); IMEI getImei(); ISDNAddressString getCalledPartyNumber(); }```
```package org.restcomm.protocols.ss7.map.service.callhandling; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGInterlock; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.callhandling.CUGCheckInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGInterlockImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class CUGCheckInfoTest { private byte[] getEncodedData() { return new byte[] { -95, 49, 4, 4, 1, 2, 3, 4, 5, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; } private byte[] getGugData() { return new byte[] { 1, 2, 3, 4 }; } @Test(groups = { "functional.decode", "service.callhandling" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); CUGCheckInfoImpl ind = new CUGCheckInfoImpl(); assertEquals(tag, 1); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); ind.decodeAll(asn); assertTrue(Arrays.equals(ind.getCUGInterlock().getData(), getGugData())); assertTrue(ind.getCUGOutgoingAccess()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.callhandling" }) public void testEncode() throws Exception { CUGInterlock cugInterlock = new CUGInterlockImpl(getGugData()); CUGCheckInfoImpl ind = new CUGCheckInfoImpl(cugInterlock, true, MAPExtensionContainerTest.GetTestExtensionContainer()); // CUGInterlock cugInterlock, boolean cugOutgoingAccess, MAPExtensionContainer extensionContainer AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 1); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.callhandling; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGInterlock; /** * CUG-CheckInfo ::= SEQUENCE { cug-Interlock CUG-Interlock, cug-OutgoingAccess NULL OPTIONAL, extensionContainer * ExtensionContainer OPTIONAL, ...} * * * @author cristian veliscu * */ public interface CUGCheckInfo extends Serializable { CUGInterlock getCUGInterlock(); boolean getCUGOutgoingAccess(); MAPExtensionContainer getExtensionContainer(); }```
```package org.restcomm.protocols.ss7.map.primitives; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.primitives.TimeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class TimeTest { public byte[] getData() { return new byte[] { 4, 4, -95, 17, 53, -98 }; }; public byte[] getData2() { return new byte[] { 4, 4, 127, -2, -14, 30 }; } @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // option 1 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); TimeImpl prim = new TimeImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getYear(), 1985); assertEquals(prim.getMonth(), 8); assertEquals(prim.getDay(), 19); assertEquals(prim.getHour(), 3); assertEquals(prim.getMinute(), 40); assertEquals(prim.getSecond(), 14); // option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new TimeImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getYear(), 2104); assertEquals(prim.getMonth(), 2); assertEquals(prim.getDay(), 25); assertEquals(prim.getHour(), 14); assertEquals(prim.getMinute(), 30); assertEquals(prim.getSecond(), 54); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { TimeImpl prim = new TimeImpl(1985, 8, 19, 3, 40, 14); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); prim = new TimeImpl(2104, 2, 25, 14, 30, 54); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.primitives; import java.io.Serializable; /** * Time ::= OCTET STRING (SIZE (4)) -- Octets are coded according to IETF RFC 3588 [139] * * The Time format is derived from the OctetString AVP Base Format. The string MUST contain four octets, in the same format as * the first four bytes are in the NTP timestamp format. The NTP Timestamp format is defined in chapter 3 of [SNTP]. * * This represents the number of seconds since 0h on 1 January 1900 with respect to the Coordinated Universal Time (UTC). * * On 6h 28m 16s UTC, 7 February 2036 the time value will overflow. SNTP [SNTP] describes a procedure to extend the time to * 2104. This procedure MUST be supported by all DIAMETER nodes. * * For "NTP Timestamp Format" please refer rfc2030. * * * * @author sergey vetyutnev * */ public interface Time extends Serializable { byte[] getData(); /** * Returns the value in UTC * */ int getYear(); /** * Returns the value in UTC * */ int getMonth(); /** * Returns the value in UTC * */ int getDay(); /** * Returns the value in UTC * */ int getHour(); /** * Returns the value in UTC * */ int getMinute(); /** * Returns the value in UTC * */ int getSecond(); } ```
```package org.restcomm.protocols.ss7.cap.service.sms.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.EsiSms.OSmsFailureSpecificInfoImpl; import org.restcomm.protocols.ss7.cap.EsiSms.OSmsSubmissionSpecificInfoImpl; import org.restcomm.protocols.ss7.cap.EsiSms.TSmsDeliverySpecificInfoImpl; import org.restcomm.protocols.ss7.cap.EsiSms.TSmsFailureSpecificInfoImpl; import org.restcomm.protocols.ss7.cap.api.EsiSms.OSmsFailureSpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.OSmsSubmissionSpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.TSmsDeliverySpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.TSmsFailureSpecificInfo; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.MOSMSCause; import org.restcomm.protocols.ss7.cap.service.sms.primitive.EventSpecificInformationSMSImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.MTSMSCauseImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class EventSpecificInformationSMSTest { public byte[] getData1() { return new byte[] { -96, 3, -128, 1, 2 }; }; public byte[] getData2() { return new byte[] {-95, 0}; }; public byte[] getData3() { return new byte[] { -94, 3, -128, 1, 6}; }; public byte[] getData4() { return new byte[] {-93, 0}; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { //option 1 byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); EventSpecificInformationSMSImpl prim = new EventSpecificInformationSMSImpl(); prim.decodeAll(asn); assertEquals(tag, EventSpecificInformationSMSImpl._ID_oSmsFailureSpecificInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNotNull(prim.getOSmsFailureSpecificInfo()); OSmsFailureSpecificInfo oSmsFailureSpecificInfo = prim.getOSmsFailureSpecificInfo(); assertEquals(oSmsFailureSpecificInfo.getFailureCause(), MOSMSCause.facilityNotSupported); assertNull(prim.getOSmsSubmissionSpecificInfo()); assertNull(prim.getTSmsFailureSpecificInfo()); assertNull(prim.getTSmsDeliverySpecificInfo()); //option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new EventSpecificInformationSMSImpl(); prim.decodeAll(asn); assertEquals(tag, EventSpecificInformationSMSImpl._ID_oSmsSubmissionSpecificInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getOSmsFailureSpecificInfo()); assertNotNull(prim.getOSmsSubmissionSpecificInfo()); assertNull(prim.getTSmsFailureSpecificInfo()); assertNull(prim.getTSmsDeliverySpecificInfo()); //option 3 data = this.getData3(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new EventSpecificInformationSMSImpl(); prim.decodeAll(asn); assertEquals(tag, EventSpecificInformationSMSImpl._ID_tSmsFailureSpecificInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getOSmsFailureSpecificInfo()); assertNull(prim.getOSmsSubmissionSpecificInfo()); assertNotNull(prim.getTSmsFailureSpecificInfo()); TSmsFailureSpecificInfo tSmsFailureSpecificInfo = prim.getTSmsFailureSpecificInfo(); assertEquals(tSmsFailureSpecificInfo.GetFailureCause().getData(),6); assertNull(prim.getTSmsDeliverySpecificInfo()); //option 4 data = this.getData4(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new EventSpecificInformationSMSImpl(); prim.decodeAll(asn); assertEquals(tag, EventSpecificInformationSMSImpl._ID_tSmsDeliverySpecificInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getOSmsFailureSpecificInfo()); assertNull(prim.getOSmsSubmissionSpecificInfo()); assertNull(prim.getTSmsFailureSpecificInfo()); assertNotNull(prim.getTSmsDeliverySpecificInfo()); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { MTSMSCauseImpl failureCause = new MTSMSCauseImpl(6); OSmsFailureSpecificInfo oSmsFailureSpecificInfo = new OSmsFailureSpecificInfoImpl(MOSMSCause.facilityNotSupported); OSmsSubmissionSpecificInfo oSmsSubmissionSpecificInfo = new OSmsSubmissionSpecificInfoImpl(); TSmsFailureSpecificInfo tSmsFailureSpecificInfo = new TSmsFailureSpecificInfoImpl(failureCause); TSmsDeliverySpecificInfo tSmsDeliverySpecificInfo = new TSmsDeliverySpecificInfoImpl(); //option 1 EventSpecificInformationSMSImpl prim = new EventSpecificInformationSMSImpl(oSmsFailureSpecificInfo); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); //option 2 prim = new EventSpecificInformationSMSImpl(oSmsSubmissionSpecificInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); //option 3 prim = new EventSpecificInformationSMSImpl(tSmsFailureSpecificInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData3())); //option 4 prim = new EventSpecificInformationSMSImpl(tSmsDeliverySpecificInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData4())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms.primitive; import java.io.Serializable; import org.restcomm.protocols.ss7.cap.api.EsiSms.OSmsFailureSpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.OSmsSubmissionSpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.TSmsDeliverySpecificInfo; import org.restcomm.protocols.ss7.cap.api.EsiSms.TSmsFailureSpecificInfo; /** * EventSpecificInformationSMS ::= CHOICE { o-smsFailureSpecificInfo [0] SEQUENCE { failureCause [0] MO-SMSCause OPTIONAL, ... * }, o-smsSubmissionSpecificInfo [1] SEQUENCE { -- no specific info defined ... }, t-smsFailureSpecificInfo [2] SEQUENCE { * failureCause [0] MT-SMSCause OPTIONAL, ... }, t-smsDeliverySpecificInfo [3] SEQUENCE { -- no specific info defined ... } } * * * @author sergey vetyutnev * */ public interface EventSpecificInformationSMS extends Serializable { OSmsFailureSpecificInfo getOSmsFailureSpecificInfo(); OSmsSubmissionSpecificInfo getOSmsSubmissionSpecificInfo(); TSmsFailureSpecificInfo getTSmsFailureSpecificInfo(); TSmsDeliverySpecificInfo getTSmsDeliverySpecificInfo(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBasicServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtCallBarringFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSStatusImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ExtCallBarringFeatureTest { public byte[] getData() { return new byte[] { 48, 47, -126, 1, 38, -124, 1, 3, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ExtCallBarringFeatureImpl prim = new ExtCallBarringFeatureImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertEquals(prim.getBasicService().getExtBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); assertNull(prim.getBasicService().getExtTeleservice()); assertNotNull(prim.getSsStatus()); assertTrue(prim.getSsStatus().getBitA()); assertFalse(prim.getSsStatus().getBitP()); assertFalse(prim.getSsStatus().getBitQ()); assertTrue(prim.getSsStatus().getBitR()); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { ExtBearerServiceCodeImpl b = new ExtBearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); ExtBasicServiceCodeImpl basicService = new ExtBasicServiceCodeImpl(b); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); ExtSSStatusImpl ssStatus = new ExtSSStatusImpl(false, false, true, true); ExtCallBarringFeatureImpl prim = new ExtCallBarringFeatureImpl(basicService, ssStatus, extensionContainer); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * Ext-CallBarringFeature ::= SEQUENCE { basicService Ext-BasicServiceCode OPTIONAL, ss-Status [4] Ext-SS-Status, * extensionContainer ExtensionContainer OPTIONAL, ...} * * * * @author sergey vetyutnev * */ public interface ExtCallBarringFeature extends Serializable { ExtBasicServiceCode getBasicService(); ExtSSStatus getSsStatus(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.locationManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.LAIFixedLength; import org.restcomm.protocols.ss7.map.api.primitives.LMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.LAIFixedLengthImpl; import org.restcomm.protocols.ss7.map.primitives.LMSIImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.primitives.TMSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.SendIdentificationRequestImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class SendIdentificationRequestTest { public byte[] getData1() { return new byte[] { 4, 4, 1, 2, 3, 4 }; }; public byte[] getData2() { return new byte[] { 48, 82, 4, 4, 1, 2, 3, 4, 2, 1, 2, 5, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 4, 4, -111, 34, 50, -12, -128, 5, 16, 97, 66, 1, 77, -127, 1, 4, -126, 0, -125, 4, -111, 34, 50, -11, -124, 4, 1, 2, 3, 4 }; }; public byte[] getDataTmsi() { return new byte[] { 1, 2, 3, 4 }; }; public byte[] getDataLmsi() { return new byte[] { 1, 2, 3, 4 }; }; @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { // version 2 byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); SendIdentificationRequestImpl prim = new SendIdentificationRequestImpl(2); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(prim.getTmsi().getData(), getDataTmsi())); // version 3 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new SendIdentificationRequestImpl(3); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(prim.getTmsi().getData(), getDataTmsi())); assertTrue(prim.getNumberOfRequestedVectors().equals(2)); assertTrue(prim.getSegmentationProhibited()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(prim.getExtensionContainer())); ISDNAddressString mscNumber = prim.getMscNumber(); assertTrue(mscNumber.getAddress().equals("22234")); assertEquals(mscNumber.getAddressNature(), AddressNature.international_number); assertEquals(mscNumber.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(prim.getPreviousLAI().getMCC(), 11); assertEquals(prim.getPreviousLAI().getMNC(), 246); assertEquals(prim.getPreviousLAI().getLac(), 333); assertTrue(prim.getHopCounter().equals(4)); assertTrue(prim.getMtRoamingForwardingSupported()); ISDNAddressString newVLRNumber = prim.getNewVLRNumber(); assertTrue(newVLRNumber.getAddress().equals("22235")); assertEquals(newVLRNumber.getAddressNature(), AddressNature.international_number); assertEquals(newVLRNumber.getNumberingPlan(), NumberingPlan.ISDN); assertTrue(Arrays.equals(prim.getNewLmsi().getData(), getDataLmsi())); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(prim.getExtensionContainer())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { // version 2 TMSIImpl tmsi = new TMSIImpl(getDataTmsi()); SendIdentificationRequestImpl prim = new SendIdentificationRequestImpl(tmsi, 2); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); // version 3 tmsi = new TMSIImpl(getDataTmsi()); Integer numberOfRequestedVectors = 2; boolean segmentationProhibited = true; MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); ISDNAddressString mscNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22234"); LAIFixedLength previousLAI = new LAIFixedLengthImpl(11, 246, 333); Integer hopCounter = 4; boolean mtRoamingForwardingSupported = true; ISDNAddressString newVLRNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); LMSI lmsi = new LMSIImpl(getDataLmsi()); prim = new SendIdentificationRequestImpl(tmsi, numberOfRequestedVectors, segmentationProhibited, extensionContainer, mscNumber, previousLAI, hopCounter, mtRoamingForwardingSupported, newVLRNumber, lmsi, 3); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.LAIFixedLength; import org.restcomm.protocols.ss7.map.api.primitives.LMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.TMSI; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * <code> MAP V2-3: MAP V3: sendIdentification OPERATION ::= { --Timer s ARGUMENT SendIdentificationArg RESULT SendIdentificationRes ERRORS { dataMissing | unidentifiedSubscriber} CODE local:55 } MAP V2: SendIdentification::= OPERATION --Timer s] ARGUMENT tmsi TMSI RESULT sendIdentificationRes SendIdentificationRes ERRORS { DataMissing, UnidentifiedSubscriber} MAP V3: SendIdentificationArg ::= SEQUENCE { tmsi TMSI, numberOfRequestedVectors NumberOfRequestedVectors OPTIONAL, -- within a dialogue numberOfRequestedVectors shall be present in -- the first service request and shall not be present in subsequent service requests. -- If received in a subsequent service request it shall be discarded. segmentationProhibited NULL OPTIONAL, extensionContainer ExtensionContainer OPTIONAL, ..., msc-Number ISDN-AddressString OPTIONAL, previous-LAI [0] LAIFixedLength OPTIONAL, hopCounter [1] HopCounter OPTIONAL, mtRoamingForwardingSupported [2] NULL OPTIONAL, newVLR-Number [3] ISDN-AddressString OPTIONAL, new-lmsi [4] LMSI OPTIONAL } NumberOfRequestedVectors ::= INTEGER (1..5) HopCounter ::= INTEGER (0..3) </code> * * * @author sergey vetyutnev * */ public interface SendIdentificationRequest extends MobilityMessage { TMSI getTmsi(); Integer getNumberOfRequestedVectors(); boolean getSegmentationProhibited(); MAPExtensionContainer getExtensionContainer(); ISDNAddressString getMscNumber(); LAIFixedLength getPreviousLAI(); Integer getHopCounter(); boolean getMtRoamingForwardingSupported(); ISDNAddressString getNewVLRNumber(); LMSI getNewLmsi(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultCallHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmCamelTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TBcsmCamelTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TCSIImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class TCSIImplTest { private byte[] getEncodedData() { return new byte[] { -96, 23, 48, 18, 48, 16, 10, 1, 12, 2, 1, 3, -128, 5, -111, 17, 34, 51, -13, -127, 1, 1, -128, 1, 2 }; } private byte[] getEncodedDataFull() { return new byte[] { -96, 68, 48, 18, 48, 16, 10, 1, 12, 2, 1, 3, -128, 5, -111, 17, 34, 51, -13, -127, 1, 1, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -128, 1, 4, -127, 0, -126, 0 }; } @Test(groups = { "functional.decode", "service.mobility.subscriberManagement" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); TCSIImpl ind = new TCSIImpl(); assertEquals(tag, 0); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); ind.decodeAll(asn); ArrayList<TBcsmCamelTDPData> lst = ind.getTBcsmCamelTDPDataList(); assertEquals(lst.size(), 1); TBcsmCamelTDPData cd = lst.get(0); assertEquals(cd.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.termAttemptAuthorized); assertEquals(cd.getServiceKey(), 3); assertEquals(cd.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(cd.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(cd.getGsmSCFAddress().getAddress().equals("1122333")); assertEquals(cd.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertNull(cd.getExtensionContainer()); assertNull(ind.getExtensionContainer()); assertEquals((int) ind.getCamelCapabilityHandling(), 2); assertFalse(ind.getNotificationToCSE()); assertFalse(ind.getCsiActive()); rawData = getEncodedDataFull(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new TCSIImpl(); assertEquals(tag, 0); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); ind.decodeAll(asn); lst = ind.getTBcsmCamelTDPDataList(); assertEquals(lst.size(), 1); cd = lst.get(0); assertEquals(cd.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.termAttemptAuthorized); assertEquals(cd.getServiceKey(), 3); assertEquals(cd.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(cd.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(cd.getGsmSCFAddress().getAddress().equals("1122333")); assertEquals(cd.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertNull(cd.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); assertEquals((int) ind.getCamelCapabilityHandling(), 4); assertTrue(ind.getNotificationToCSE()); assertTrue(ind.getCsiActive()); } @Test(groups = { "functional.encode", "service.mobility.subscriberManagement" }) public void testEncode() throws Exception { ISDNAddressStringImpl gsmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1122333"); TBcsmCamelTDPDataImpl cind = new TBcsmCamelTDPDataImpl(TBcsmTriggerDetectionPoint.termAttemptAuthorized, 3, gsmSCFAddress, DefaultCallHandling.releaseCall, null); ArrayList<TBcsmCamelTDPData> lst = new ArrayList<TBcsmCamelTDPData>(); lst.add(cind); TCSIImpl ind = new TCSIImpl(lst, null, 2, false, false); AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 0); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); ind = new TCSIImpl(lst, MAPExtensionContainerTest.GetTestExtensionContainer(), 4, true, true); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 0); encodedData = asnOS.toByteArray(); rawData = getEncodedDataFull(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import java.io.IOException; import java.util.ArrayList; import org.mobicents.protocols.asn.AsnException; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.MAPException; import org.restcomm.protocols.ss7.map.api.MAPParsingComponentException; import org.restcomm.protocols.ss7.map.api.MAPParsingComponentExceptionReason; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmCamelTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TCSI; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerImpl; import org.restcomm.protocols.ss7.map.primitives.SequenceBase; /** * * @author sergey vetyutnev * */ public class TCSIImpl extends SequenceBase implements TCSI { public static final int _TAGcamelCapabilityHandling = 0; public static final int _TAGnotificationToCSE = 1; public static final int _TAGcsi_Active = 2; public ArrayList<TBcsmCamelTDPData> tBcsmCamelTDPDataList; public MAPExtensionContainer extensionContainer; public Integer camelCapabilityHandling; public boolean notificationToCSE; public boolean csiActive; public TCSIImpl() { super("TCSI"); } public TCSIImpl(ArrayList<TBcsmCamelTDPData> tBcsmCamelTDPDataList, MAPExtensionContainer extensionContainer, Integer camelCapabilityHandling, boolean notificationToCSE, boolean csiActive) { super("TCSI"); this.tBcsmCamelTDPDataList = tBcsmCamelTDPDataList; this.extensionContainer = extensionContainer; this.camelCapabilityHandling = camelCapabilityHandling; this.notificationToCSE = notificationToCSE; this.csiActive = csiActive; } @Override public ArrayList<TBcsmCamelTDPData> getTBcsmCamelTDPDataList() { return tBcsmCamelTDPDataList; } @Override public MAPExtensionContainer getExtensionContainer() { return extensionContainer; } @Override public Integer getCamelCapabilityHandling() { return camelCapabilityHandling; } @Override public boolean getNotificationToCSE() { return notificationToCSE; } @Override public boolean getCsiActive() { return csiActive; } @Override protected void _decode(AsnInputStream asnIS, int length) throws MAPParsingComponentException, IOException, AsnException { this.tBcsmCamelTDPDataList = null; this.extensionContainer = null; this.camelCapabilityHandling = null; this.notificationToCSE = false; this.csiActive = false; AsnInputStream ais = asnIS.readSequenceStreamData(length); int num = 0; while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); switch (num) { case 0: // t-BcsmCamelTDPDataList if (tag != Tag.SEQUENCE || ais.getTagClass() != Tag.CLASS_UNIVERSAL || ais.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": Parameter 0 bad tag, tag class or primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.tBcsmCamelTDPDataList = new ArrayList<TBcsmCamelTDPData>(); AsnInputStream ais2 = ais.readSequenceStream(); while (true) { if (ais2.available() == 0) break; int tag2 = ais2.readTag(); if (tag2 != Tag.SEQUENCE || ais2.getTagClass() != Tag.CLASS_UNIVERSAL || ais2.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": bad tag or tagClass or is primitive when decoding tBcsmCamelTDPDataList", MAPParsingComponentExceptionReason.MistypedParameter); TBcsmCamelTDPDataImpl elem = new TBcsmCamelTDPDataImpl(); ((TBcsmCamelTDPDataImpl) elem).decodeAll(ais2); this.tBcsmCamelTDPDataList.add(elem); } if (this.tBcsmCamelTDPDataList.size() < 1 || this.tBcsmCamelTDPDataList.size() > 10) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ".tBcsmCamelTDPDataList: tBcsmCamelTDPData elements count must be from 1 to 10, found: " + this.tBcsmCamelTDPDataList.size(), MAPParsingComponentExceptionReason.MistypedParameter); break; default: switch (ais.getTagClass()) { case Tag.CLASS_UNIVERSAL: { switch (tag) { case Tag.SEQUENCE: // forwardingData if (ais.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ".forwardingData: Parameter is primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(ais); break; default: ais.advanceElement(); break; } } break; case Tag.CLASS_CONTEXT_SPECIFIC: { switch (tag) { case _TAGcamelCapabilityHandling: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ".camelCapabilityHandling: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.camelCapabilityHandling = (int) ais.readInteger(); break; case _TAGnotificationToCSE: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ".notificationToCSE: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.notificationToCSE = true; ais.readNull(); break; case _TAGcsi_Active: if (!ais.isTagPrimitive()) throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ".csiActive: Parameter is not primitive", MAPParsingComponentExceptionReason.MistypedParameter); this.csiActive = true; ais.readNull(); break; default: ais.advanceElement(); break; } } break; default: ais.advanceElement(); break; } } num++; } if (num < 1) { throw new MAPParsingComponentException("Error while decoding " + _PrimitiveName + ": Parament tBcsmCamelTDPDataList is mandatory but does not found", MAPParsingComponentExceptionReason.MistypedParameter); } } @Override public void encodeData(AsnOutputStream asnOs) throws MAPException { try { if (this.tBcsmCamelTDPDataList == null) throw new MAPException("Error while encoding" + _PrimitiveName + ": tBcsmCamelTDPDataList must not be null"); if (this.tBcsmCamelTDPDataList.size() < 1 || this.tBcsmCamelTDPDataList.size() > 10) throw new MAPException("Error while encoding" + _PrimitiveName + ": tBcsmCamelTDPDataList size must be from 1 to 10, found: " + this.tBcsmCamelTDPDataList.size()); asnOs.writeTag(Tag.CLASS_UNIVERSAL, false, Tag.SEQUENCE); int pos = asnOs.StartContentDefiniteLength(); for (TBcsmCamelTDPData be : this.tBcsmCamelTDPDataList) { TBcsmCamelTDPDataImpl bee = (TBcsmCamelTDPDataImpl) be; bee.encodeAll(asnOs); } asnOs.FinalizeContent(pos); if (this.extensionContainer != null) ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOs); if (this.camelCapabilityHandling != null) asnOs.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _TAGcamelCapabilityHandling, this.camelCapabilityHandling); if (this.notificationToCSE) asnOs.writeNull(Tag.CLASS_CONTEXT_SPECIFIC, _TAGnotificationToCSE); if (this.csiActive) asnOs.writeNull(Tag.CLASS_CONTEXT_SPECIFIC, _TAGcsi_Active); } catch (IOException e) { throw new MAPException("IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e); } catch (AsnException e) { throw new MAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e); } } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(this._PrimitiveName); sb.append(" ["); if (this.tBcsmCamelTDPDataList != null) { sb.append("tBcsmCamelTDPDataList=["); for (TBcsmCamelTDPData be : this.tBcsmCamelTDPDataList) { sb.append(be.toString()); } sb.append("]"); } if (this.extensionContainer != null) { sb.append(", extensionContainer="); sb.append(this.extensionContainer.toString()); } if (this.camelCapabilityHandling != null) { sb.append(", camelCapabilityHandling="); sb.append(this.camelCapabilityHandling); } if (this.notificationToCSE) { sb.append(", notificationToCSE"); } if (this.csiActive) { sb.append(", csiActive"); } sb.append("]"); return sb.toString(); } } ```
```package org.restcomm.protocols.ss7.map.service.mobility.locationManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.ISRInformationImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ISRInformationTest { public byte[] getData1() { return new byte[] { 3, 2, 5, -32 }; }; public byte[] getData2() { return new byte[] { 3, 2, 5, 0 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // option 1 byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ISRInformationImpl prim = new ISRInformationImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(prim.getCancelSGSN()); assertTrue(prim.getInitialAttachIndicator()); assertTrue(prim.getUpdateMME()); // option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ISRInformationImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertFalse(prim.getCancelSGSN()); assertFalse(prim.getInitialAttachIndicator()); assertFalse(prim.getUpdateMME()); } @Test(groups = { "functional.decode", "primitives" }) public void testEncode() throws Exception { // option 1 ISRInformationImpl prim = new ISRInformationImpl(true, true, true); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); // option 2 prim = new ISRInformationImpl(false, false, false); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement; import java.io.Serializable; /** * ISR-Information::= BIT STRING { updateMME (0), cancelSGSN (1), initialAttachIndicator (2)} (SIZE (3..8)) -- exception * handling: reception of unknown bit assignments in the -- ISR-Information data type shall be discarded by the receiver * * * @author sergey vetyutnev * */ public interface ISRInformation extends Serializable { boolean getUpdateMME(); boolean getCancelSGSN(); boolean getInitialAttachIndicator(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.authentication.AuthenticationTripletImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AuthenticationTripletTest { private byte[] getEncodedData() { return new byte[] { 48, 34, 4, 16, 15, (byte) 254, 18, (byte) 164, (byte) 207, 43, (byte) 221, (byte) 185, (byte) 178, (byte) 158, 109, 83, (byte) 180, (byte) 169, 77, (byte) 128, 4, 4, (byte) 224, 82, (byte) 239, (byte) 242, 4, 8, 31, 72, (byte) 163, 97, 78, (byte) 239, (byte) 204, 0 }; } static protected byte[] getRandData() { return new byte[] { 15, -2, 18, -92, -49, 43, -35, -71, -78, -98, 109, 83, -76, -87, 77, -128 }; } static protected byte[] getSresData() { return new byte[] { -32, 82, -17, -14 }; } static protected byte[] getKcData() { return new byte[] { 31, 72, -93, 97, 78, -17, -52, 0 }; } @Test public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); AuthenticationTripletImpl asc = new AuthenticationTripletImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(asc.getRand(), getRandData())); assertTrue(Arrays.equals(asc.getSres(), getSresData())); assertTrue(Arrays.equals(asc.getKc(), getKcData())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { AuthenticationTripletImpl asc = new AuthenticationTripletImpl(getRandData(), getSresData(), getKcData()); AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import java.io.Serializable; /** * AuthenticationTriplet ::= SEQUENCE { rand RAND, sres SRES, kc Kc, ...} * * * RAND ::= OCTET STRING (SIZE (16)) SRES ::= OCTET STRING (SIZE (4)) Kc ::= OCTET STRING (SIZE (8)) * * @author sergey vetyutnev * */ public interface AuthenticationTriplet extends Serializable { byte[] getRand(); byte[] getSres(); byte[] getKc(); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.sms.MoForwardShortMessageResponseImpl; import org.restcomm.protocols.ss7.map.service.sms.SmsSignalInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class MoForwardShortMessageResponseTest { private byte[] getEncodedData() { return new byte[] { 48, 48, 4, 5, 11, 22, 33, 44, 55, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); MoForwardShortMessageResponseImpl ind = new MoForwardShortMessageResponseImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(new byte[] { 11, 22, 33, 44, 55 }, ind.getSM_RP_UI().getData())); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { SmsSignalInfo ui = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55 }, null); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); MoForwardShortMessageResponseImpl ind = new MoForwardShortMessageResponseImpl(ui, extensionContainer); AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * MO-ForwardSM-Res ::= SEQUENCE { sm-RP-UI SignalInfo OPTIONAL, extensionContainer ExtensionContainer OPTIONAL, ...} * * * * * @author sergey vetyutnev * */ public interface MoForwardShortMessageResponse extends SmsMessage { SmsSignalInfo getSM_RP_UI(); MAPExtensionContainer getExtensionContainer(); }```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.AppendFreeFormatData; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.FreeFormatDataGprs; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.PDPID; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.FCIBCCCAMELsequence1GprsImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.FreeFormatDataGprsImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.PDPIDImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class FCIBCCCAMELsequence1GprsTest { public byte[] getData() { return new byte[] { -96, 16, -128, 8, 48, 6, -128, 1, 5, -127, 1, 2, -127, 1, 2, -126, 1, 1 }; }; public byte[] getFreeFormatData() { return new byte[] { 48, 6, -128, 1, 5, -127, 1, 2 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); FCIBCCCAMELsequence1GprsImpl prim = new FCIBCCCAMELsequence1GprsImpl(); prim.decodeAll(asn); assertEquals(tag, FCIBCCCAMELsequence1GprsImpl._ID_FCIBCCCAMELsequence1); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertEquals(prim.getFreeFormatData().getData(), this.getFreeFormatData()); assertEquals(prim.getPDPID().getId(), 2); assertEquals(prim.getAppendFreeFormatData(), AppendFreeFormatData.append); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { FreeFormatDataGprs freeFormatData = new FreeFormatDataGprsImpl(this.getFreeFormatData()); PDPID pdpID = new PDPIDImpl(2); FCIBCCCAMELsequence1GprsImpl prim = new FCIBCCCAMELsequence1GprsImpl(freeFormatData, pdpID, AppendFreeFormatData.append); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; import org.restcomm.protocols.ss7.cap.api.primitives.AppendFreeFormatData; /** * fCIBCCCAMELsequence1 [0] SEQUENCE { freeFormatData [0] OCTET STRING (SIZE(1 .. 160)), pDPID [1] PDPID OPTIONAL, * appendFreeFormatData [2] AppendFreeFormatData DEFAULT overwrite, ... } * * * @author sergey vetyutnev * */ public interface FCIBCCCAMELsequence1Gprs extends Serializable { FreeFormatDataGprs getFreeFormatData(); PDPID getPDPID(); AppendFreeFormatData getAppendFreeFormatData(); }```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.oam.MGWEventListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class MGWEventListTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 7, (byte) 128 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); MGWEventListImpl asc = new MGWEventListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getContext()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { MGWEventListImpl asc = new MGWEventListImpl(true); // boolean context AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> MGW-EventList ::= BIT STRING { context (0) } (SIZE (1..8)) -- Other bits than listed above shall be discarded. </code> * * * @author sergey vetyutnev * */ public interface MGWEventList extends Serializable { boolean getContext(); } ```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.GPRSQoSImpl; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtQoSSubscribed; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.QoSSubscribed; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtQoSSubscribedImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.QoSSubscribedImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class GPRSQoSTest { public byte[] getData() { return new byte[] { -128, 3, 4, 7, 7 }; }; public byte[] getData2() { return new byte[] { -127, 2, 1, 7 }; }; public byte[] getQoSSubscribedData() { return new byte[] { 4, 7, 7 }; }; public byte[] getExtQoSSubscribedData() { return new byte[] { 1, 7 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // Option 1 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); GPRSQoSImpl prim = new GPRSQoSImpl(); prim.decodeAll(asn); assertEquals(tag, GPRSQoSImpl._ID_shortQoSFormat); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(Arrays.equals(prim.getShortQoSFormat().getData(), this.getQoSSubscribedData())); assertNull(prim.getLongQoSFormat()); // Option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new GPRSQoSImpl(); prim.decodeAll(asn); assertEquals(tag, GPRSQoSImpl._ID_longQoSFormat); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(Arrays.equals(prim.getLongQoSFormat().getData(), this.getExtQoSSubscribedData())); assertNull(prim.getShortQoSFormat()); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { // Option 1 QoSSubscribed qosSubscribed = new QoSSubscribedImpl(this.getQoSSubscribedData()); GPRSQoSImpl prim = new GPRSQoSImpl(qosSubscribed); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // Option 2 ExtQoSSubscribed extQoSSubscribed = new ExtQoSSubscribedImpl(this.getExtQoSSubscribedData()); prim = new GPRSQoSImpl(extQoSSubscribed); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtQoSSubscribed; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.QoSSubscribed; /** * GPRS-QoS ::= CHOICE { short-QoS-format [0] QoS-Subscribed, long-QoS-format [1] Ext-QoS-Subscribed } -- Short-QoS-format shall * be sent for QoS in pre GSM release 99 format. -- Long-QoS-format shall be sent for QoS in GSM release 99 (and beyond) format. * -- Which of the two QoS formats shall be sent is determined by which QoS -- format is available in the SGSN at the time of * sending. -- Refer to 3GPP TS 29.002 [11] for encoding details of QoS-Subscribed and -- Ext-QoS-Subscribed. * * * @author sergey vetyutnev * */ public interface GPRSQoS extends Serializable { QoSSubscribed getShortQoSFormat(); ExtQoSSubscribed getLongQoSFormat(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.SubscriberStateChoice; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.ProvideSubscriberInfoResponseImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.SubscriberInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.SubscriberStateImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ProvideSubscriberInfoResponseTest { private byte[] getEncodedData() { return new byte[] { 48, 6, 48, 4, (byte) 161, 2, (byte) 129, 0 }; } private byte[] getEncodedData2() { return new byte[] { 48, 47, 48, 4, (byte) 161, 2, (byte) 129, 0, 48, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33 }; } @Test(groups = { "functional.decode", "service.mobility.subscriberInformation" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); ProvideSubscriberInfoResponseImpl asc = new ProvideSubscriberInfoResponseImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getSubscriberInfo().getSubscriberState().getSubscriberStateChoice(), SubscriberStateChoice.camelBusy); assertNull(asc.getExtensionContainer()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new ProvideSubscriberInfoResponseImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getSubscriberInfo().getSubscriberState().getSubscriberStateChoice(), SubscriberStateChoice.camelBusy); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(asc.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.mobility.subscriberInformation" }) public void testEncode() throws Exception { SubscriberStateImpl subscriberState = new SubscriberStateImpl(SubscriberStateChoice.camelBusy, null); SubscriberInfoImpl subscriberInfo = new SubscriberInfoImpl(null, subscriberState, null, null, null, null, null, null, null); ProvideSubscriberInfoResponseImpl asc = new ProvideSubscriberInfoResponseImpl(subscriberInfo, null); // SubscriberInfo subscriberInfo, MAPExtensionContainer extensionContainer AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); asc = new ProvideSubscriberInfoResponseImpl(subscriberInfo, MAPExtensionContainerTest.GetTestExtensionContainer()); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * <p> * The HLR may use MAP PSI to obtain subscriber data from VLR; the subscriber data that may be obtained with MAP PSI includes * location information and subscriber state. In CAMEL phase 3 and CAMEL phase 4, additional information may be obtained from * the VLR * </p> * <p> * Within the context of CAMEL, the HLR may use MAP PSI for the following procedures: (1) MT call handling (2) ATI * </p> * <p> * The HLR may also use MAP PSI for optimal routing (OR); refer to GSM TS 03.79 [39] for a description of OR * </p> * <code> ProvideSubscriberInfoRes ::= SEQUENCE { subscriberInfo SubscriberInfo, extensionContainer ExtensionContainer OPTIONAL, ... } </code> * * * * @author sergey vetyutnev * */ public interface ProvideSubscriberInfoResponse extends MobilityMessage { SubscriberInfo getSubscriberInfo(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.smstpdu; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import java.util.Map; import org.restcomm.protocols.ss7.map.api.datacoding.NationalLanguageIdentifier; import org.restcomm.protocols.ss7.map.api.smstpdu.ConcatenatedShortMessagesIdentifier; import org.restcomm.protocols.ss7.map.api.smstpdu.NationalLanguageLockingShiftIdentifier; import org.restcomm.protocols.ss7.map.api.smstpdu.NationalLanguageSingleShiftIdentifier; import org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeaderElement; import org.restcomm.protocols.ss7.map.smstpdu.ConcatenatedShortMessagesIdentifierImpl; import org.restcomm.protocols.ss7.map.smstpdu.NationalLanguageLockingShiftIdentifierImpl; import org.restcomm.protocols.ss7.map.smstpdu.NationalLanguageSingleShiftIdentifierImpl; import org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class UserDataHeaderTest { public byte[] getData1() { return new byte[] { 6, 8, 4, 0, -47, 3, 2 }; } public byte[] getData11() { return new byte[] { 6, 8, 4, 10, 1, 3, 2 }; } public byte[] getData2() { return new byte[] { 5, 0, 3, -116, 2, 1 }; } public byte[] getDataA1() { return new byte[] { 3, 37, 1, 2 }; } public byte[] getDataA2() { return new byte[] { 3, 36, 1, 3 }; } public byte[] getData3() { return new byte[] { 4, 13, 2, 20, 6 }; } public byte[] getData4() { return new byte[] { 40, 0, 3, 40, 3, 2, 17, 33, 48, -1, -1, -128, 49, -128, 49, -113, -15, -97, -7, -104, 25, -104, 25, -104, 25, -97, -7, -97, -7, -103, -103, -97, -7, -97, -7, -103, -103, -97, -7, -1, -1 }; } public byte[] getData5() { return new byte[] { 9, 0, 3, 40, 3, 3, 11, 2, 0, 0 }; } public byte[] getData6() { return new byte[] { 9, 10, 3, 0, 32, 4, 11, 2, 32, 5 }; } public byte[] getData7() { return new byte[] { 6, 5, 4, 35, -12, 0, 0 }; } public byte[] getData8() { return new byte[] { 2, 112, 0 }; } @Test(groups = { "functional.decode", "smstpdu" }) public void testDecode() throws Exception { UserDataHeaderImpl impl = new UserDataHeaderImpl(this.getData1()); Map<Integer, byte[]> mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(8), new byte[] { 0, -47, 3, 2 })); ConcatenatedShortMessagesIdentifier conc = impl.getConcatenatedShortMessagesIdentifier(); assertNotNull(conc); assertEquals(conc.getReferenceIs16bit(), true); assertEquals(conc.getReference(), 53504); assertEquals(conc.getMesageSegmentCount(), 3); assertEquals(conc.getMesageSegmentNumber(), 2); impl = new UserDataHeaderImpl(this.getData11()); mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(8), new byte[] { 10, 1, 3, 2 })); conc = impl.getConcatenatedShortMessagesIdentifier(); assertNotNull(conc); assertEquals(conc.getReferenceIs16bit(), true); assertEquals(conc.getReference(), 266); assertEquals(conc.getMesageSegmentCount(), 3); assertEquals(conc.getMesageSegmentNumber(), 2); impl = new UserDataHeaderImpl(this.getData2()); mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(0), new byte[] { -116, 2, 1 })); conc = impl.getConcatenatedShortMessagesIdentifier(); assertNotNull(conc); assertEquals(conc.getReferenceIs16bit(), false); assertEquals(conc.getReference(), 140); assertEquals(conc.getMesageSegmentCount(), 2); assertEquals(conc.getMesageSegmentNumber(), 1); impl = new UserDataHeaderImpl(this.getDataA1()); mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(37), new byte[] { 2 })); NationalLanguageLockingShiftIdentifier nls = impl.getNationalLanguageLockingShift(); assertNotNull(nls); assertEquals(nls.getNationalLanguageIdentifier(), NationalLanguageIdentifier.Spanish); impl = new UserDataHeaderImpl(this.getDataA2()); mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(36), new byte[] { 3 })); NationalLanguageSingleShiftIdentifier nss = impl.getNationalLanguageSingleShift(); assertNotNull(nss); assertEquals(nss.getNationalLanguageIdentifier(), NationalLanguageIdentifier.Portuguese); // TODO: implement getData3()-getData7() decoding impl = new UserDataHeaderImpl(this.getData8()); mp = impl.getAllData(); assertEquals(impl.getAllData().size(), 1); assertTrue(Arrays.equals(mp.get(112), new byte[] { })); } @Test(groups = { "functional.encode", "smstpdu" }) public void testEncode() throws Exception { UserDataHeaderImpl impl = new UserDataHeaderImpl(); UserDataHeaderElement ie = new ConcatenatedShortMessagesIdentifierImpl(true, 53504, 3, 2); impl.addInformationElement(ie); assertTrue(Arrays.equals(impl.getEncodedData(), this.getData1())); impl = new UserDataHeaderImpl(); ie = new ConcatenatedShortMessagesIdentifierImpl(true, 266, 3, 2); impl.addInformationElement(ie); assertTrue(Arrays.equals(impl.getEncodedData(), this.getData11())); impl = new UserDataHeaderImpl(); ie = new ConcatenatedShortMessagesIdentifierImpl(false, 140, 2, 1); impl.addInformationElement(ie); assertTrue(Arrays.equals(impl.getEncodedData(), this.getData2())); impl = new UserDataHeaderImpl(); ie = new NationalLanguageLockingShiftIdentifierImpl(NationalLanguageIdentifier.Spanish); impl.addInformationElement(ie); assertTrue(Arrays.equals(impl.getEncodedData(), this.getDataA1())); impl = new UserDataHeaderImpl(); ie = new NationalLanguageSingleShiftIdentifierImpl(NationalLanguageIdentifier.Portuguese); impl.addInformationElement(ie); assertTrue(Arrays.equals(impl.getEncodedData(), this.getDataA2())); // TODO: implement getData3()-getData7() encoding impl = new UserDataHeaderImpl(); ie = new ConcatenatedShortMessagesIdentifierImpl(false, 140, 2, 1); impl.addInformationElement(112, new byte[] {}); assertTrue(Arrays.equals(impl.getEncodedData(), this.getData8())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.smstpdu; import java.io.Serializable; import java.util.Map; /** * * @author sergey vetyutnev * */ public interface UserDataHeader extends Serializable { int _InformationElementIdentifier_ConcatenatedShortMessages8bit = 0x00; int _InformationElementIdentifier_ApplicationPortAddressingScheme16BitAddress = 0x05; int _InformationElementIdentifier_ConcatenatedShortMessages16bit = 0x08; int _InformationElementIdentifier_NationalLanguageSingleShift = 0x24; int _InformationElementIdentifier_NationalLanguageLockingShift = 0x25; byte[] getEncodedData(); Map<Integer, byte[]> getAllData(); void addInformationElement(int informationElementIdentifier, byte[] encodedData); void addInformationElement(UserDataHeaderElement informationElement); byte[] getInformationElementData(int informationElementIdentifier); NationalLanguageLockingShiftIdentifier getNationalLanguageLockingShift(); NationalLanguageSingleShiftIdentifier getNationalLanguageSingleShift(); ConcatenatedShortMessagesIdentifier getConcatenatedShortMessagesIdentifier(); ApplicationPortAddressing16BitAddress getApplicationPortAddressing16BitAddress(); }```
```package org.restcomm.protocols.ss7.map.service.supplementary; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.supplementary.SSStatusImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class SSStatusTest { private byte[] getEncodedData1() { return new byte[] { 4, 1, 10 }; } private byte[] getEncodedData2() { return new byte[] { 4, 1, 5 }; } @Test(groups = { "functional.decode", "service.supplementary" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData1(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); SSStatusImpl impl = new SSStatusImpl(); impl.decodeAll(asn); assertTrue(impl.getQBit()); assertFalse(impl.getPBit()); assertTrue(impl.getRBit()); assertFalse(impl.getABit()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); impl = new SSStatusImpl(); impl.decodeAll(asn); assertFalse(impl.getQBit()); assertTrue(impl.getPBit()); assertFalse(impl.getRBit()); assertTrue(impl.getABit()); } @Test(groups = { "functional.encode", "service.supplementary" }) public void testEncode() throws Exception { SSStatusImpl impl = new SSStatusImpl(true, false, true, false); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); impl = new SSStatusImpl(false, true, false, true); asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.supplementary; import java.io.Serializable; /** * SS-Status ::= OCTET STRING (SIZE (1)) * * -- bits 8765: 0000 (unused) -- bits 4321: Used to convey the "P bit","R bit","A bit" and "Q bit", -- representing * supplementary service state information -- as defined in TS 3GPP TS 23.011 [22] * * -- bit 4: "Q bit" * * -- bit 3: "P bit" * * -- bit 2: "R bit" * * -- bit 1: "A bit" * * * * @author sergey vetyutnev * */ public interface SSStatus extends Serializable { int getData(); boolean getQBit(); boolean getPBit(); boolean getRBit(); boolean getABit(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtSSStatus; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSStatusImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MCSSInfoImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class MCSSInfoTest { public byte[] getData() { return new byte[] { 48, 53, -128, 1, 33, -127, 1, 10, -126, 1, 2, -125, 1, 4, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); MCSSInfoImpl prim = new MCSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getSSCode().getSupplementaryCodeValue(), SupplementaryCodeValue.cfu); ExtSSStatus ssStatus = prim.getSSStatus(); assertFalse(ssStatus.getBitA()); assertFalse(ssStatus.getBitP()); assertTrue(ssStatus.getBitQ()); assertTrue(ssStatus.getBitR()); assertEquals(prim.getNbrSB(), 2); assertEquals(prim.getNbrUser(), 4); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { SSCode ssCode = new SSCodeImpl(SupplementaryCodeValue.cfu); ExtSSStatus ssStatus = new ExtSSStatusImpl(true, false, true, false); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); MCSSInfoImpl prim = new MCSSInfoImpl(ssCode, ssStatus, 2, 4, extensionContainer); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; /** * <code> MC-SS-Info ::= SEQUENCE { ss-Code [0] SS-Code, ss-Status [1] Ext-SS-Status, nbrSB [2] MaxMC-Bearers, nbrUser [3] MC-Bearers, extensionContainer [4] ExtensionContainer OPTIONAL, ... } MaxMC-Bearers ::= INTEGER (2..7) MC-Bearers ::= INTEGER (1..7) </code> * * * * * @author sergey vetyutnev * */ public interface MCSSInfo extends Serializable { SSCode getSSCode(); ExtSSStatus getSSStatus(); int getNbrSB(); int getNbrUser(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.ElapsedTimeRollOverImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.ROTimeGPRSIfTariffSwitchImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.TransferredVolumeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ElapsedTimeRollOverTest { public byte[] getData() { return new byte[] { -128, 1, 24 }; }; public byte[] getData2() { return new byte[] { -95, 6, -128, 1, 12, -127, 1, 24 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // Option 1 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ElapsedTimeRollOverImpl prim = new ElapsedTimeRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, TransferredVolumeImpl._ID_volumeIfNoTariffSwitch); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(prim.getIsPrimitive()); assertEquals(prim.getROTimeGPRSIfNoTariffSwitch().intValue(), 24); assertNull(prim.getROTimeGPRSIfTariffSwitch()); // Option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ElapsedTimeRollOverImpl(); prim.decodeAll(asn); assertEquals(tag, TransferredVolumeImpl._ID_volumeIfTariffSwitch); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertFalse(prim.getIsPrimitive()); assertNull(prim.getROTimeGPRSIfNoTariffSwitch()); assertEquals(prim.getROTimeGPRSIfTariffSwitch().getROTimeGPRSSinceLastTariffSwitch().intValue(), 12); assertEquals(prim.getROTimeGPRSIfTariffSwitch().getROTimeGPRSTariffSwitchInterval().intValue(), 24); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { // Option 1 ElapsedTimeRollOverImpl prim = new ElapsedTimeRollOverImpl(new Integer(24)); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // Option 2 ROTimeGPRSIfTariffSwitchImpl roTimeGPRSIfTariffSwitch = new ROTimeGPRSIfTariffSwitchImpl(new Integer(12), new Integer( 24)); prim = new ElapsedTimeRollOverImpl(roTimeGPRSIfTariffSwitch); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; /** * ElapsedTimeRollOver ::= CHOICE { rO-TimeGPRSIfNoTariffSwitch [0] INTEGER (0..255), rO-TimeGPRSIfTariffSwitch [1] SEQUENCE { * rO-TimeGPRSSinceLastTariffSwitch [0] INTEGER (0..255) OPTIONAL, rO-TimeGPRSTariffSwitchInterval [1] INTEGER (0..255) OPTIONAL * } } -- rO-TimeGPRSIfNoTariffSwitch, rO-TimeGPRSSinceLastTariffSwitch and -- rO-TimeGPRSTariffSwitchInterval -- present * counters indicating the number of parameter range rollovers. * * * @author sergey vetyutnev * */ public interface ElapsedTimeRollOver extends Serializable { Integer getROTimeGPRSIfNoTariffSwitch(); ROTimeGPRSIfTariffSwitch getROTimeGPRSIfTariffSwitch(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.EMLPPPriority; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.LMSIImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.ProvideSubscriberInfoRequestImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.RequestedInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ProvideSubscriberInfoRequestTest { private byte[] getEncodedData() { return new byte[] { 48, 12, (byte) 128, 6, 17, 33, 34, 51, 67, 68, (byte) 162, 2, (byte) 128, 0 }; } private byte[] getEncodedData2() { return new byte[] { 48, 62, (byte) 128, 6, 17, 33, 34, 51, 67, 68, (byte) 129, 4, 11, 22, 33, 44, (byte) 162, 2, (byte) 128, 0, (byte) 163, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33, (byte) 132, 1, 4 }; } private byte[] getLmsiData() { return new byte[] { 11, 22, 33, 44 }; } @Test(groups = { "functional.decode", "service.mobility.subscriberInformation" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); ProvideSubscriberInfoRequestImpl asc = new ProvideSubscriberInfoRequestImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); IMSI imsi = asc.getImsi(); assertTrue(imsi.getData().equals("111222333444")); assertTrue(asc.getRequestedInfo().getLocationInformation()); assertFalse(asc.getRequestedInfo().getSubscriberState()); assertNull(asc.getLmsi()); assertNull(asc.getExtensionContainer()); assertNull(asc.getCallPriority()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new ProvideSubscriberInfoRequestImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("111222333444")); assertTrue(asc.getRequestedInfo().getLocationInformation()); assertFalse(asc.getRequestedInfo().getSubscriberState()); assertEquals(asc.getLmsi().getData(), getLmsiData()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(asc.getExtensionContainer())); assertEquals(asc.getCallPriority(), EMLPPPriority.priorityLevel4); } @Test(groups = { "functional.encode", "service.mobility.subscriberInformation" }) public void testEncode() throws Exception { IMSIImpl imsi = new IMSIImpl("111222333444"); RequestedInfoImpl requestedInfo = new RequestedInfoImpl(true, false, null, false, null, false, false, false); ProvideSubscriberInfoRequestImpl asc = new ProvideSubscriberInfoRequestImpl(imsi, null, requestedInfo, null, null); // IMSI imsi, LMSI lmsi, RequestedInfo requestedInfo, MAPExtensionContainer extensionContainer, // EMLPPPriority callPriority AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); LMSIImpl lmsi = new LMSIImpl(getLmsiData()); asc = new ProvideSubscriberInfoRequestImpl(imsi, lmsi, requestedInfo, MAPExtensionContainerTest.GetTestExtensionContainer(), EMLPPPriority.priorityLevel4); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation; import org.restcomm.protocols.ss7.map.api.primitives.EMLPPPriority; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.LMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * <code> MAP V3: provideSubscriberInfo OPERATION ::= { --Timer m ARGUMENT ProvideSubscriberInfoArg RESULT ProvideSubscriberInfoRes ERRORS { dataMissing | unexpectedDataValue} CODE local:70 } ProvideSubscriberInfoArg ::= SEQUENCE { imsi [0] IMSI, lmsi [1] LMSI OPTIONAL, requestedInfo [2] RequestedInfo, extensionContainer [3] ExtensionContainer OPTIONAL, ..., callPriority [4] EMLPP-Priority OPTIONAL } </code> * * * * @author sergey vetyutnev * */ public interface ProvideSubscriberInfoRequest extends MobilityMessage { IMSI getImsi(); LMSI getLmsi(); RequestedInfo getRequestedInfo(); MAPExtensionContainer getExtensionContainer(); EMLPPPriority getCallPriority(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.BearerServiceCodeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class BearerServiceCodeTest { private byte[] getEncodedData1() { return new byte[] { (byte) 130, 1, 38 }; } @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData1(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); BearerServiceCodeImpl impl = new BearerServiceCodeImpl(); impl.decodeAll(asn); assertEquals(impl.getData(), 38); assertEquals(impl.getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { BearerServiceCodeImpl impl = new BearerServiceCodeImpl(38); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 2); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); impl = new BearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); asnOS = new AsnOutputStream(); impl.encodeAll(asnOS, Tag.CLASS_CONTEXT_SPECIFIC, 2); encodedData = asnOS.toByteArray(); rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * <code> BearerServiceCode ::= OCTET STRING (SIZE (1)) -- This type is used to represent the code identifying a single -- bearer service, a group of bearer services, or all bearer -- services. The services are defined in TS 3GPP TS 22.002 [3]. -- The internal structure is defined as follows: -- -- plmn-specific bearer services: -- bits 87654321: defined by the HPLMN operator -- rest of bearer services: -- bit 8: 0 (unused) -- bits 7654321: group (bits 7654), and rate, if applicable -- (bits 321) </code> * * * * @author sergey vetyutnev * */ public interface BearerServiceCode extends Serializable { int getData(); BearerServiceCodeValue getBearerServiceCodeValue(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.imei; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.primitives.IMEIImpl; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.imei.CheckImeiRequestImpl; import org.restcomm.protocols.ss7.map.service.mobility.imei.RequestedEquipmentInfoImpl; import org.testng.annotations.Test; /** * * @author normandes * */ public class CheckImeiRequestTest { // Real Trace private byte[] getEncodedDataV2() { return new byte[] { 0x04, 0x08, 0x53, 0x08, 0x19, 0x10, (byte) 0x86, 0x35, 0x55, (byte) 0xf0 }; } private byte[] getEncodedDataV3() { // TODO this is self generated trace. We need trace from operator return new byte[] { 48, 14, 4, 8, 83, 8, 25, 16, -122, 53, 85, -16, 3, 2, 6, -128 }; } private byte[] getEncodedDataV3Full() { // TODO this is self generated trace. We need trace from operator return new byte[] { 48, 55, 4, 8, 83, 8, 25, 16, -122, 53, 85, -16, 3, 2, 6, -128, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; } // Huawei trace with IMSI private byte[] getEncodedDataV2_Huawei() { return new byte[] { 0x04, 0x08, 0x53, 0x46, 0x76, 0x40, (byte) 0x94, (byte) 0x98, 0x19, (byte) 0xf0, 0x00, 0x08, 0x27, 0x34, 0x04, 0x03, 0x30, 0x58, 0x67, (byte) 0xf3 }; } private byte[] getEncodedDataImeiLengthLessThan15() { return new byte[] { 4, 1, -15 }; } @Test(groups = { "functional.decode", "imei" }) public void testDecode() throws Exception { // Testing version 3 byte[] rawData = getEncodedDataV3(); AsnInputStream asnIS = new AsnInputStream(rawData); int tag = asnIS.readTag(); assertEquals(tag, Tag.SEQUENCE); CheckImeiRequestImpl checkImeiImpl = new CheckImeiRequestImpl(3); checkImeiImpl.decodeAll(asnIS); assertTrue(checkImeiImpl.getIMEI().getIMEI().equals("358091016853550")); assertTrue(checkImeiImpl.getRequestedEquipmentInfo().getEquipmentStatus()); assertFalse(checkImeiImpl.getRequestedEquipmentInfo().getBmuef()); assertNull(checkImeiImpl.getIMSI()); // Testing version 3 Full rawData = getEncodedDataV3Full(); asnIS = new AsnInputStream(rawData); tag = asnIS.readTag(); assertEquals(tag, Tag.SEQUENCE); checkImeiImpl = new CheckImeiRequestImpl(3); checkImeiImpl.decodeAll(asnIS); assertTrue(checkImeiImpl.getIMEI().getIMEI().equals("358091016853550")); assertTrue(checkImeiImpl.getRequestedEquipmentInfo().getEquipmentStatus()); assertFalse(checkImeiImpl.getRequestedEquipmentInfo().getBmuef()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(checkImeiImpl.getExtensionContainer())); assertNull(checkImeiImpl.getIMSI()); // Testing version 1 and 2 rawData = getEncodedDataV2(); asnIS = new AsnInputStream(rawData); tag = asnIS.readTag(); assertEquals(tag, Tag.STRING_OCTET); checkImeiImpl = new CheckImeiRequestImpl(2); checkImeiImpl.decodeAll(asnIS); assertTrue(checkImeiImpl.getIMEI().getIMEI().equals("358091016853550")); assertNull(checkImeiImpl.getIMSI()); // Testing version 1 and 2 with Huawei trace rawData = getEncodedDataV2_Huawei(); asnIS = new AsnInputStream(rawData); tag = asnIS.readTag(); assertEquals(tag, Tag.STRING_OCTET); checkImeiImpl = new CheckImeiRequestImpl(2); checkImeiImpl.decodeAll(asnIS); assertTrue(checkImeiImpl.getIMEI().getIMEI().equals("356467044989910")); assertTrue(checkImeiImpl.getIMSI().getData().equals("724340300385763")); // Testing IMEI length != 15 rawData = getEncodedDataImeiLengthLessThan15(); asnIS = new AsnInputStream(rawData); tag = asnIS.readTag(); assertEquals(tag, Tag.STRING_OCTET); checkImeiImpl = new CheckImeiRequestImpl(2); checkImeiImpl.decodeAll(asnIS); assertTrue(checkImeiImpl.getIMEI().getIMEI().equals("1")); assertNull(checkImeiImpl.getIMSI()); } @Test(groups = { "functional.encode", "imei" }) public void testEncode() throws Exception { // Testing version 3 IMEIImpl imei = new IMEIImpl("358091016853550"); RequestedEquipmentInfoImpl requestedEquipmentInfo = new RequestedEquipmentInfoImpl(true, false); CheckImeiRequestImpl checkImei = new CheckImeiRequestImpl(3, imei, requestedEquipmentInfo, null); AsnOutputStream asnOS = new AsnOutputStream(); checkImei.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedDataV3(); assertTrue(Arrays.equals(rawData, encodedData)); // Testing version 3 Full imei = new IMEIImpl("358091016853550"); requestedEquipmentInfo = new RequestedEquipmentInfoImpl(true, false); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); checkImei = new CheckImeiRequestImpl(3, imei, requestedEquipmentInfo, extensionContainer); asnOS = new AsnOutputStream(); checkImei.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataV3Full(); assertTrue(Arrays.equals(rawData, encodedData)); // Testing version 1 and 2 imei = new IMEIImpl("358091016853550"); checkImei = new CheckImeiRequestImpl(2, imei, null, null); asnOS = new AsnOutputStream(); checkImei.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataV2(); assertTrue(Arrays.equals(rawData, encodedData)); // Testing version 1 and 2 with Huawei trace imei = new IMEIImpl("356467044989910"); IMSIImpl imsi = new IMSIImpl("724340300385763"); checkImei = new CheckImeiRequestImpl(2, imei, null, null); checkImei.setIMSI(imsi); asnOS = new AsnOutputStream(); checkImei.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataV2_Huawei(); assertTrue(Arrays.equals(rawData, encodedData)); // Testing IMEI length != 15 imei = new IMEIImpl("1"); checkImei = new CheckImeiRequestImpl(2, imei, null, null); asnOS = new AsnOutputStream(); checkImei.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataImeiLengthLessThan15(); assertTrue(Arrays.equals(rawData, encodedData)); } }```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.imei; import org.restcomm.protocols.ss7.map.api.primitives.IMEI; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * MAP V1-2-3: * * MAP V3: checkIMEI OPERATION ::= { --Timer m ARGUMENT CheckIMEI-Arg RESULT CheckIMEI-Res ERRORS { systemFailure | dataMissing * | unknownEquipment} CODE local:43 } * * MAP V2: CheckIMEI ::= OPERATION --Timer m ARGUMENT imei IMEI RESULT equipmentStatus EquipmentStatus ERRORS { SystemFailure, * DataMissing, UnknownEquipment } * * MAP V3: CheckIMEIArg ::= SEQUENCE { imei IMEI, requestedEquipmentInfo RequestedEquipmentInfo, extensionContainer * ExtensionContainer OPTIONAL, ...} * * MAP V2: ARGUMENT imei IMEI * * * @author normandes * */ public interface CheckImeiRequest extends MobilityMessage { IMEI getIMEI(); RequestedEquipmentInfo getRequestedEquipmentInfo(); MAPExtensionContainer getExtensionContainer(); IMSI getIMSI(); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.sms.IpSmGwGuidanceImpl; import org.testng.annotations.Test; import java.util.Arrays; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; /** * * @author eva ogallar * @author sergey vetyutnev * */ public class IpSmGwGuidanceTest { private byte[] getEncodedData() { return new byte[] {32,6,2,1,30,2,1,40}; } private byte[] getEncodedDataFull() { return new byte[] {32,47,2,1,30,2,1,40,48,39,-96,32,48,10,6,3,42,3,4,11,12,13,14,15, 48,5,6,3,42,3,6,48,11,6,3,42,3,5,21,22,23,24,25,26,-95,3,31,32,33}; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); IpSmGwGuidanceImpl ipSmGwGuidance = new IpSmGwGuidanceImpl(); ipSmGwGuidance.decodeAll(asn); assertEquals(tag, 0); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(ipSmGwGuidance.getMinimumDeliveryTimeValue(), 30); assertEquals(ipSmGwGuidance.getRecommendedDeliveryTimeValue(), 40); rawData = getEncodedDataFull(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ipSmGwGuidance = new IpSmGwGuidanceImpl(); ipSmGwGuidance.decodeAll(asn); assertEquals(tag, 0); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(ipSmGwGuidance.getMinimumDeliveryTimeValue(), 30); assertEquals(ipSmGwGuidance.getRecommendedDeliveryTimeValue(), 40); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ipSmGwGuidance.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { IpSmGwGuidanceImpl liw = new IpSmGwGuidanceImpl(30, 40, null); AsnOutputStream asnOS = new AsnOutputStream(); liw.encodeAll(asnOS, Tag.CLASS_UNIVERSAL, 0); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); liw = new IpSmGwGuidanceImpl(30, 40, MAPExtensionContainerTest.GetTestExtensionContainer()); asnOS.reset(); liw.encodeAll(asnOS, Tag.CLASS_UNIVERSAL, 0); encodedData = asnOS.toByteArray(); rawData = getEncodedDataFull(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import java.io.Serializable; /** <code> IP-SM-GW-Guidance ::= SEQUENCE { minimumDeliveryTimeValue SM-DeliveryTimerValue, recommendedDeliveryTimeValue SM-DeliveryTimerValue, extensionContainer ExtensionContainer OPTIONAL, ... } SM-DeliveryTimerValue ::= INTEGER (30..600) </code> * * @author eva ogallar */ public interface IpSmGwGuidance extends Serializable { int getMinimumDeliveryTimeValue(); int getRecommendedDeliveryTimeValue(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.authentication.AuthenticationQuintupletImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AuthenticationQuintupletTest { private byte[] getEncodedData() { return new byte[] { 48, 78, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 2, 2, 2, 2, 4, 16, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 16, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 16, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; } static protected byte[] getRandData() { return new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; } static protected byte[] getXresData() { return new byte[] { 2, 2, 2, 2 }; } static protected byte[] getCkData() { return new byte[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 }; } static protected byte[] getIkData() { return new byte[] { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; } static protected byte[] getAutnData() { return new byte[] { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; } @Test public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); AuthenticationQuintupletImpl asc = new AuthenticationQuintupletImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(asc.getRand(), getRandData())); assertTrue(Arrays.equals(asc.getXres(), getXresData())); assertTrue(Arrays.equals(asc.getCk(), getCkData())); assertTrue(Arrays.equals(asc.getIk(), getIkData())); assertTrue(Arrays.equals(asc.getAutn(), getAutnData())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { AuthenticationQuintupletImpl asc = new AuthenticationQuintupletImpl(getRandData(), getXresData(), getCkData(), getIkData(), getAutnData()); AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import java.io.Serializable; /** * AuthenticationQuintuplet ::= SEQUENCE { rand RAND, xres XRES, ck CK, ik IK, autn AUTN, ...} * * * RAND ::= OCTET STRING (SIZE (16)) XRES ::= OCTET STRING (SIZE (4..16)) CK ::= OCTET STRING (SIZE (16)) IK ::= OCTET STRING * (SIZE (16)) AUTN ::= OCTET STRING (SIZE (16)) * * @author sergey vetyutnev * */ public interface AuthenticationQuintuplet extends Serializable { byte[] getRand(); byte[] getXres(); byte[] getCk(); byte[] getIk(); byte[] getAutn(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CallTypeCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CauseValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DPAnalysedInfoCriterium; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultCallHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultSMSHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DestinationNumberCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtBasicServiceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtTeleserviceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MMCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MMCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MTSMSTPDUType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MTsmsCAMELTDPCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MatchType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.OBcsmCamelTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.OBcsmCamelTdpCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.OBcsmTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.OCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSCAMELTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SSCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SSCamelData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmCamelTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmCamelTdpCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCodeValue; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CauseValueImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.DCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.DPAnalysedInfoCriteriumImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.DestinationNumberCriteriaImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBasicServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtTeleserviceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MMCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MTsmsCAMELTDPCriteriaImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.OBcsmCamelTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.OBcsmCamelTdpCriteriaImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.OCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCAMELTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SSCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SSCamelDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TBcsmCamelTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TBcsmCamelTdpCriteriaImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.VlrCamelSubscriptionInfoImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class VlrCamelSubscriptionInfoTest { public byte[] getData() { return new byte[] { 48, -126, 2, -56, -96, 23, 48, 18, 48, 16, 10, 1, 4, 2, 1, 3, -128, 5, -111, 17, 34, 51, -13, -127, 1, 1, -128, 1, 2, -95, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -94, 97, 48, 52, 48, 3, 4, 1, 96, 4, 4, -111, 34, 50, -11, -96, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 0, -92, 92, 48, 90, 10, 1, 2, -96, 28, -128, 1, 1, -95, 12, 4, 4, -111, 34, 50, -12, 4, 4, -111, 34, 50, -11, -94, 9, 2, 1, 2, 2, 1, 4, 2, 1, 1, -95, 6, -126, 1, 38, -125, 1, 0, -126, 1, 0, -93, 3, 4, 1, 7, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -91, 60, 48, 6, 4, 1, -125, 4, 1, 2, 2, 1, 3, -128, 4, -111, 34, 50, -11, -95, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -125, 0, -90, 106, -96, 58, 48, 56, -128, 1, 1, -127, 1, 3, -126, 4, -111, 34, 50, -11, -125, 1, 0, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 8, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -124, 0, -89, 22, 48, 17, 48, 15, 10, 1, 12, 2, 1, 3, -128, 4, -111, 34, 50, -11, -127, 1, 1, -128, 1, 2, -88, 21, 48, 19, 10, 1, 13, -96, 6, -126, 1, 38, -125, 1, 0, -95, 6, 4, 1, 7, 4, 1, 6, -87, 111, -96, 61, 48, 59, 4, 4, -111, 34, 50, -12, 2, 1, 7, 4, 4, -111, 34, 50, -11, 2, 1, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 2, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -125, 0, -124, 0, -86, 106, -96, 58, 48, 56, -128, 1, 1, -127, 1, 3, -126, 4, -111, 34, 50, -11, -125, 1, 0, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 8, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -124, 0, -85, 13, 48, 11, 10, 1, 1, -96, 6, 10, 1, 0, 10, 1, 2 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); VlrCamelSubscriptionInfoImpl prim = new VlrCamelSubscriptionInfoImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); // oCsi OCSI oCsi = prim.getOCsi(); ArrayList<OBcsmCamelTDPData> lst = oCsi.getOBcsmCamelTDPDataList(); assertEquals(lst.size(), 1); OBcsmCamelTDPData cd = lst.get(0); assertEquals(cd.getOBcsmTriggerDetectionPoint(), OBcsmTriggerDetectionPoint.routeSelectFailure); assertEquals(cd.getServiceKey(), 3); assertEquals(cd.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(cd.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(cd.getGsmSCFAddress().getAddress().equals("1122333")); assertEquals(cd.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertNull(cd.getExtensionContainer()); assertNull(oCsi.getExtensionContainer()); assertEquals((int) oCsi.getCamelCapabilityHandling(), 2); assertFalse(oCsi.getNotificationToCSE()); assertFalse(oCsi.getCsiActive()); // extensionContainer MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); // ssCsi SSCSI ssCsi = prim.getSsCsi(); SSCamelData ssCamelData = ssCsi.getSsCamelData(); ArrayList<SSCode> ssEventList = ssCamelData.getSsEventList(); assertNotNull(ssEventList); assertEquals(ssEventList.size(), 1); SSCode one = ssEventList.get(0); assertNotNull(one); assertEquals(one.getSupplementaryCodeValue(), SupplementaryCodeValue.allCommunityOfInterestSS); ISDNAddressString gsmSCFAddress = ssCamelData.getGsmSCFAddress(); assertTrue(gsmSCFAddress.getAddress().equals("22235")); assertEquals(gsmSCFAddress.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddress.getNumberingPlan(), NumberingPlan.ISDN); assertNotNull(ssCamelData.getExtensionContainer()); assertNotNull(ssCsi.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ssCsi.getExtensionContainer())); assertTrue(ssCsi.getCsiActive()); assertTrue(!ssCsi.getNotificationToCSE()); // oBcsmCamelTDPCriteriaList ArrayList<OBcsmCamelTdpCriteria> oBcsmCamelTDPCriteriaList = prim.getOBcsmCamelTDPCriteriaList(); assertNotNull(oBcsmCamelTDPCriteriaList); assertEquals(oBcsmCamelTDPCriteriaList.size(), 1); OBcsmCamelTdpCriteria oBcsmCamelTdpCriteria = oBcsmCamelTDPCriteriaList.get(0); assertNotNull(oBcsmCamelTdpCriteria); DestinationNumberCriteria destinationNumberCriteria = oBcsmCamelTdpCriteria.getDestinationNumberCriteria(); ArrayList<ISDNAddressString> destinationNumberList = destinationNumberCriteria.getDestinationNumberList(); assertNotNull(destinationNumberList); assertEquals(destinationNumberList.size(), 2); ISDNAddressString destinationNumberOne = destinationNumberList.get(0); assertNotNull(destinationNumberOne); assertTrue(destinationNumberOne.getAddress().equals("22234")); assertEquals(destinationNumberOne.getAddressNature(), AddressNature.international_number); assertEquals(destinationNumberOne.getNumberingPlan(), NumberingPlan.ISDN); ISDNAddressString destinationNumberTwo = destinationNumberList.get(1); assertNotNull(destinationNumberTwo); assertTrue(destinationNumberTwo.getAddress().equals("22235")); assertEquals(destinationNumberTwo.getAddressNature(), AddressNature.international_number); assertEquals(destinationNumberTwo.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(destinationNumberCriteria.getMatchType().getCode(), MatchType.enabling.getCode()); ArrayList<Integer> destinationNumberLengthList = destinationNumberCriteria.getDestinationNumberLengthList(); assertNotNull(destinationNumberLengthList); assertEquals(destinationNumberLengthList.size(), 3); assertEquals(destinationNumberLengthList.get(0).intValue(), 2); assertEquals(destinationNumberLengthList.get(1).intValue(), 4); assertEquals(destinationNumberLengthList.get(2).intValue(), 1); assertEquals(oBcsmCamelTdpCriteria.getOBcsmTriggerDetectionPoint(), OBcsmTriggerDetectionPoint.collectedInfo); assertNotNull(oBcsmCamelTdpCriteria.getBasicServiceCriteria()); assertEquals(oBcsmCamelTdpCriteria.getBasicServiceCriteria().size(), 2); ExtBasicServiceCode basicServiceOne = oBcsmCamelTdpCriteria.getBasicServiceCriteria().get(0); assertNotNull(basicServiceOne); assertEquals(basicServiceOne.getExtBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); ExtBasicServiceCode basicServiceTwo = oBcsmCamelTdpCriteria.getBasicServiceCriteria().get(1); assertNotNull(basicServiceTwo); assertEquals(basicServiceTwo.getExtTeleservice().getTeleserviceCodeValue(), TeleserviceCodeValue.allTeleservices); assertEquals(oBcsmCamelTdpCriteria.getCallTypeCriteria(), CallTypeCriteria.forwarded); ArrayList<CauseValue> oCauseValueCriteria = oBcsmCamelTdpCriteria.getOCauseValueCriteria(); assertNotNull(oCauseValueCriteria); assertEquals(oCauseValueCriteria.size(), 1); assertNotNull(oCauseValueCriteria.get(0)); assertEquals(oCauseValueCriteria.get(0).getData(), 7); // TifCsi assertFalse(prim.getTifCsi()); // mCsi MCSI mCsi = prim.getMCsi(); ArrayList<MMCode> mobilityTriggers = mCsi.getMobilityTriggers(); assertNotNull(mobilityTriggers); assertEquals(mobilityTriggers.size(), 2); MMCode mmCode = mobilityTriggers.get(0); assertNotNull(mmCode); assertEquals(MMCodeValue.GPRSAttach, mmCode.getMMCodeValue()); MMCode mmCode2 = mobilityTriggers.get(1); assertNotNull(mmCode2); assertEquals(MMCodeValue.IMSIAttach, mmCode2.getMMCodeValue()); assertNotNull(mCsi.getServiceKey()); assertEquals(mCsi.getServiceKey(), 3); ISDNAddressString gsmSCFAddressTwo = mCsi.getGsmSCFAddress(); assertTrue(gsmSCFAddressTwo.getAddress().equals("22235")); assertEquals(gsmSCFAddressTwo.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressTwo.getNumberingPlan(), NumberingPlan.ISDN); assertNotNull(mCsi.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(mCsi.getExtensionContainer())); assertTrue(mCsi.getCsiActive()); assertTrue(!mCsi.getNotificationToCSE()); // smsCsi SMSCSI smsCsi = prim.getSmsCsi(); ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = smsCsi.getSmsCamelTdpDataList(); assertNotNull(smsCamelTdpDataList); assertEquals(smsCamelTdpDataList.size(), 1); SMSCAMELTDPData smsCAMELTDPData = smsCamelTdpDataList.get(0); assertNotNull(smsCAMELTDPData); assertEquals(smsCAMELTDPData.getServiceKey(), 3); assertEquals(smsCAMELTDPData.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); ISDNAddressString gsmSCFAddressSmsCAMELTDPData = smsCAMELTDPData.getGsmSCFAddress(); assertTrue(gsmSCFAddressSmsCAMELTDPData.getAddress().equals("22235")); assertEquals(gsmSCFAddressSmsCAMELTDPData.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressSmsCAMELTDPData.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(smsCAMELTDPData.getDefaultSMSHandling(), DefaultSMSHandling.continueTransaction); assertNotNull(smsCAMELTDPData.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(smsCAMELTDPData.getExtensionContainer())); assertTrue(smsCsi.getCsiActive()); assertTrue(!smsCsi.getNotificationToCSE()); assertEquals(smsCsi.getCamelCapabilityHandling().intValue(), 8); // vtCsi TCSI vtCsi = prim.getVtCsi(); ArrayList<TBcsmCamelTDPData> tbcsmCamelTDPDatalst = vtCsi.getTBcsmCamelTDPDataList(); assertEquals(lst.size(), 1); TBcsmCamelTDPData tbcsmCamelTDPData = tbcsmCamelTDPDatalst.get(0); assertEquals(tbcsmCamelTDPData.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.termAttemptAuthorized); assertEquals(tbcsmCamelTDPData.getServiceKey(), 3); assertEquals(tbcsmCamelTDPData.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(tbcsmCamelTDPData.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(tbcsmCamelTDPData.getGsmSCFAddress().getAddress().equals("22235")); assertEquals(tbcsmCamelTDPData.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertNull(tbcsmCamelTDPData.getExtensionContainer()); assertNull(vtCsi.getExtensionContainer()); assertEquals((int) vtCsi.getCamelCapabilityHandling(), 2); assertFalse(vtCsi.getNotificationToCSE()); assertFalse(vtCsi.getCsiActive()); // tBcsmCamelTdpCriteriaList ArrayList<TBcsmCamelTdpCriteria> tBcsmCamelTdpCriteriaList = prim.getTBcsmCamelTdpCriteriaList(); assertNotNull(tBcsmCamelTdpCriteriaList); assertEquals(tBcsmCamelTdpCriteriaList.size(), 1); assertNotNull(tBcsmCamelTdpCriteriaList.get(0)); TBcsmCamelTdpCriteria tbcsmCamelTdpCriteria = tBcsmCamelTdpCriteriaList.get(0); assertEquals(tbcsmCamelTdpCriteria.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.tBusy); assertNotNull(tbcsmCamelTdpCriteria.getBasicServiceCriteria()); assertEquals(tbcsmCamelTdpCriteria.getBasicServiceCriteria().size(), 2); assertNotNull(tbcsmCamelTdpCriteria.getBasicServiceCriteria().get(0)); assertNotNull(tbcsmCamelTdpCriteria.getBasicServiceCriteria().get(1)); ArrayList<CauseValue> oCauseValueCriteriaLst = tbcsmCamelTdpCriteria.getTCauseValueCriteria(); assertNotNull(oCauseValueCriteriaLst); assertEquals(oCauseValueCriteriaLst.size(), 2); assertNotNull(oCauseValueCriteriaLst.get(0)); assertEquals(oCauseValueCriteriaLst.get(0).getData(), 7); assertNotNull(oCauseValueCriteriaLst.get(1)); assertEquals(oCauseValueCriteriaLst.get(1).getData(), 6); // dCsi DCSI dCsi = prim.getDCsi(); ArrayList<DPAnalysedInfoCriterium> dpAnalysedInfoCriteriaList = dCsi.getDPAnalysedInfoCriteriaList(); assertNotNull(dpAnalysedInfoCriteriaList); assertEquals(dpAnalysedInfoCriteriaList.size(), 1); DPAnalysedInfoCriterium dpAnalysedInfoCriterium = dpAnalysedInfoCriteriaList.get(0); assertNotNull(dpAnalysedInfoCriterium); ISDNAddressString dialledNumber = dpAnalysedInfoCriterium.getDialledNumber(); assertTrue(dialledNumber.getAddress().equals("22234")); assertEquals(dialledNumber.getAddressNature(), AddressNature.international_number); assertEquals(dialledNumber.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(dpAnalysedInfoCriterium.getServiceKey(), 7); ISDNAddressString gsmSCFAddressDp = dpAnalysedInfoCriterium.getGsmSCFAddress(); assertTrue(gsmSCFAddressDp.getAddress().equals("22235")); assertEquals(gsmSCFAddressDp.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressDp.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(dpAnalysedInfoCriterium.getDefaultCallHandling(), DefaultCallHandling.continueCall); assertNotNull(dCsi.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(dCsi.getExtensionContainer())); assertEquals(dCsi.getCamelCapabilityHandling().intValue(), 2); assertTrue(dCsi.getCsiActive()); assertTrue(dCsi.getNotificationToCSE()); // mtSmsCSI SMSCSI mtSmsCSI = prim.getMtSmsCSI(); ArrayList<SMSCAMELTDPData> smsCamelTdpDataListOfmtSmsCSI = mtSmsCSI.getSmsCamelTdpDataList(); assertNotNull(smsCamelTdpDataListOfmtSmsCSI); assertEquals(smsCamelTdpDataListOfmtSmsCSI.size(), 1); SMSCAMELTDPData smsCAMELTDPDataOfMtSmsCSI = smsCamelTdpDataListOfmtSmsCSI.get(0); assertNotNull(smsCAMELTDPDataOfMtSmsCSI); assertEquals(smsCAMELTDPDataOfMtSmsCSI.getServiceKey(), 3); assertEquals(smsCAMELTDPDataOfMtSmsCSI.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); ISDNAddressString gsmSCFAddressOfMtSmsCSI = smsCAMELTDPDataOfMtSmsCSI.getGsmSCFAddress(); assertTrue(gsmSCFAddressOfMtSmsCSI.getAddress().equals("22235")); assertEquals(gsmSCFAddressOfMtSmsCSI.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressOfMtSmsCSI.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(smsCAMELTDPDataOfMtSmsCSI.getDefaultSMSHandling(), DefaultSMSHandling.continueTransaction); assertNotNull(smsCAMELTDPDataOfMtSmsCSI.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(smsCAMELTDPDataOfMtSmsCSI.getExtensionContainer())); assertNotNull(mtSmsCSI.getExtensionContainer()); assertTrue(mtSmsCSI.getCsiActive()); assertTrue(!mtSmsCSI.getNotificationToCSE()); assertEquals(mtSmsCSI.getCamelCapabilityHandling().intValue(), 8); // mtSmsCamelTdpCriteriaList ArrayList<MTsmsCAMELTDPCriteria> mtSmsCamelTdpCriteriaList = prim.getMtSmsCamelTdpCriteriaList(); assertNotNull(mtSmsCamelTdpCriteriaList); assertEquals(mtSmsCamelTdpCriteriaList.size(), 1); MTsmsCAMELTDPCriteria mtsmsCAMELTDPCriteria = mtSmsCamelTdpCriteriaList.get(0); ArrayList<MTSMSTPDUType> tPDUTypeCriterion = mtsmsCAMELTDPCriteria.getTPDUTypeCriterion(); assertNotNull(tPDUTypeCriterion); assertEquals(tPDUTypeCriterion.size(), 2); MTSMSTPDUType mtSMSTPDUTypeOne = tPDUTypeCriterion.get(0); assertNotNull(mtSMSTPDUTypeOne); assertEquals(mtSMSTPDUTypeOne, MTSMSTPDUType.smsDELIVER); MTSMSTPDUType mtSMSTPDUTypeTwo = tPDUTypeCriterion.get(1); assertNotNull(mtSMSTPDUTypeTwo); assertTrue(mtSMSTPDUTypeTwo == MTSMSTPDUType.smsSTATUSREPORT); assertEquals(mtsmsCAMELTDPCriteria.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { TBcsmTriggerDetectionPoint tBcsmTriggerDetectionPoint = TBcsmTriggerDetectionPoint.tBusy; ArrayList<ExtBasicServiceCode> basicServiceCriteria = new ArrayList<ExtBasicServiceCode>(); ExtBearerServiceCodeImpl b = new ExtBearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); ExtTeleserviceCode extTeleservice = new ExtTeleserviceCodeImpl(TeleserviceCodeValue.allTeleservices); ExtBasicServiceCodeImpl basicServiceOne = new ExtBasicServiceCodeImpl(b); ExtBasicServiceCodeImpl basicServiceTwo = new ExtBasicServiceCodeImpl(extTeleservice); basicServiceCriteria.add(basicServiceOne); basicServiceCriteria.add(basicServiceTwo); ArrayList<CauseValue> tCauseValueCriteria = new ArrayList<CauseValue>(); tCauseValueCriteria.add(new CauseValueImpl(7)); tCauseValueCriteria.add(new CauseValueImpl(6)); ISDNAddressStringImpl gsmSCFAddressOne = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1122333"); OBcsmCamelTDPDataImpl cind = new OBcsmCamelTDPDataImpl(OBcsmTriggerDetectionPoint.routeSelectFailure, 3, gsmSCFAddressOne, DefaultCallHandling.releaseCall, null); ArrayList<OBcsmCamelTDPData> lst = new ArrayList<OBcsmCamelTDPData>(); lst.add(cind); OCSI oCsi = new OCSIImpl(lst, null, 2, false, false); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); ArrayList<SSCode> ssEventList = new ArrayList<SSCode>(); ssEventList.add(new SSCodeImpl(SupplementaryCodeValue.allCommunityOfInterestSS.getCode())); ISDNAddressString gsmSCFAddressTwo = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); SSCamelData ssCamelData = new SSCamelDataImpl(ssEventList, gsmSCFAddressTwo, extensionContainer); boolean notificationToCSE = false; boolean csiActive = true; SSCSI ssCsi = new SSCSIImpl(ssCamelData, extensionContainer, notificationToCSE, csiActive); ArrayList<OBcsmCamelTdpCriteria> oBcsmCamelTDPCriteriaList = new ArrayList<OBcsmCamelTdpCriteria>(); OBcsmTriggerDetectionPoint oBcsmTriggerDetectionPoint = OBcsmTriggerDetectionPoint.collectedInfo; ISDNAddressStringImpl destinationNumberOne = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22234"); ISDNAddressStringImpl destinationNumberTwo = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); ArrayList<ISDNAddressString> destinationNumberList = new ArrayList<ISDNAddressString>(); destinationNumberList.add(destinationNumberOne); destinationNumberList.add(destinationNumberTwo); ArrayList<Integer> destinationNumberLengthList = new ArrayList<Integer>(); destinationNumberLengthList.add(new Integer(2)); destinationNumberLengthList.add(new Integer(4)); destinationNumberLengthList.add(new Integer(1)); DestinationNumberCriteria destinationNumberCriteria = new DestinationNumberCriteriaImpl(MatchType.enabling, destinationNumberList, destinationNumberLengthList); CallTypeCriteria callTypeCriteria = CallTypeCriteria.forwarded; ArrayList<CauseValue> oCauseValueCriteria = new ArrayList<CauseValue>(); oCauseValueCriteria.add(new CauseValueImpl(7)); OBcsmCamelTdpCriteriaImpl oBcsmCamelTdpCriteria = new OBcsmCamelTdpCriteriaImpl(oBcsmTriggerDetectionPoint, destinationNumberCriteria, basicServiceCriteria, callTypeCriteria, oCauseValueCriteria, extensionContainer); oBcsmCamelTDPCriteriaList.add(oBcsmCamelTdpCriteria); boolean tifCsi = false; ArrayList<MMCode> mobilityTriggers = new ArrayList<MMCode>(); Long serviceKey = new Long(3); ISDNAddressString gsmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); ; mobilityTriggers.add(new MMCodeImpl(MMCodeValue.GPRSAttach)); mobilityTriggers.add(new MMCodeImpl(MMCodeValue.IMSIAttach)); MCSI mCsi = new MCSIImpl(mobilityTriggers, serviceKey, gsmSCFAddress, extensionContainer, notificationToCSE, csiActive); SMSTriggerDetectionPoint smsTriggerDetectionPoint = SMSTriggerDetectionPoint.smsCollectedInfo; DefaultSMSHandling defaultSMSHandling = DefaultSMSHandling.continueTransaction; ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = new ArrayList<SMSCAMELTDPData>(); SMSCAMELTDPDataImpl smsCAMELTDPData = new SMSCAMELTDPDataImpl(smsTriggerDetectionPoint, serviceKey, gsmSCFAddress, defaultSMSHandling, extensionContainer); smsCamelTdpDataList.add(smsCAMELTDPData); Integer camelCapabilityHandling = new Integer(8); SMSCSI smsCsi = new SMSCSIImpl(smsCamelTdpDataList, camelCapabilityHandling, extensionContainer, notificationToCSE, csiActive); TBcsmCamelTDPDataImpl tBcsmCamelTDPData = new TBcsmCamelTDPDataImpl(TBcsmTriggerDetectionPoint.termAttemptAuthorized, 3, gsmSCFAddress, DefaultCallHandling.releaseCall, null); ArrayList<TBcsmCamelTDPData> tBcsmCamelTDPDatalst = new ArrayList<TBcsmCamelTDPData>(); tBcsmCamelTDPDatalst.add(tBcsmCamelTDPData); TCSI vtCsi = new TCSIImpl(tBcsmCamelTDPDatalst, null, 2, false, false); TBcsmCamelTdpCriteriaImpl tBcsmCamelTdpCriteria = new TBcsmCamelTdpCriteriaImpl(tBcsmTriggerDetectionPoint, basicServiceCriteria, tCauseValueCriteria); ArrayList<TBcsmCamelTdpCriteria> tBcsmCamelTdpCriteriaList = new ArrayList<TBcsmCamelTdpCriteria>(); tBcsmCamelTdpCriteriaList.add(tBcsmCamelTdpCriteria); ISDNAddressStringImpl dialledNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22234"); DPAnalysedInfoCriteriumImpl dpAnalysedInfoCriterium = new DPAnalysedInfoCriteriumImpl(dialledNumber, 7, gsmSCFAddress, DefaultCallHandling.continueCall, extensionContainer); ArrayList<DPAnalysedInfoCriterium> dpAnalysedInfoCriteriaList = new ArrayList<DPAnalysedInfoCriterium>(); dpAnalysedInfoCriteriaList.add(dpAnalysedInfoCriterium); DCSI dCsi = new DCSIImpl(dpAnalysedInfoCriteriaList, 2, extensionContainer, true, true); SMSCSI mtSmsCSI = new SMSCSIImpl(smsCamelTdpDataList, camelCapabilityHandling, extensionContainer, notificationToCSE, csiActive); ArrayList<MTsmsCAMELTDPCriteria> mtSmsCamelTdpCriteriaList = new ArrayList<MTsmsCAMELTDPCriteria>(); ArrayList<MTSMSTPDUType> tPDUTypeCriterion = new ArrayList<MTSMSTPDUType>(); tPDUTypeCriterion.add(MTSMSTPDUType.smsDELIVER); tPDUTypeCriterion.add(MTSMSTPDUType.smsSTATUSREPORT); MTsmsCAMELTDPCriteriaImpl mTsmsCAMELTDPCriteria = new MTsmsCAMELTDPCriteriaImpl(smsTriggerDetectionPoint, tPDUTypeCriterion); mtSmsCamelTdpCriteriaList.add(mTsmsCAMELTDPCriteria); VlrCamelSubscriptionInfoImpl prim = new VlrCamelSubscriptionInfoImpl(oCsi, extensionContainer, ssCsi, oBcsmCamelTDPCriteriaList, tifCsi, mCsi, smsCsi, vtCsi, tBcsmCamelTdpCriteriaList, dCsi, mtSmsCSI, mtSmsCamelTdpCriteriaList); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * VlrCamelSubscriptionInfo ::= SEQUENCE { o-CSI [0] O-CSI OPTIONAL, extensionContainer [1] ExtensionContainer OPTIONAL, ..., * ss-CSI [2] SS-CSI OPTIONAL, o-BcsmCamelTDP-CriteriaList [4] O-BcsmCamelTDPCriteriaList OPTIONAL, tif-CSI [3] NULL OPTIONAL, * m-CSI [5] M-CSI OPTIONAL, mo-sms-CSI [6] SMS-CSI OPTIONAL, vt-CSI [7] T-CSI OPTIONAL, t-BCSM-CAMEL-TDP-CriteriaList [8] * T-BCSM-CAMEL-TDP-CriteriaList OPTIONAL, d-CSI [9] D-CSI OPTIONAL, mt-sms-CSI [10] SMS-CSI OPTIONAL, * mt-smsCAMELTDP-CriteriaList [11] MT-smsCAMELTDP-CriteriaList OPTIONAL } * * O-BcsmCamelTDPCriteriaList ::= SEQUENCE SIZE (1..10) OF O-BcsmCamelTDP-Criteria * * T-BCSM-CAMEL-TDP-CriteriaList ::= SEQUENCE SIZE (1..10) OF T-BCSM-CAMEL-TDP-Criteria * * MT-smsCAMELTDP-CriteriaList ::= SEQUENCE SIZE (1.. 10) OF MT-smsCAMELTDP-Criteria * * * * @author sergey vetyutnev * */ public interface VlrCamelSubscriptionInfo extends Serializable { OCSI getOCsi(); MAPExtensionContainer getExtensionContainer(); SSCSI getSsCsi(); ArrayList<OBcsmCamelTdpCriteria> getOBcsmCamelTDPCriteriaList(); boolean getTifCsi(); MCSI getMCsi(); SMSCSI getSmsCsi(); TCSI getVtCsi(); ArrayList<TBcsmCamelTdpCriteria> getTBcsmCamelTdpCriteriaList(); DCSI getDCsi(); SMSCSI getMtSmsCSI(); ArrayList<MTsmsCAMELTDPCriteria> getMtSmsCamelTdpCriteriaList(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwOptionsForwardingReason; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtForwOptionsImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ExtForwOptionsTest { public byte[] getData() { return new byte[] { 4, 1, -92 }; }; public byte[] getData2() { return new byte[] { (byte) 134, 1, 0 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ExtForwOptionsImpl prim = new ExtForwOptionsImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(prim.getNotificationToCallingParty()); assertTrue(prim.getNotificationToForwardingParty()); assertTrue(!prim.getRedirectingPresentation()); assertEquals(prim.getExtForwOptionsForwardingReason(), ExtForwOptionsForwardingReason.msBusy); data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtForwOptionsImpl(); prim.decodeAll(asn); assertEquals(tag, 6); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertFalse(prim.getNotificationToCallingParty()); assertFalse(prim.getNotificationToForwardingParty()); assertFalse(prim.getRedirectingPresentation()); assertEquals(prim.getExtForwOptionsForwardingReason(), ExtForwOptionsForwardingReason.msNotReachable); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { ExtForwOptionsImpl prim = new ExtForwOptionsImpl(true, false, true, ExtForwOptionsForwardingReason.msBusy); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); prim = new ExtForwOptionsImpl(false, false, false, ExtForwOptionsForwardingReason.msNotReachable); asn = new AsnOutputStream(); prim.encodeAll(asn, Tag.CLASS_CONTEXT_SPECIFIC, 6); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * Ext-ForwOptions ::= OCTET STRING (SIZE (1..5)) * * -- OCTET 1: * * -- bit 8: notification to forwarding party -- 0 no notification -- 1 notification * * -- bit 7: redirecting presentation -- 0 no presentation -- 1 presentation * * -- bit 6: notification to calling party -- 0 no notification -- 1 notification * * -- bit 5: 0 (unused) * * -- bits 43: forwarding reason -- 00 ms not reachable -- 01 ms busy -- 10 no reply -- 11 unconditional * * -- bits 21: 00 (unused) * * -- OCTETS 2-5: reserved for future use. They shall be discarded if -- received and not understood. * * * * @author sergey vetyutnev * */ public interface ExtForwOptions extends Serializable { byte[] getData(); boolean getNotificationToForwardingParty(); boolean getRedirectingPresentation(); boolean getNotificationToCallingParty(); ExtForwOptionsForwardingReason getExtForwOptionsForwardingReason(); } ```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.oam.PGWEventListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class PGWEventListTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 5, 96 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); PGWEventListImpl asc = new PGWEventListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertFalse(asc.getPdnConnectionCreation()); assertTrue(asc.getPdnConnectionTermination()); assertTrue(asc.getBearerActivationModificationDeletion()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { PGWEventListImpl asc = new PGWEventListImpl(false, true, true); // boolean pdnConnectionCreation, boolean pdnConnectionTermination, boolean bearerActivationModificationDeletion AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> PGW-EventList ::= BIT STRING { pdn-connectionCreation (0), pdn-connectionTermination (1), bearerActivationModificationDeletion (2) } (SIZE (3..8)) -- Other bits than listed above shall be discarded. </code> * * * @author sergey vetyutnev * */ public interface PGWEventList extends Serializable { boolean getPdnConnectionCreation(); boolean getPdnConnectionTermination(); boolean getBearerActivationModificationDeletion(); } ```
```package org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.AOCBeforeAnswerImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.AOCSubsequentImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAI_GSM0224Impl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AOCBeforeAnswerTest { public byte[] getData1() { return new byte[] { 48, 21, (byte) 160, 6, (byte) 131, 1, 4, (byte) 132, 1, 5, (byte) 161, 11, (byte) 160, 6, (byte) 128, 1, 1, (byte) 134, 1, 7, (byte) 129, 1, 100 }; } @Test(groups = { "functional.decode", "circuitSwitchedCall.primitive" }) public void testDecode() throws Exception { byte[] data = this.getData1(); AsnInputStream ais = new AsnInputStream(data); AOCBeforeAnswerImpl elem = new AOCBeforeAnswerImpl(); int tag = ais.readTag(); elem.decodeAll(ais); assertNull(elem.getAOCInitial().getE1()); assertNull(elem.getAOCInitial().getE2()); assertNull(elem.getAOCInitial().getE3()); assertEquals((int) elem.getAOCInitial().getE4(), 4); assertEquals((int) elem.getAOCInitial().getE5(), 5); assertNull(elem.getAOCInitial().getE6()); assertNull(elem.getAOCInitial().getE7()); assertEquals((int) elem.getAOCSubsequent().getCAI_GSM0224().getE1(), 1); assertNull(elem.getAOCSubsequent().getCAI_GSM0224().getE2()); assertNull(elem.getAOCSubsequent().getCAI_GSM0224().getE3()); assertNull(elem.getAOCSubsequent().getCAI_GSM0224().getE4()); assertNull(elem.getAOCSubsequent().getCAI_GSM0224().getE5()); assertNull(elem.getAOCSubsequent().getCAI_GSM0224().getE6()); assertEquals((int) elem.getAOCSubsequent().getCAI_GSM0224().getE7(), 7); assertEquals((int) elem.getAOCSubsequent().getTariffSwitchInterval(), 100); } @Test(groups = { "functional.encode", "circuitSwitchedCall.primitive" }) public void testEncode() throws Exception { CAI_GSM0224Impl aocInitial = new CAI_GSM0224Impl(null, null, null, 4, 5, null, null); CAI_GSM0224Impl cai_GSM0224 = new CAI_GSM0224Impl(1, null, null, null, null, null, 7); AOCSubsequentImpl aocSubsequent = new AOCSubsequentImpl(cai_GSM0224, 100); AOCBeforeAnswerImpl elem = new AOCBeforeAnswerImpl(aocInitial, aocSubsequent); // CAI_GSM0224 aocInitial, AOCSubsequent aocSubsequent AsnOutputStream aos = new AsnOutputStream(); elem.encodeAll(aos); assertTrue(Arrays.equals(aos.toByteArray(), this.getData1())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive; import java.io.Serializable; /** * AOCBeforeAnswer ::= SEQUENCE { aOCInitial [0] CAI-GSM0224, aOCSubsequent [1] AOCSubsequent OPTIONAL } * * * @author sergey vetyutnev * */ public interface AOCBeforeAnswer extends Serializable { CAI_GSM0224 getAOCInitial(); AOCSubsequent getAOCSubsequent(); }```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.AOCSubsequent; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.CAI_GSM0224; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.AOCGPRS; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.PDPID; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.AOCSubsequentImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAI_GSM0224Impl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.AOCGPRSImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.CAMELSCIGPRSBillingChargingCharacteristicsImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.PDPIDImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class CAMELSCIGPRSBillingChargingCharacteristicsTest { public byte[] getData() { return new byte[] { 48, 42, -96, 37, -96, 21, -128, 1, 1, -127, 1, 2, -126, 1, 3, -125, 1, 4, -124, 1, 5, -123, 1, 6, -122, 1, 7, -95, 12, -96, 6, -125, 1, 4, -124, 1, 5, -127, 2, 0, -34, -127, 1, 1 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); CAMELSCIGPRSBillingChargingCharacteristicsImpl prim = new CAMELSCIGPRSBillingChargingCharacteristicsImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE1(), 1); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE2(), 2); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE3(), 3); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE4(), 4); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE5(), 5); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE6(), 6); assertEquals((int) prim.getAOCGPRS().getAOCInitial().getE7(), 7); assertNull(prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE1()); assertNull(prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE2()); assertNull(prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE3()); assertEquals((int) prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE4(), 4); assertEquals((int) prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE5(), 5); assertNull(prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE6()); assertNull(prim.getAOCGPRS().getAOCSubsequent().getCAI_GSM0224().getE7()); assertEquals((int) prim.getAOCGPRS().getAOCSubsequent().getTariffSwitchInterval(), 222); assertEquals(prim.getPDPID().getId(), 1); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { CAI_GSM0224 aocInitial = new CAI_GSM0224Impl(1, 2, 3, 4, 5, 6, 7); CAI_GSM0224Impl cai_GSM0224 = new CAI_GSM0224Impl(null, null, null, 4, 5, null, null); AOCSubsequent aocSubsequent = new AOCSubsequentImpl(cai_GSM0224, 222); AOCGPRS aocGPRS = new AOCGPRSImpl(aocInitial, aocSubsequent); PDPID pdpID = new PDPIDImpl(1); CAMELSCIGPRSBillingChargingCharacteristicsImpl prim = new CAMELSCIGPRSBillingChargingCharacteristicsImpl(aocGPRS, pdpID); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; /** * CAMEL-SCIGPRSBillingChargingCharacteristics ::= SEQUENCE { aOCGPRS [0] AOCGPRS, pDPID [1] PDPID OPTIONAL, ... } * * * * * @author sergey vetyutnev * */ public interface CAMELSCIGPRSBillingChargingCharacteristics extends Serializable { AOCGPRS getAOCGPRS(); PDPID getPDPID(); }```
```package org.restcomm.protocols.ss7.map.service.supplementary; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.service.supplementary.RegisterSSResponseImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSDataImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class RegisterSSResponseTest { private byte[] getEncodedData1() { return new byte[] { (byte) 163, 3, 4, 1, 18 }; } @Test(groups = { "functional.decode", "service.supplementary" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData1(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, SSInfoImpl._TAG_ssData); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); RegisterSSResponseImpl impl = new RegisterSSResponseImpl(); impl.decodeAll(asn); assertEquals(impl.getSsInfo().getSsData().getSsCode().getSupplementaryCodeValue(), SupplementaryCodeValue.clir); assertNull(impl.getSsInfo().getCallBarringInfo()); assertNull(impl.getSsInfo().getForwardingInfo()); } @Test(groups = { "functional.encode", "service.supplementary" }) public void testEncode() throws Exception { SSCode ssCode = new SSCodeImpl(SupplementaryCodeValue.clir); SSDataImpl ssData = new SSDataImpl(ssCode, null, null, null, null, null); SSInfoImpl ssInfo = new SSInfoImpl(ssData); RegisterSSResponseImpl impl = new RegisterSSResponseImpl(ssInfo); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.supplementary; /** * <code> RESULT SS-Info -- optional </code> * * * @author sergey vetyutnev * */ public interface RegisterSSResponse extends SupplementaryMessage { SSInfo getSsInfo(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AccessDeliveryInformationImpl; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class AccessDeliveryInformationTest extends ParameterHarness { public AccessDeliveryInformationTest() { super(); super.badBodies.add(new byte[2]); super.goodBodies.add(getBody1()); } private byte[] getBody1() { byte[] body = new byte[]{(byte)0x01}; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { AccessDeliveryInformationImpl at = new AccessDeliveryInformationImpl(getBody1()); String[] methodNames = { "getAccessDeliveryIndicator" }; Object[] expectedValues = { AccessDeliveryInformationImpl._NO_SETUP_MESSAGE }; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.AccessDeliveryInformationImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:10:53:42 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com"> Bartosz Baranowski </a> */ public interface AccessDeliveryInformation extends ISUPParameter { /** * See Q.763 3.2 Access delivery indicator: set-up message generated */ int _SETUP_MESSAGE = 0; /** * See Q.763 3.2 Access delivery indicator:no set-up message generated */ int _NO_SETUP_MESSAGE = 1; int _PARAMETER_CODE = 0x2E; int getAccessDeliveryIndicator(); void setAccessDeliveryIndicator(int accessDeliveryIndicator); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultSMSHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSCAMELTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCAMELTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCSIImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class SMSCSITest { public byte[] getData() { return new byte[] { 48, 104, -96, 58, 48, 56, -128, 1, 1, -127, 1, 4, -126, 4, -111, 34, 50, -11, -125, 1, 0, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 8, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); SMSCSIImpl prim = new SMSCSIImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = prim.getSmsCamelTdpDataList(); assertNotNull(smsCamelTdpDataList); assertEquals(smsCamelTdpDataList.size(), 1); SMSCAMELTDPData one = smsCamelTdpDataList.get(0); assertNotNull(one); assertEquals(one.getServiceKey(), 4); assertEquals(one.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); ISDNAddressString gsmSCFAddress = one.getGsmSCFAddress(); assertTrue(gsmSCFAddress.getAddress().equals("22235")); assertEquals(gsmSCFAddress.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddress.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(one.getDefaultSMSHandling(), DefaultSMSHandling.continueTransaction); assertNotNull(one.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(one.getExtensionContainer())); assertNotNull(prim.getExtensionContainer()); assertTrue(!prim.getCsiActive()); assertTrue(!prim.getNotificationToCSE()); assertEquals(prim.getCamelCapabilityHandling().intValue(), 8); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); SMSTriggerDetectionPoint smsTriggerDetectionPoint = SMSTriggerDetectionPoint.smsCollectedInfo; long serviceKey = 4; ISDNAddressString gsmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); ; DefaultSMSHandling defaultSMSHandling = DefaultSMSHandling.continueTransaction; ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = new ArrayList<SMSCAMELTDPData>(); SMSCAMELTDPDataImpl smsCAMELTDPData = new SMSCAMELTDPDataImpl(smsTriggerDetectionPoint, serviceKey, gsmSCFAddress, defaultSMSHandling, extensionContainer); smsCamelTdpDataList.add(smsCAMELTDPData); Integer camelCapabilityHandling = new Integer(8); boolean notificationToCSE = false; boolean csiActive = false; SMSCSIImpl prim = new SMSCSIImpl(smsCamelTdpDataList, camelCapabilityHandling, extensionContainer, notificationToCSE, csiActive); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * SMS-CSI ::= SEQUENCE { sms-CAMEL-TDP-DataList [0] SMS-CAMEL-TDP-DataList OPTIONAL, camelCapabilityHandling [1] * CamelCapabilityHandling OPTIONAL, extensionContainer [2] ExtensionContainer OPTIONAL, notificationToCSE [3] NULL OPTIONAL, * csi-Active [4] NULL OPTIONAL, ...} -- notificationToCSE and csi-Active shall not be present -- when MO-SMS-CSI or MT-SMS-CSI * is sent to VLR or SGSN. -- They may only be included in ATSI/ATM ack/NSDC message. -- SMS-CAMEL-TDP-Data and * camelCapabilityHandling shall be present in -- the SMS-CSI sequence. -- If SMS-CSI is segmented, sms-CAMEL-TDP-DataList and * camelCapabilityHandling shall be -- present in the first segment * * SMS-CAMEL-TDP-DataList ::= SEQUENCE SIZE (1..1-) OF SMS-CAMEL-TDP-Data -- SMS-CAMEL-TDP-DataList shall not contain more than * one instance of -- SMS-CAMEL-TDP-Data containing the same value for sms-TriggerDetectionPoint. * * CamelCapabilityHandling ::= INTEGER(1..16) -- value 1 = CAMEL phase 1, -- value 2 = CAMEL phase 2, -- value 3 = CAMEL Phase * 3, -- value 4 = CAMEL phase 4: -- reception of values greater than 4 shall be treated as CAMEL phase 4. * * * * @author sergey vetyutnev * */ public interface SMSCSI extends Serializable { ArrayList<SMSCAMELTDPData> getSmsCamelTdpDataList(); Integer getCamelCapabilityHandling(); MAPExtensionContainer getExtensionContainer(); boolean getNotificationToCSE(); boolean getCsiActive(); } ```
```package org.restcomm.protocols.ss7.cap.service.gprs; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.TimerID; import org.restcomm.protocols.ss7.cap.service.gprs.ResetTimerGPRSRequestImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ResetTimerGPRSRequestTest { public byte[] getData() { return new byte[] { 48, 6, -128, 1, 0, -127, 1, 12 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ResetTimerGPRSRequestImpl prim = new ResetTimerGPRSRequestImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getTimerValue(), 12); assertEquals(prim.getTimerID(), TimerID.tssf); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { ResetTimerGPRSRequestImpl prim = new ResetTimerGPRSRequestImpl(TimerID.tssf, 12); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs; import org.restcomm.protocols.ss7.cap.api.primitives.TimerID; /** * resetTimerGPRS OPERATION ::= { ARGUMENT ResetTimerGPRSArg RETURN RESULT FALSE ERRORS {missingParameter | parameterOutOfRange * | taskRefused | unexpectedComponentSequence | unexpectedDataValue | unexpectedParameter | unknownPDPID} CODE * opcode-resetTimerGPRS} -- Direction: gsmSCF > gprsSSF, Timer: Trtg -- This operation is used to request the gprsSSF to * refresh an application timer in the gprsSSF. * * ResetTimerGPRSArg ::= SEQUENCE { timerID [0] TimerID DEFAULT tssf, timervalue [1] TimerValue, ... } * * TimerValue ::= Integer4 -- Indicates the timer value (in seconds). * * * * @author sergey vetyutnev * */ public interface ResetTimerGPRSRequest extends GprsMessage { TimerID getTimerID(); int getTimerValue(); }```
```package org.restcomm.protocols.ss7.tcapAnsi.asn; import static org.testng.Assert.*; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.ApplicationContext; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.DialogPortion; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.Component; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.ComponentType; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.Parameter; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.ReturnResultLast; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.TCResponseMessage; import org.restcomm.protocols.ss7.tcapAnsi.asn.TcapFactory; import org.testng.annotations.Test; @Test(groups = { "asn" }) public class TcResponseTest { private byte[] data1 = new byte[] { (byte) 0xe4, 0x3c, (byte) 0xc7, 0x04, 0x14, 0x00, 0x00, 0x00, (byte) 0xe8, 0x34, (byte) 0xea, 0x32, (byte) 0xcf, 0x01, 0x01, (byte) 0xf2, 0x2d, (byte) 0x96, 0x01, 0x13, (byte) 0x8e, 0x02, 0x06, 0x00, (byte) 0x95, 0x03, 0x00, 0x0c, 0x10, (byte) 0x9f, 0x4e, 0x01, 0x01, (byte) 0x99, 0x03, 0x7a, 0x0d, 0x11, (byte) 0x9f, 0x5d, 0x07, 0x00, 0x00, 0x21, 0x06, 0x36, 0x54, 0x10, (byte) 0x97, 0x01, 0x07, (byte) 0x9f, 0x73, 0x01, 0x00, (byte) 0x9f, 0x75, 0x01, 0x00, (byte) 0x98, 0x01, 0x02 }; private byte[] data2 = new byte[] { -28, 11, -57, 4, 20, 0, 0, 0, -7, 3, -37, 1, 66 }; private byte[] trId = new byte[] { 20, 0, 0, 0 }; private byte[] parData = new byte[] { -106, 1, 19, -114, 2, 6, 0, -107, 3, 0, 12, 16, -97, 78, 1, 1, -103, 3, 122, 13, 17, -97, 93, 7, 0, 0, 33, 6, 54, 84, 16, -105, 1, 7, -97, 115, 1, 0, -97, 117, 1, 0, -104, 1, 2 }; @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { // 1 AsnInputStream ais = new AsnInputStream(this.data1); int tag = ais.readTag(); assertEquals(tag, TCResponseMessage._TAG_RESPONSE); assertEquals(ais.getTagClass(), Tag.CLASS_PRIVATE); TCResponseMessage tcm = TcapFactory.createTCResponseMessage(ais); assertEquals(tcm.getDestinationTransactionId(), trId); assertNull(tcm.getDialogPortion()); assertEquals(tcm.getComponent().length, 1); Component cmp = tcm.getComponent()[0]; assertEquals(cmp.getType(), ComponentType.ReturnResultLast); ReturnResultLast rrl = (ReturnResultLast) cmp; assertEquals((long) rrl.getCorrelationId(), 1); Parameter p = rrl.getParameter(); assertEquals(p.getTag(), 18); assertEquals(p.getTagClass(), Tag.CLASS_PRIVATE); assertFalse(p.isPrimitive()); assertEquals(p.getData(), parData); // 2 ais = new AsnInputStream(this.data2); tag = ais.readTag(); assertEquals(tag, TCResponseMessage._TAG_RESPONSE); assertEquals(ais.getTagClass(), Tag.CLASS_PRIVATE); tcm = TcapFactory.createTCResponseMessage(ais); assertEquals(tcm.getDestinationTransactionId(), trId); DialogPortion dp = tcm.getDialogPortion(); assertNull(dp.getProtocolVersion()); ApplicationContext ac = dp.getApplicationContext(); assertEquals(ac.getInteger(), 66); assertNull(dp.getConfidentiality()); assertNull(dp.getSecurityContext()); assertNull(dp.getUserInformation()); assertNull(tcm.getComponent()); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { // 1 Component[] cc = new Component[1]; ReturnResultLast rrl = TcapFactory.createComponentReturnResultLast(); cc[0] = rrl; rrl.setCorrelationId(1L); Parameter p = TcapFactory.createParameterSet(); p.setData(parData); rrl.setParameter(p); TCResponseMessage tcm = TcapFactory.createTCResponseMessage(); tcm.setDestinationTransactionId(trId); tcm.setComponent(cc); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encodedData = aos.toByteArray(); byte[] expectedData = data1; assertEquals(encodedData, expectedData); // 2 tcm = TcapFactory.createTCResponseMessage(); tcm.setDestinationTransactionId(trId); DialogPortion dp = TcapFactory.createDialogPortion(); ApplicationContext ac = TcapFactory.createApplicationContext(66); dp.setApplicationContext(ac); tcm.setDialogPortion(dp); aos = new AsnOutputStream(); tcm.encode(aos); encodedData = aos.toByteArray(); expectedData = data2; assertEquals(encodedData, expectedData); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.tcapAnsi.asn; import java.io.IOException; import java.util.Arrays; import org.mobicents.protocols.asn.AsnException; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.DialogPortion; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.EncodeException; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.ParseException; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.Component; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.PAbortCause; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.TCQueryMessage; import org.restcomm.protocols.ss7.tcapAnsi.api.asn.comp.TCResponseMessage; /** * @author baranowb * @author sergey vetyutnev * */ public class TCResponseMessageImpl implements TCResponseMessage { private byte[] destinationTransactionId; private DialogPortion dp; private Component[] component; /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage#getComponent() */ public Component[] getComponent() { return this.component; } /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage#getDialogPortion () */ public DialogPortion getDialogPortion() { return this.dp; } /* * (non-Javadoc) * * @seeorg.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage# getOriginatingTransactionId() */ public byte[] getDestinationTransactionId() { return this.destinationTransactionId; } /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage#setComponent * (org.restcomm.protocols.ss7.tcap.asn.comp.Component[]) */ public void setComponent(Component[] c) { this.component = c; } /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage#setDialogPortion * (org.restcomm.protocols.ss7.tcap.asn.DialogPortion) */ public void setDialogPortion(DialogPortion dp) { this.dp = dp; } /* * (non-Javadoc) * * @seeorg.restcomm.protocols.ss7.tcap.asn.comp.TCBeginMessage# setOriginatingTransactionId(java.lang.String) */ public void setDestinationTransactionId(byte[] t) { if (t != null && t.length != 4) throw new IllegalArgumentException("TransactionId leng must be 4 bytes, found: " + t.length); this.destinationTransactionId = t; } /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.Encodable#decode(org.mobicents.protocols .asn.AsnInputStream) */ public void decode(AsnInputStream ais) throws ParseException { this.destinationTransactionId = null; this.dp = null; this.component = null; try { AsnInputStream localAis = ais.readSequenceStream(); // transaction portion TransactionID tid = TcapFactory.readTransactionID(localAis); if (tid.getFirstElem() == null || tid.getSecondElem() != null) { throw new ParseException(PAbortCause.BadlyStructuredTransactionPortion, "Error decoding TCResponseMessage: transactionId must contain one and only one transactionId"); } this.destinationTransactionId = tid.getFirstElem(); // dialog portion if (localAis.available() == 0) { throw new ParseException(PAbortCause.UnrecognizedDialoguePortionID, "Error decoding TCResponseMessage: neither dialog no component portion is found"); } int tag = localAis.readTag(); if (tag == DialogPortion._TAG_DIALOG_PORTION) { this.dp = TcapFactory.createDialogPortion(localAis); if (localAis.available() == 0) return; tag = localAis.readTag(); } // component portion this.component = TcapFactory.readComponents(localAis); } catch (IOException e) { throw new ParseException(PAbortCause.BadlyStructuredDialoguePortion, "IOException while decoding TCResponseMessage: " + e.getMessage(), e); } catch (AsnException e) { throw new ParseException(PAbortCause.BadlyStructuredDialoguePortion, "AsnException while decoding TCResponseMessage: " + e.getMessage(), e); } } /* * (non-Javadoc) * * @see org.restcomm.protocols.ss7.tcap.asn.Encodable#encode(org.mobicents.protocols .asn.AsnOutputStream) */ public void encode(AsnOutputStream aos) throws EncodeException { if (this.destinationTransactionId == null || this.destinationTransactionId.length != 4) throw new EncodeException("Error while encoding TCResponseMessage: destinationTransactionId is not defined or has not a length 4"); // TODO: should we send a Component without both components and dialogPortion ? if ((this.component == null || this.component.length == 0) && this.dp == null) throw new EncodeException("Error while encoding TCResponseMessage: neither dialogPortion nor componentPortion is defined"); try { aos.writeTag(Tag.CLASS_PRIVATE, false, TCResponseMessage._TAG_RESPONSE); int pos = aos.StartContentDefiniteLength(); aos.writeOctetString(Tag.CLASS_PRIVATE, TCQueryMessage._TAG_TRANSACTION_ID, this.destinationTransactionId); if (this.dp != null) this.dp.encode(aos); if (component != null && component.length > 0) { aos.writeTag(Tag.CLASS_PRIVATE, false, TCQueryMessage._TAG_COMPONENT_SEQUENCE); int pos2 = aos.StartContentDefiniteLength(); for (Component c : this.component) { c.encode(aos); } aos.FinalizeContent(pos2); } aos.FinalizeContent(pos); } catch (IOException e) { throw new EncodeException("IOException while encoding TCResponseMessage: " + e.getMessage(), e); } catch (AsnException e) { throw new EncodeException("AsnException while encoding TCResponseMessage: " + e.getMessage(), e); } } public String toString() { StringBuilder sb = new StringBuilder(); sb.append("TCResponseMessage ["); if (this.destinationTransactionId != null) { sb.append("destinationTransactionId=["); sb.append(Arrays.toString(this.destinationTransactionId)); sb.append("], "); } if (this.dp != null) { sb.append("DialogPortion="); sb.append(this.dp); sb.append(", "); } if (this.component != null && this.component.length > 0) { sb.append("Components=["); int i1 = 0; for (Component comp : this.component) { if (i1 == 0) i1 = 1; else sb.append(", "); sb.append(comp.toString()); } sb.append("], "); } sb.append("]"); return sb.toString(); } } ```
```package org.restcomm.protocols.ss7.map.datacoding; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import org.restcomm.protocols.ss7.map.api.datacoding.CBSDataCodingGroup; import org.restcomm.protocols.ss7.map.api.datacoding.CBSNationalLanguage; import org.restcomm.protocols.ss7.map.api.smstpdu.CharacterSet; import org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingSchemaMessageClass; import org.restcomm.protocols.ss7.map.datacoding.CBSDataCodingSchemeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class CBSDataCodingSchemeTest { @Test(groups = { "functional.decode", "datacoding" }) public void testDecode() throws Exception { // first common case - dcs=15 - GSM7 CBSDataCodingSchemeImpl dcs = new CBSDataCodingSchemeImpl(15); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralGsm7); assertEquals(dcs.getNationalLanguageShiftTable(), CBSNationalLanguage.LanguageUnspecified); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); // second common case - dcs=72 - USC2 dcs = new CBSDataCodingSchemeImpl(72); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralDataCodingIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.UCS2); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralGsm7); assertEquals(dcs.getNationalLanguageShiftTable(), CBSNationalLanguage.German); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x0B); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralGsm7); assertEquals(dcs.getNationalLanguageShiftTable(), CBSNationalLanguage.Greek); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x22); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralGsm7); assertEquals(dcs.getNationalLanguageShiftTable(), CBSNationalLanguage.Arabic); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x0F); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralGsm7); assertEquals(dcs.getNationalLanguageShiftTable(), CBSNationalLanguage.LanguageUnspecified); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x10); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralWithLanguageIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x11); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralWithLanguageIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.UCS2); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x78); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralDataCodingIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.UCS2); assertEquals(dcs.getMessageClass(), DataCodingSchemaMessageClass.Class0); assertTrue(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x57); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralDataCodingIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM8); assertEquals(dcs.getMessageClass(), DataCodingSchemaMessageClass.Class3); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x4C); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.GeneralDataCodingIndication); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.Reserved); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0x99); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.MessageWithUserDataHeader); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.UCS2); assertEquals(dcs.getMessageClass(), DataCodingSchemaMessageClass.Class1); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0xD0); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.I1ProtocolMessage); assertNull(dcs.getNationalLanguageShiftTable()); assertNull(dcs.getCharacterSet()); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0xE0); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.DefinedByTheWAPForum); assertNull(dcs.getNationalLanguageShiftTable()); assertNull(dcs.getCharacterSet()); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0xF6); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.DataCodingMessageClass); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM8); assertEquals(dcs.getMessageClass(), DataCodingSchemaMessageClass.Class2); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0xF3); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.DataCodingMessageClass); assertNull(dcs.getNationalLanguageShiftTable()); assertEquals(dcs.getCharacterSet(), CharacterSet.GSM7); assertEquals(dcs.getMessageClass(), DataCodingSchemaMessageClass.Class3); assertFalse(dcs.getIsCompressed()); dcs = new CBSDataCodingSchemeImpl(0xC0); assertEquals(dcs.getDataCodingGroup(), CBSDataCodingGroup.Reserved); assertNull(dcs.getNationalLanguageShiftTable()); assertNull(dcs.getCharacterSet()); assertNull(dcs.getMessageClass()); assertFalse(dcs.getIsCompressed()); } @Test(groups = { "functional.encode", "datacoding" }) public void testEncode() throws Exception { CBSDataCodingSchemeImpl dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralGsm7, CharacterSet.GSM7, CBSNationalLanguage.German, null, false); assertEquals(dcs.getCode(), 0); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralGsm7, CharacterSet.GSM7, CBSNationalLanguage.Greek, null, false); assertEquals(dcs.getCode(), 0x0B); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralGsm7, CharacterSet.GSM7, CBSNationalLanguage.Arabic, null, false); assertEquals(dcs.getCode(), 0x22); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralGsm7, CharacterSet.GSM7, CBSNationalLanguage.LanguageUnspecified, null, false); assertEquals(dcs.getCode(), 0x0F); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralWithLanguageIndication, CharacterSet.GSM7, null, null, false); assertEquals(dcs.getCode(), 0x10); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralWithLanguageIndication, CharacterSet.UCS2, null, null, false); assertEquals(dcs.getCode(), 0x11); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralDataCodingIndication, CharacterSet.UCS2, null, DataCodingSchemaMessageClass.Class0, true); assertEquals(dcs.getCode(), 0x78); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralDataCodingIndication, CharacterSet.GSM8, null, DataCodingSchemaMessageClass.Class3, false); assertEquals(dcs.getCode(), 0x57); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.GeneralDataCodingIndication, CharacterSet.Reserved, null, null, false); assertEquals(dcs.getCode(), 0x4C); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.MessageWithUserDataHeader, CharacterSet.UCS2, null, DataCodingSchemaMessageClass.Class1, false); assertEquals(dcs.getCode(), 0x99); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.I1ProtocolMessage, null, null, null, false); assertEquals(dcs.getCode(), 0xD0); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.DefinedByTheWAPForum, null, null, null, false); assertEquals(dcs.getCode(), 0xE0); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.DataCodingMessageClass, CharacterSet.GSM8, null, DataCodingSchemaMessageClass.Class2, false); assertEquals(dcs.getCode(), 0xF6); dcs = new CBSDataCodingSchemeImpl(CBSDataCodingGroup.DataCodingMessageClass, CharacterSet.GSM7, null, DataCodingSchemaMessageClass.Class3, false); assertEquals(dcs.getCode(), 0xF3); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.datacoding; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.smstpdu.CharacterSet; import org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingSchemaMessageClass; /** * * @author sergey vetyutnev * */ public interface CBSDataCodingScheme extends Serializable { int getCode(); CBSDataCodingGroup getDataCodingGroup(); CBSNationalLanguage getNationalLanguageShiftTable(); CharacterSet getCharacterSet(); DataCodingSchemaMessageClass getMessageClass(); boolean getIsCompressed(); } ```
```package org.restcomm.protocols.ss7.map.service.lsm; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.lsm.DeferredLocationEventTypeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class DeferredLocationEventTypeTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 4, -96 }; } @Test(groups = { "functional.decode", "service.lsm" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); DeferredLocationEventTypeImpl imp = new DeferredLocationEventTypeImpl(); imp.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(imp.getMsAvailable()); assertFalse(imp.getEnteringIntoArea()); assertTrue(imp.getLeavingFromArea()); assertFalse(imp.getBeingInsideArea()); } @Test(groups = { "functional.encode", "service.lsm" }) public void testEncode() throws Exception { DeferredLocationEventTypeImpl imp = new DeferredLocationEventTypeImpl(true, false, true, false); // boolean msAvailable, boolean enteringIntoArea, boolean leavingFromArea, boolean beingInsideArea AsnOutputStream asnOS = new AsnOutputStream(); imp.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.lsm; import java.io.Serializable; /** * DeferredLocationEventType ::= BIT STRING { msAvailable (0) , enteringIntoArea (1), leavingFromArea (2), beingInsideArea (3) } * (SIZE (1..16)) -- beingInsideArea is always treated as oneTimeEvent regardless of the possible value -- of occurrenceInfo * inside areaEventInfo. -- exception handling: -- a ProvideSubscriberLocation-Arg containing other values than listed above in * -- DeferredLocationEventType shall be rejected by the receiver with a return error cause of -- unexpected data value. * * @author amit bhayani * */ public interface DeferredLocationEventType extends Serializable { boolean getMsAvailable(); boolean getEnteringIntoArea(); boolean getLeavingFromArea(); boolean getBeingInsideArea(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.*; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.LSAIdentity; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.LSAIdentityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.LSAInformationWithdrawImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class LSAInformationWithdrawTest { private byte[] getEncodedData() { return new byte[] { 5, 0 }; } private byte[] getEncodedData2() { return new byte[] { 48, 5, 4, 3, 1, 2, 3 }; } private byte[] getLsaIdData() { return new byte[] { 1, 2, 3 }; } @Test public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); LSAInformationWithdrawImpl asc = new LSAInformationWithdrawImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.NULL); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asn.isTagPrimitive()); assertTrue(asc.getAllLSAData()); assertNull(asc.getLSAIdentityList()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new LSAInformationWithdrawImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertFalse(asn.isTagPrimitive()); assertFalse(asc.getAllLSAData()); assertEquals(asc.getLSAIdentityList().size(), 1); assertEquals(asc.getLSAIdentityList().get(0).getData(), getLsaIdData()); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { LSAInformationWithdrawImpl asc = new LSAInformationWithdrawImpl(true); AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); ArrayList<LSAIdentity> arr = new ArrayList<LSAIdentity>(); LSAIdentity lsaId = new LSAIdentityImpl(getLsaIdData()); arr.add(lsaId); asc = new LSAInformationWithdrawImpl(arr); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import java.util.ArrayList; /** * LSAInformationWithdraw ::= CHOICE { allLSAData NULL, lsaIdentityList LSAIdentityList } * * LSAIdentityList ::= SEQUENCE SIZE (1..20) OF LSAIdentity * * * @author sergey vetyutnev * */ public interface LSAInformationWithdraw extends Serializable { boolean getAllLSAData(); ArrayList<LSAIdentity> getLSAIdentityList(); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.primitives.AddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.service.sms.SM_RP_OAImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class SM_RP_OATest { private byte[] getEncodedData_Msisdn() { return new byte[] { (byte) 130, 7, (byte) 145, (byte) 147, 51, 88, 38, 101, 89 }; } private byte[] getEncodedData_ServiceCentreAddressOA() { return new byte[] { -124, 7, -111, -127, 16, 7, 17, 17, -15 }; } private byte[] getEncodedData_No() { return new byte[] { (byte) 133, 0 }; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData_ServiceCentreAddressOA(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); SM_RP_OAImpl oa = new SM_RP_OAImpl(); oa.decodeAll(asn); assertEquals(tag, 4); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); AddressString nnm = oa.getServiceCentreAddressOA(); assertEquals(nnm.getAddressNature(), AddressNature.international_number); assertEquals(nnm.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(nnm.getAddress(), "18017011111"); rawData = getEncodedData_Msisdn(); asn = new AsnInputStream(rawData); tag = asn.readTag(); oa = new SM_RP_OAImpl(); oa.decodeAll(asn); assertEquals(tag, 2); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); ISDNAddressString msisdn = oa.getMsisdn(); assertEquals(msisdn.getAddressNature(), AddressNature.international_number); assertEquals(msisdn.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(msisdn.getAddress(), "393385625695"); rawData = getEncodedData_No(); asn = new AsnInputStream(rawData); tag = asn.readTag(); oa = new SM_RP_OAImpl(); oa.decodeAll(asn); assertEquals(tag, 5); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertEquals(oa.getServiceCentreAddressOA(), null); assertEquals(oa.getMsisdn(), null); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { AddressStringImpl astr = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "18017011111"); SM_RP_OAImpl oa = new SM_RP_OAImpl(); oa.setServiceCentreAddressOA(astr); AsnOutputStream asnOS = new AsnOutputStream(); oa.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData_ServiceCentreAddressOA(); assertTrue(Arrays.equals(rawData, encodedData)); ISDNAddressStringImpl isdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "393385625695"); oa = new SM_RP_OAImpl(); oa.setMsisdn(isdn); asnOS = new AsnOutputStream(); oa.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData_Msisdn(); assertTrue(Arrays.equals(rawData, encodedData)); oa = new SM_RP_OAImpl(); asnOS = new AsnOutputStream(); oa.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData_No(); assertTrue(Arrays.equals(rawData, encodedData)); } @Test(groups = { "functional.serialize", "service.sms" }) public void testSerialization() throws Exception { AddressStringImpl astr = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "18017011111"); SM_RP_OAImpl original = new SM_RP_OAImpl(); // serialize ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(original); oos.close(); // deserialize byte[] pickled = out.toByteArray(); InputStream in = new ByteArrayInputStream(pickled); ObjectInputStream ois = new ObjectInputStream(in); Object o = ois.readObject(); SM_RP_OAImpl copy = (SM_RP_OAImpl) o; // test result assertEquals(copy.getServiceCentreAddressOA(), original.getServiceCentreAddressOA()); ISDNAddressStringImpl isdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "393385625695"); original = new SM_RP_OAImpl(); original.setMsisdn(isdn); // serialize out = new ByteArrayOutputStream(); oos = new ObjectOutputStream(out); oos.writeObject(original); oos.close(); // deserialize pickled = out.toByteArray(); in = new ByteArrayInputStream(pickled); ois = new ObjectInputStream(in); o = ois.readObject(); copy = (SM_RP_OAImpl) o; // test result assertEquals(copy.getMsisdn(), original.getMsisdn()); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; /** * SM-RP-OA ::= CHOICE { msisdn [2] ISDN-AddressString, serviceCentreAddressOA [4] AddressString, noSM-RP-OA [5] NULL} * * Only one method getMsisdn() or getServiceCentreAddressOA() will return the non null value If all these methods return null - * this means noSM-RP-OA value * * @author sergey vetyutnev * */ public interface SM_RP_OA extends Serializable { ISDNAddressString getMsisdn(); AddressString getServiceCentreAddressOA(); } ```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.oam.MMEInterfaceListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class MMEInterfaceListTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 3, (byte) 168 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); MMEInterfaceListImpl asc = new MMEInterfaceListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getS1Mme()); assertFalse(asc.getS3()); assertTrue(asc.getS6a()); assertFalse(asc.getS10()); assertTrue(asc.getS11()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { MMEInterfaceListImpl asc = new MMEInterfaceListImpl(true, false, true, false, true); // boolean s1Mme, boolean s3, boolean s6a, boolean s10, boolean s11 AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> MME-InterfaceList ::= BIT STRING { s1-mme (0), s3 (1), s6a (2), s10 (3), s11 (4) } (SIZE (5..8)) -- Other bits than listed above shall be discarded. </code> * * * @author sergey vetyutnev * */ public interface MMEInterfaceList extends Serializable { boolean getS1Mme(); boolean getS3(); boolean getS6a(); boolean getS10(); boolean getS11(); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCodeValue; import org.restcomm.protocols.ss7.map.api.service.sms.SMDeliveryNotIntended; import org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_MTI; import org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_SMEA; import org.restcomm.protocols.ss7.map.primitives.AddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TeleserviceCodeImpl; import org.restcomm.protocols.ss7.map.service.sms.SM_RP_SMEAImpl; import org.restcomm.protocols.ss7.map.service.sms.SendRoutingInfoForSMRequestImpl; import org.testng.annotations.Test; import java.util.Arrays; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; /** * * @author sergey vetyutnev * */ public class SendRoutingInfoForSMRequestTest { private byte[] getEncodedDataSimple() { return new byte[] { 48, 20, -128, 7, -111, 49, 84, 119, 84, 85, -15, -127, 1, 0, -126, 6, -111, -119, 18, 17, 51, 51 }; } private byte[] getEncodedDataComplex() { return new byte[] { 48, 30, -128, 7, -111, 49, 84, 119, 84, 85, -15, -127, 1, 0, -126, 6, -111, -119, 18, 17, 51, 51, -121, 0, -119, 6, -111, 105, 49, 3, -105, 97 }; } private byte[] getEncodedDataFull() { return new byte[] { 48, 70, -128, 6, -111, 17, 33, 34, 51, -13, -127, 1, -1, -126, 3, -72, 68, 68, -90, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -121, 0, -120, 1, 1, -119, 6, -111, 105, 49, 3, -105, 97 }; } private byte[] getEncodedData1() { return new byte[] { 48, 20, -128, 5, -111, 17, 17, 17, 17, -127, 1, 0, -126, 5, -111, 34, 34, 34, 34, -123, 1, 33 }; } private byte[] getEncodedData2() { return new byte[] { 48,25,-128,5,-111,17,17,17,17,-127,1,-1,-126,5,-111,34,34,34,34,-121,0,-117,0,-114,0,-115,0 }; } private byte[] getEncodedData3() { return new byte[] { 48,20,-128,5,-111,17,17,17,17,-127,1,0,-126,5,-111,34,34,34,34,-118,1,0 }; } private byte[] getEncodedData4() { return new byte[] { 48, 34, -128, 5, -111, 17, 17, 17, 17, -127, 1, 0, -126, 5, -111, 34, 34, 34, 34, -116, 6, 81, 20, 69, 81, 20, 69, -81, 7, -128, 5, 17, 17, 33, 34, 34}; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedDataSimple(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); SendRoutingInfoForSMRequestImpl ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ISDNAddressString msisdn = ind.getMsisdn(); assertEquals(msisdn.getAddressNature(), AddressNature.international_number); assertEquals(msisdn.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(msisdn.getAddress(), "13457745551"); assertEquals((boolean) ind.getSm_RP_PRI(), false); AddressString sca = ind.getServiceCentreAddress(); assertEquals(sca.getAddressNature(), AddressNature.international_number); assertEquals(sca.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(sca.getAddress(), "9821113333"); assertNull(ind.getTeleservice()); rawData = getEncodedDataComplex(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); msisdn = ind.getMsisdn(); assertEquals(msisdn.getAddressNature(), AddressNature.international_number); assertEquals(msisdn.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(msisdn.getAddress(), "13457745551"); assertEquals((boolean) ind.getSm_RP_PRI(), false); sca = ind.getServiceCentreAddress(); assertEquals(sca.getAddressNature(), AddressNature.international_number); assertEquals(sca.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(sca.getAddress(), "9821113333"); assertEquals((boolean) ind.getGprsSupportIndicator(), true); assertTrue(Arrays.equals(new byte[] { -111, 105, 49, 3, -105, 97 }, ind.getSM_RP_SMEA().getData())); assertNull(ind.getTeleservice()); rawData = getEncodedDataFull(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); msisdn = ind.getMsisdn(); assertEquals(msisdn.getAddressNature(), AddressNature.international_number); assertEquals(msisdn.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(msisdn.getAddress(), "111222333"); assertEquals((boolean) ind.getSm_RP_PRI(), true); sca = ind.getServiceCentreAddress(); assertEquals(sca.getAddressNature(), AddressNature.network_specific_number); assertEquals(sca.getNumberingPlan(), NumberingPlan.national); assertEquals(sca.getAddress(), "4444"); assertEquals((boolean) ind.getGprsSupportIndicator(), true); assertTrue(Arrays.equals(new byte[] { -111, 105, 49, 3, -105, 97 }, ind.getSM_RP_SMEA().getData())); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); assertEquals(ind.getSM_RP_MTI(), SM_RP_MTI.SMS_Status_Report); assertNull(ind.getTeleservice()); rawData = getEncodedData1(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); msisdn = ind.getMsisdn(); assertEquals(msisdn.getAddressNature(), AddressNature.international_number); assertEquals(msisdn.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(msisdn.getAddress(), "11111111"); assertEquals((boolean) ind.getSm_RP_PRI(), false); sca = ind.getServiceCentreAddress(); assertEquals(sca.getAddressNature(), AddressNature.international_number); assertEquals(sca.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(sca.getAddress(), "22222222"); assertEquals(ind.getGprsSupportIndicator(), false); assertNull(ind.getSM_RP_SMEA()); assertNull(ind.getExtensionContainer()); assertNull(ind.getSM_RP_MTI()); assertEquals(ind.getTeleservice().getTeleserviceCodeValue(), TeleserviceCodeValue.shortMessageMT_PP); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(ind.getSm_RP_PRI()); assertTrue(ind.getGprsSupportIndicator()); assertTrue(ind.getIpSmGwGuidanceIndicator()); assertTrue(ind.getT4TriggerIndicator()); assertTrue(ind.getSingleAttemptDelivery()); rawData = getEncodedData3(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertFalse(ind.getSm_RP_PRI()); assertFalse(ind.getGprsSupportIndicator()); assertFalse(ind.getIpSmGwGuidanceIndicator()); assertFalse(ind.getT4TriggerIndicator()); assertFalse(ind.getSingleAttemptDelivery()); assertTrue(ind.getSmDeliveryNotIntended().equals(SMDeliveryNotIntended.onlyIMSIRequested)); rawData = getEncodedData4(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new SendRoutingInfoForSMRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(ind.getImsi().getData().equals("154154154154")); assertTrue(ind.getCorrelationID().getHlrId().getData().equals("1111122222")); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { //msisdn + sca ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "13457745551"); AddressString sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "9821113333"); SendRoutingInfoForSMRequestImpl ind = new SendRoutingInfoForSMRequestImpl(msisdn, false, sca, null, false, null, null, null, false, null, false, false, null, null); AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedDataSimple(); assertTrue(Arrays.equals(rawData, encodedData)); // msisdn + sca + sm_rp_smea msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "13457745551"); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "9821113333"); SM_RP_SMEA sm_rp_smea = new SM_RP_SMEAImpl(new byte[] { -111, 105, 49, 3, -105, 97 }); ind = new SendRoutingInfoForSMRequestImpl(msisdn, false, sca, null, true, null, sm_rp_smea, null, false, null, false, false, null, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataComplex(); assertTrue(Arrays.equals(rawData, encodedData)); //msisdn + sca + sm_rp_smea + extContainer + SM_RP_MTI msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "111222333"); sca = new AddressStringImpl(AddressNature.network_specific_number, NumberingPlan.national, "4444"); sm_rp_smea = new SM_RP_SMEAImpl(new byte[] { -111, 105, 49, 3, -105, 97 }); ind = new SendRoutingInfoForSMRequestImpl(msisdn, true, sca, MAPExtensionContainerTest.GetTestExtensionContainer(), true, SM_RP_MTI.SMS_Status_Report, sm_rp_smea, null, false, null, false, false, null, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataFull(); assertTrue(Arrays.equals(rawData, encodedData)); //msisdn + sca + tc msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111"); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222"); TeleserviceCodeImpl tc = new TeleserviceCodeImpl(TeleserviceCodeValue.shortMessageMT_PP); ind = new SendRoutingInfoForSMRequestImpl(msisdn, false, sca, null, false, null, null, null, false, null, false, false, tc, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); //msisdn + sca + sm_RP_PRI + gprsSupportIndicator + ipSmGwGuidanceIndicator + t4TriggerIndicator + this.singleAttemptDelivery msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111"); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222"); ind = new SendRoutingInfoForSMRequestImpl(msisdn, true, sca, null, true, null, null, null, true, null, true, true, null, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); //msisdn + sca + smDeliveryNotIntended msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111"); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222"); SMDeliveryNotIntended smDeliveryNotIntended = SMDeliveryNotIntended.onlyIMSIRequested; ind = new SendRoutingInfoForSMRequestImpl(msisdn, false, sca, null, false, null, null, smDeliveryNotIntended, false, null, false, false, null, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData3(); assertTrue(Arrays.equals(rawData, encodedData)); //msisdn + sca + imsi + correlationID msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "11111111"); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22222222"); IMSI imsi = new IMSIImpl("154154154154"); IMSI hlrId = new IMSIImpl("1111122222"); CorrelationIDImpl corrId = new CorrelationIDImpl(hlrId, null, null); ind = new SendRoutingInfoForSMRequestImpl(msisdn, false, sca, null, false, null, null, null, false, imsi, false, false, null, corrId); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData4(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCode; /** * <code> MAP V1-2-3: MAP V3: sendRoutingInfoForSM OPERATION ::= { --Timer m ARGUMENT RoutingInfoForSM-Arg RESULT RoutingInfoForSM-Res ERRORS { systemFailure | dataMissing | unexpectedDataValue | facilityNotSupported | unknownSubscriber | teleserviceNotProvisioned | callBarred | absentSubscriberSM } CODE local:45 } MAP V2: SendRoutingInfoForSM ::= OPERATION --Timer m ARGUMENT routingInfoForSM-Arg RoutingInfoForSM-Arg RESULT routingInfoForSM-Res RoutingInfoForSM-Res ERRORS { SystemFailure, DataMissing, UnexpectedDataValue, FacilityNotSupported, UnknownSubscriber, TeleserviceNotProvisioned, AbsentSubscriber, CallBarred } MAP V3: RoutingInfoForSM-Arg ::= SEQUENCE { msisdn [0] ISDN-AddressString, sm-RP-PRI [1] BOOLEAN, serviceCentreAddress [2] AddressString, extensionContainer [6] ExtensionContainer OPTIONAL, ... , gprsSupportIndicator [7] NULL OPTIONAL, -- gprsSupportIndicator is set only if the SMS-GMSC supports -- receiving of two numbers from the HLR sm-RP-MTI [8] SM-RP-MTI OPTIONAL, sm-RP-SMEA [9] SM-RP-SMEA OPTIONAL, sm-deliveryNotIntended [10] SM-DeliveryNotIntended OPTIONAL, ip-sm-gwGuidanceIndicator [11] NULL OPTIONAL, imsi [12] IMSI OPTIONAL, t4-Trigger-Indicator [14] NULL OPTIONAL, singleAttemptDelivery [13] NULL OPTIONAL, correlationID [15] CorrelationID OPTIONAL } MAP V2: RoutingInfoForSM-Arg ::= SEQUENCE { msisdn [0] ISDN-AddressString, sm-RP-PRI [1] BOOLEAN, erviceCentreAddress [2] AddressString, teleservice [5] TeleserviceCode OPTIONAL, -- teleservice must be absent in version greater 1 ... } </code> * * * @author sergey vetyutnev * @author eva ogallar * */ public interface SendRoutingInfoForSMRequest extends SmsMessage { ISDNAddressString getMsisdn(); boolean getSm_RP_PRI(); AddressString getServiceCentreAddress(); MAPExtensionContainer getExtensionContainer(); boolean getGprsSupportIndicator(); SM_RP_MTI getSM_RP_MTI(); SM_RP_SMEA getSM_RP_SMEA(); SMDeliveryNotIntended getSmDeliveryNotIntended(); boolean getIpSmGwGuidanceIndicator(); IMSI getImsi(); boolean getT4TriggerIndicator(); boolean getSingleAttemptDelivery(); CorrelationID getCorrelationID(); // for MAP V1 only TeleserviceCode getTeleservice(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.authentication.ReSynchronisationInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ReSynchronisationInfoTest { private byte[] getEncodedData() { return new byte[] { 48, 34, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 14, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3 }; } static protected byte[] getRandData() { return new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; } static protected byte[] getAutsData() { return new byte[] { 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3 }; } @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); ReSynchronisationInfoImpl asc = new ReSynchronisationInfoImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(asc.getRand(), getRandData())); assertTrue(Arrays.equals(asc.getAuts(), getAutsData())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { ReSynchronisationInfoImpl asc = new ReSynchronisationInfoImpl(getRandData(), getAutsData()); AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import java.io.Serializable; /** * * Re-synchronisationInfo ::= SEQUENCE { rand RAND, auts AUTS, ...} * * RAND ::= OCTET STRING (SIZE (16)) AUTS ::= OCTET STRING (SIZE (14)) * * * @author sergey vetyutnev * */ public interface ReSynchronisationInfo extends Serializable { byte[] getRand(); byte[] getAuts(); } ```
```package org.restcomm.protocols.ss7.tcap.asn; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.io.IOException; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.tcap.TCAPTestUtils; import org.restcomm.protocols.ss7.tcap.asn.DialogAPDU; import org.restcomm.protocols.ss7.tcap.asn.DialogAPDUType; import org.restcomm.protocols.ss7.tcap.asn.DialogResponseAPDU; import org.restcomm.protocols.ss7.tcap.asn.DialogServiceProviderType; import org.restcomm.protocols.ss7.tcap.asn.EncodeException; import org.restcomm.protocols.ss7.tcap.asn.ParseException; import org.restcomm.protocols.ss7.tcap.asn.Result; import org.restcomm.protocols.ss7.tcap.asn.ResultSourceDiagnostic; import org.restcomm.protocols.ss7.tcap.asn.ResultType; import org.restcomm.protocols.ss7.tcap.asn.TcapFactory; import org.restcomm.protocols.ss7.tcap.asn.comp.Component; import org.restcomm.protocols.ss7.tcap.asn.comp.ComponentType; import org.restcomm.protocols.ss7.tcap.asn.comp.Invoke; import org.restcomm.protocols.ss7.tcap.asn.comp.OperationCode; import org.restcomm.protocols.ss7.tcap.asn.comp.OperationCodeType; import org.restcomm.protocols.ss7.tcap.asn.comp.ReturnResultLast; import org.restcomm.protocols.ss7.tcap.asn.comp.TCContinueMessage; import org.testng.annotations.Test; @Test(groups = { "asn" }) public class TcContinueTest { @Test(groups = { "functional.encode", "functional.decode" }) public void testBasicTCContinue() throws IOException, EncodeException, ParseException { // OrigTran ID (full)............ 145031169 // DestTran ID (full)............ 144965633 // no idea how to check rest...? // trace byte[] b = new byte[] { 0x65, 0x16, // org txid 0x48, 0x04, 0x08, (byte) 0xA5, 0, 0x01, // dtx 0x49, 0x04, 8, (byte) 0xA4, 0, 1, // comp portion 0x6C, 8, // invoke (byte) 0xA1, 6, // invoke ID 0x02, 0x01, 0x01, // op code 0x02, 0x01, 0x37 }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCInvoke"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); assertNull(tcm.getDialogPortion(), "Dialog portion should not be present"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); // assertEquals(144965633L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA4, 0, 1, }), "Destination transaction id does not match"); assertNotNull(tcm.getComponent(), "Component portion should be present"); assertEquals(1, tcm.getComponent().length, "Component count is wrong"); Component c = tcm.getComponent()[0]; assertEquals(ComponentType.Invoke, c.getType(), "Wrong component type"); Invoke i = (Invoke) c; assertEquals(new Long(1), i.getInvokeId(), "Wrong invoke ID"); assertNull(i.getLinkedId(), "Linked ID is not null"); assertNotNull(i.getOperationCode(), "Operation code is null"); assertNull(i.getParameter(), "Parameter not null"); OperationCode oc = i.getOperationCode(); assertEquals(OperationCodeType.Local, oc.getOperationType(), "Wrong operation type"); assertEquals(new Long(0x37), oc.getLocalOperationCode(), "Wrong operation code"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } @Test(groups = { "functional.encode", "functional.decode" }) public void testBasicTCContinue_Long() throws IOException, EncodeException, ParseException { // trace byte[] b = new byte[] { // TCContinue 0x65, // len 60, // oid // OrigTran ID (full)............ 145031169 0x48, 0x04, 0x08, (byte) 0xA5, 0, 1, // dtx // DestTran ID (full)............ 144965633 0x49, 4, 8, (byte) 0xA4, 0, 1, // comp portion 0x6C, 46, (byte) // invoke 0xA1, 44, // invokeId 0x02, 1, 0x02, // op code 0x02, 0x01, 42, // Parameter 0x24, 36, (byte) // some tag.1 0xA0, 17, (byte) // some tag.1.1 0x80, 2, 0x11, 0x11, (byte) // some tag.1.2 0xA1, 04, (byte) // some tag.1.3 ? 0x82, 2, 0x00, 0x00, (byte) // 7 // some tag.1.4 0x82, 1, 12, (byte) // some tag.1.5 0x83, 2, 0x33, 0x33, (byte) // some trash here // tension indicator 2........ ??? // use value.................. ??? // some tag.2 0xA1, 3, (byte) // some tag.2.1 0x80, 1, -1, (byte) // some tag.3 0xA2, 3, (byte) // some tag.3.1 0x80, 1, -1, (byte) // some tag.4 0xA3, 5, (byte) // some tag.4.1 0x82, 3, (byte) // - 85 serviceKey................... 123456 // dont care about this content, lets just make len // correct 0xAB, (byte) 0xCD, (byte) 0xEF }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCInvoke"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); assertNull(tcm.getDialogPortion(), "Dialog portion should not be present"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); // assertEquals(144965633L,tcm.getDestinationTransactionId(),"Desination transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA4, 0, 1, }), "Destination transaction id does not match"); assertNotNull(tcm.getComponent(), "Component portion should be present"); assertEquals(1, tcm.getComponent().length, "Component count is wrong"); Component c = tcm.getComponent()[0]; assertEquals(ComponentType.Invoke, c.getType(), "Wrong component type"); Invoke i = (Invoke) c; assertEquals(new Long(2), i.getInvokeId(), "Wrong invoke ID"); assertNull(i.getLinkedId(), "Linked ID is not null"); assertNotNull(i.getOperationCode(), "Operation code is null"); assertNotNull(i.getParameter(), "Parameter null"); OperationCode oc = i.getOperationCode(); assertEquals(OperationCodeType.Local, oc.getOperationType(), "Wrong operation type"); assertEquals(new Long(42), oc.getLocalOperationCode(), "Wrong operation code"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } @Test(groups = { "functional.encode", "functional.decode" }) public void testTCContinueMessage_No_Dialog() throws IOException, EncodeException, ParseException { // no idea how to check rest...? // created by hand byte[] b = new byte[] { // TCContinue 0x65, 71, // org txid // OrigTran ID (full)............ 145031169 0x48, 0x04, 0x08, (byte) 0xA5, 0, 0x01, // dtx // DestTran ID (full)............ 144965633 0x49, 4, 8, (byte) 0xA4, 0, 1, // dialog portion // empty // comp portion 0x6C, 57, // invoke (byte) 0xA1, 6, // invoke ID 0x02, 0x01, 0x01, // op code 0x02, 0x01, 0x37, // return result last (byte) 0xA2, 47, // inoke id 0x02, 0x01, 0x02, // sequence start 0x30, 42, // local operation 0x02, 0x02, 0x00, (byte) 0xFF, // parameter 0x30, 36, (byte) 0xA0,// some tag.1 17, (byte) 0x80,// some tag.1.1 2, 0x11, 0x11, (byte) 0xA1,// some tag.1.2 04, (byte) 0x82, // some tag.1.3 ? 2, 0x00, 0x00, (byte) 0x82, // some tag.1.4 1, 12, (byte) 0x83, // some tag.1.5 2, 0x33, 0x33, (byte) 0xA1,// some trash here // tension indicator 2........ ??? // use value.................. ??? // some tag.2 3, (byte) 0x80,// some tag.2.1 1, -1, (byte) 0xA2, // some tag.3 3, (byte) 0x80,// some tag.3.1 1, -1, (byte) 0xA3,// some tag.4 5, (byte) 0x82,// some tag.4.1 3, (byte) 0xAB,// - 85 serviceKey................... 123456 // dont care about this content, lets just make len // correct (byte) 0xCD, (byte) 0xEF }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCContinue"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); assertNull(tcm.getDialogPortion(), "Dialog portion should not be present"); // assertEquals(144965633L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA4, 0, 1, }), "Destination transaction id does not match"); // comp portion assertNotNull(tcm.getComponent(), "Component portion should be present"); assertEquals(2, tcm.getComponent().length, "Component count is wrong"); Component c = tcm.getComponent()[0]; assertEquals(ComponentType.Invoke, c.getType(), "Wrong component type"); Invoke i = (Invoke) c; assertEquals(new Long(1), i.getInvokeId(), "Wrong invoke ID"); assertNull(i.getLinkedId(), "Linked ID is not null"); c = tcm.getComponent()[1]; assertEquals(ComponentType.ReturnResultLast, c.getType(), "Wrong component type"); ReturnResultLast rrl = (ReturnResultLast) c; assertEquals(new Long(2), rrl.getInvokeId(), "Wrong invoke ID"); assertNotNull(rrl.getOperationCode(), "Operation code should not be null"); OperationCode ocs = rrl.getOperationCode(); assertEquals(OperationCodeType.Local, ocs.getOperationType(), "Wrong Operation Code type"); assertEquals(new Long(0x00FF), ocs.getLocalOperationCode(), "Wrong Operation Code"); assertNotNull(rrl.getParameter(), "Parameter should not be null"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } @Test(groups = { "functional.encode", "functional.decode" }) public void testTCContinueMessage_No_Component() throws IOException, EncodeException, ParseException { // created by hand byte[] b = new byte[] { // TCContinue 0x65, 56, // org txid // OrigTran ID (full)............ 145031169 0x48, 0x04, 0x08, (byte) 0xA5, 0, 0x01, // didTx // DstTran ID (full)............ 145031169 0x49, 4, 8, (byte) 0xA5, 0, 1, // dialog portion 0x6B, 42, // extrnal tag 0x28, 40, // oid 0x06, 7, 0, 17, (byte) 134, 5, 1, 1, 1, (byte) 160, // asn 29, 0x61, // dialog response 27, // protocol version (byte) 0x80, // protocol version 2, 7, (byte) 0x80, (byte) 161,// acn 9, // oid 6, 7, 4, 0, 1, 1, 1, 3, 0, // result (byte) 0xA2, 0x03, 0x2, 0x1, (byte) 0x0, // result source diagnostic (byte) 0xA3, 5, (byte) 0x0A2, // provider 3, 0x02,// int 2 0x01, (byte) 0x2 // no user info? }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCContinue"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); assertNull(tcm.getComponent(), "Component portion should not be present"); assertNotNull(tcm.getDialogPortion(), "Dialog portion should not be null"); // assertEquals(145031169L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA5, 0, 1, }), "Destination transaction id does not match"); assertFalse(tcm.getDialogPortion().isUnidirectional(), "Dialog should not be Uni"); DialogAPDU _dapd = tcm.getDialogPortion().getDialogAPDU(); assertEquals(DialogAPDUType.Response, _dapd.getType(), "Wrong dialog APDU type!"); DialogResponseAPDU dapd = (DialogResponseAPDU) _dapd; // check nulls first assertNull(dapd.getUserInformation(), "UserInformation should not be present"); // not nulls assertNotNull(dapd.getResult(), "Result should not be null"); Result r = dapd.getResult(); assertEquals(ResultType.Accepted, r.getResultType(), "Wrong result"); assertNotNull(dapd.getResultSourceDiagnostic(), "Result Source Diagnostic should not be null"); ResultSourceDiagnostic rsd = dapd.getResultSourceDiagnostic(); assertNull(rsd.getDialogServiceUserType(), "User diagnostic should not be present"); assertEquals(DialogServiceProviderType.NoCommonDialogPortion, rsd.getDialogServiceProviderType(), "Wrong provider diagnostic type"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } @Test(groups = { "functional.encode", "functional.decode" }) public void testTCContinueMessage_No_Nothing() throws IOException, EncodeException, ParseException { // no idea how to check rest...? // created by hand byte[] b = new byte[] { // TCContinue 0x65, 12, // org txid // OrigTran ID (full)............ 145031169 0x48, 0x04, 0x08, (byte) 0xA5, 0, 0x01, // didTx // DEstTran ID (full)............ 145031169 0x49, 4, 8, (byte) 0xA5, 0, 1, }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCContinue"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); assertNull(tcm.getDialogPortion(), "Dialog portion should be null"); assertNull(tcm.getComponent(), "Component portion should not be present"); // assertEquals(145031169L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA5, 0, 1, }), "Destination transaction id does not match"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } @Test public void testTCContinueMessage_All() throws IOException, EncodeException, ParseException { // no idea how to check rest...? // created by hand byte[] b = new byte[] { // TCContinue 0x65, 114, // org txid // OrigTran ID (full)............ 145031169 0x48, 0x04, 0x08, (byte) 0xA5, 0, 0x01, // dtx // DestTran ID (full)............ 144965633 0x49, 4, 8, (byte) 0xA4, 0, 1, // dialog portion 0x6B, 42, // extrnal tag 0x28, 40, // oid 0x06, 7, 0, 17, (byte) 134, 5, 1, 1, 1, (byte) 160, // asn 29, 0x61, // dialog response 27, // protocol version (byte) 0x80, // protocol version 2, 7, (byte) 0x80, (byte) 161,// acn 9, // oid 6, 7, 4, 0, 1, 1, 1, 3, 0, // result (byte) 0xA2, 0x03, 0x2, 0x1, (byte) 0x01, // result source diagnostic (byte) 0xA3, 5, (byte) 0x0A2, // provider 3, 0x02,// int 2 0x01, (byte) 0x00, // no user info? // comp portion 0x6C, 56, // invoke (byte) 0xA1, 6, // invoke ID 0x02, 0x01, 0x01, // op code 0x02, 0x01, 0x37, // return result last (byte) 0xA2, 46, // inoke id 0x02, 0x01, 0x02, // sequence start 0x30, 41, // local operation 0x02, 0x01, 0x01, // parameter 0x30, 36, (byte) 0xA0,// some tag.1 17, (byte) 0x80,// some tag.1.1 2, 0x11, 0x11, (byte) 0xA1,// some tag.1.2 04, (byte) 0x82, // some tag.1.3 ? 2, 0x00, 0x00, (byte) 0x82, // some tag.1.4 1, 12, (byte) 0x83, // some tag.1.5 2, 0x33, 0x33, (byte) 0xA1,// some trash here // tension indicator 2........ ??? // use value.................. ??? // some tag.2 3, (byte) 0x80,// some tag.2.1 1, -1, (byte) 0xA2, // some tag.3 3, (byte) 0x80,// some tag.3.1 1, -1, (byte) 0xA3,// some tag.4 5, (byte) 0x82,// some tag.4.1 3, (byte) 0xAB,// - 85 serviceKey................... 123456 // dont care about this content, lets just make len // correct (byte) 0xCD, (byte) 0xEF }; AsnInputStream ais = new AsnInputStream(b); int tag = ais.readTag(); assertEquals(TCContinueMessage._TAG, tag, "Expected TCContinue"); TCContinueMessage tcm = TcapFactory.createTCContinueMessage(ais); // universal // assertEquals(144965633L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); // assertEquals(145031169L, tcm.getOriginatingTransactionId(),"Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getOriginatingTransactionId(), new byte[] { 0x08, (byte) 0xA5, 0, 0x01, }), "Originating transaction id does not match"); assertTrue(Arrays.equals(tcm.getDestinationTransactionId(), new byte[] { 8, (byte) 0xA4, 0, 1, }), "Destination transaction id does not match"); // dialog portion assertNotNull(tcm.getDialogPortion(), "Dialog portion should not be null"); // assertEquals(144965633L, tcm.getDestinationTransactionId(),"Destination transaction id does not match"); assertFalse(tcm.getDialogPortion().isUnidirectional(), "Dialog should not be Uni"); DialogAPDU _dapd = tcm.getDialogPortion().getDialogAPDU(); assertEquals(DialogAPDUType.Response, _dapd.getType(), "Wrong dialog APDU type!"); DialogResponseAPDU dapd = (DialogResponseAPDU) _dapd; // check nulls first assertNull(dapd.getUserInformation(), "UserInformation should not be present"); // not nulls assertNotNull(dapd.getResult(), "Result should not be null"); Result r = dapd.getResult(); assertEquals(ResultType.RejectedPermanent, r.getResultType(), "Wrong result"); assertNotNull(dapd.getResultSourceDiagnostic(), "Result Source Diagnostic should not be null"); ResultSourceDiagnostic rsd = dapd.getResultSourceDiagnostic(); assertNull(rsd.getDialogServiceUserType(), "User diagnostic should not be present"); assertEquals(DialogServiceProviderType.Null, rsd.getDialogServiceProviderType(), "Wrong provider diagnostic type"); // comp portion assertNotNull(tcm.getComponent(), "Component portion should be present"); assertEquals(2, tcm.getComponent().length, "Component count is wrong"); Component c = tcm.getComponent()[0]; assertEquals(ComponentType.Invoke, c.getType(), "Wrong component type"); Invoke i = (Invoke) c; assertEquals(new Long(1), i.getInvokeId(), "Wrong invoke ID"); assertNull(i.getLinkedId(), "Linked ID is not null"); c = tcm.getComponent()[1]; assertEquals(ComponentType.ReturnResultLast, c.getType(), "Wrong component type"); ReturnResultLast rrl = (ReturnResultLast) c; assertEquals(new Long(2), rrl.getInvokeId(), "Wrong invoke ID"); assertNotNull(rrl.getOperationCode(), "Operation code should not be null"); OperationCode ocs = rrl.getOperationCode(); assertEquals(OperationCodeType.Local, ocs.getOperationType(), "Wrong Operation Code type"); assertEquals(new Long(1), ocs.getLocalOperationCode(), "Wrong Operation Code"); assertNotNull(rrl.getParameter(), "Parameter should not be null"); AsnOutputStream aos = new AsnOutputStream(); tcm.encode(aos); byte[] encoded = aos.toByteArray(); TCAPTestUtils.compareArrays(b, encoded); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.tcap.asn.comp; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.tcap.asn.DialogPortion; import org.restcomm.protocols.ss7.tcap.asn.Encodable; /** * @author baranowb * */ public interface TCContinueMessage extends Encodable { int _TAG = 0x05; boolean _TAG_PC_PRIMITIVE = false; int _TAG_CLASS = Tag.CLASS_APPLICATION; int _TAG_OTX = 0x08; boolean _TAG_OTX_PC_PRIMITIVE = true; int _TAG_CLASS_OTX = Tag.CLASS_APPLICATION; int _TAG_DTX = 0x09; boolean _TAG_DTX_PC_PRIMITIVE = true; int _TAG_CLASS_DTX = Tag.CLASS_APPLICATION; // mandatory byte[] getOriginatingTransactionId(); void setOriginatingTransactionId(byte[] t); byte[] getDestinationTransactionId(); void setDestinationTransactionId(byte[] t); // opt FIXME: make this External? DialogPortion getDialogPortion(); void setDialogPortion(DialogPortion dp); // opt Component[] getComponent(); void setComponent(Component[] c); } ```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.InformationRequestIndicatorsImpl; import org.testng.annotations.Test; /** * Start time:11:34:01 2009-04-24<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class InformationRequestIndicatorsTest extends ParameterHarness { private static final int _TURN_ON = 1; private static final int _TURN_OFF = 0; public InformationRequestIndicatorsTest() { super(); // super.goodBodies.add(new byte[] { 67, 12 }); // super.badBodies.add(new byte[3]); // super.badBodies.add(new byte[1]); } private byte[] getBody(boolean callingPartAddressRequestIndicator, boolean holdingIndicator, boolean callingpartysCategoryRequestIndicator, boolean chargeInformationRequestIndicator, boolean maliciousCallIdentificationRequestIndicator, int reserved) { int b0 = 0; int b1 = 0; b0 |= callingPartAddressRequestIndicator ? _TURN_ON : _TURN_OFF; b0 |= (holdingIndicator ? _TURN_ON : _TURN_OFF) << 1; b0 |= (callingpartysCategoryRequestIndicator ? _TURN_ON : _TURN_OFF) << 3; b0 |= (chargeInformationRequestIndicator ? _TURN_ON : _TURN_OFF) << 4; b0 |= (maliciousCallIdentificationRequestIndicator ? _TURN_ON : _TURN_OFF) << 7; b1 |= (reserved & 0x0F) << 4; return new byte[] { (byte) b0, (byte) b1 }; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws ParameterException { InformationRequestIndicatorsImpl eci = new InformationRequestIndicatorsImpl(getBody( InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, 10)); String[] methodNames = { "isCallingPartAddressRequestIndicator", "isHoldingIndicator", "isCallingPartysCategoryRequestIndicator", "isChargeInformationRequestIndicator", "isMaliciousCallIdentificationRequestIndicator", "getReserved" }; Object[] expectedValues = { InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, InformationRequestIndicatorsImpl._INDICATOR_NOT_REQUESTED, 10 }; super.testValues(eci, methodNames, expectedValues); } /* * (non-Javadoc) * * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent () */ public AbstractISUPParameter getTestedComponent() throws ParameterException { return new InformationRequestIndicatorsImpl(new byte[2]); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:13:17:28 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface InformationRequestIndicators extends ISUPParameter { int _PARAMETER_CODE = 0x0E; /** * Flag that indicates that information is requested */ boolean _INDICATOR_REQUESTED = true; /** * Flag that indicates that information is not requested */ boolean _INDICATOR_NOT_REQUESTED = false; boolean isCallingPartAddressRequestIndicator(); void setCallingPartAddressRequestIndicator(boolean callingPartAddressRequestIndicator); boolean isHoldingIndicator(); void setHoldingIndicator(boolean holdingIndicator); boolean isCallingPartysCategoryRequestIndicator(); void setCallingPartysCategoryRequestIndicator(boolean callingpartysCategoryRequestIndicator); boolean isChargeInformationRequestIndicator(); void setChargeInformationRequestIndicator(boolean chargeInformationRequestIndicator); boolean isMaliciousCallIdentificationRequestIndicator(); void setMaliciousCallIdentificationRequestIndicator(boolean maliciousCallIdentificationRequestIndicator); int getReserved(); void setReserved(int reserved); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.service.mobility.authentication.ReSynchronisationInfo; import org.restcomm.protocols.ss7.map.api.service.mobility.authentication.RequestingNodeType; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.PlmnIdImpl; import org.restcomm.protocols.ss7.map.service.mobility.authentication.ReSynchronisationInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.authentication.SendAuthenticationInfoRequestImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class SendAuthenticationInfoRequestTest { private byte[] getEncodedData() { return new byte[] { 48, 21, -128, 6, 17, 33, 34, 51, 67, 68, 2, 1, 4, -125, 1, 0, -124, 3, -71, -2, -59, -122, 0 }; } private byte[] getEncodedData2() { return new byte[] { 48, 57, -128, 6, 51, 51, 67, 68, 68, -12, 2, 1, 5, 5, 0, -127, 0, 48, 34, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 14, 2, 2, 2, 2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, -125, 1, 1, -123, 1, 6 }; } private byte[] getEncodedData_V2() { return new byte[] { 4, 8, 82, 0, 7, 34, 2, 35, 103, -9 }; } private byte[] getRequestingPlmnId() { return new byte[] { (byte) 185, (byte) 254, (byte) 197 }; } @Test public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); SendAuthenticationInfoRequestImpl asc = new SendAuthenticationInfoRequestImpl(3); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 3); IMSI imsi = asc.getImsi(); assertTrue(imsi.getData().equals("111222333444")); assertEquals(asc.getRequestingNodeType(), RequestingNodeType.vlr); assertEquals(asc.getNumberOfRequestedVectors(), 4); assertNotNull(asc.getRequestingPlmnId()); assertTrue(Arrays.equals(asc.getRequestingPlmnId().getData(), getRequestingPlmnId())); assertNull(asc.getReSynchronisationInfo()); assertNull(asc.getExtensionContainer()); assertNull(asc.getNumberOfRequestedAdditionalVectors()); assertFalse(asc.getSegmentationProhibited()); assertFalse(asc.getImmediateResponsePreferred()); assertTrue(asc.getAdditionalVectorsAreForEPS()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new SendAuthenticationInfoRequestImpl(3); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getMapProtocolVersion(), 3); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("33333444444")); assertEquals(asc.getRequestingNodeType(), RequestingNodeType.sgsn); assertEquals(asc.getNumberOfRequestedVectors(), 5); assertNull(asc.getRequestingPlmnId()); ReSynchronisationInfo rsi = asc.getReSynchronisationInfo(); assertTrue(Arrays.equals(rsi.getRand(), ReSynchronisationInfoTest.getRandData())); assertTrue(Arrays.equals(rsi.getAuts(), ReSynchronisationInfoTest.getAutsData())); assertNull(asc.getExtensionContainer()); assertEquals((int) asc.getNumberOfRequestedAdditionalVectors(), 6); assertTrue(asc.getSegmentationProhibited()); assertTrue(asc.getImmediateResponsePreferred()); assertFalse(asc.getAdditionalVectorsAreForEPS()); rawData = getEncodedData_V2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new SendAuthenticationInfoRequestImpl(2); asc.decodeAll(asn); assertEquals(asc.getMapProtocolVersion(), 2); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); imsi = asc.getImsi(); assertTrue(imsi.getData().equals("250070222032767")); assertNull(asc.getRequestingNodeType()); assertEquals(asc.getNumberOfRequestedVectors(), 0); assertNull(asc.getRequestingPlmnId()); assertNull(asc.getReSynchronisationInfo()); assertNull(asc.getExtensionContainer()); assertNull(asc.getNumberOfRequestedAdditionalVectors()); assertFalse(asc.getSegmentationProhibited()); assertFalse(asc.getImmediateResponsePreferred()); assertFalse(asc.getAdditionalVectorsAreForEPS()); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { IMSIImpl imsi = new IMSIImpl("111222333444"); PlmnIdImpl plmnId = new PlmnIdImpl(getRequestingPlmnId()); SendAuthenticationInfoRequestImpl asc = new SendAuthenticationInfoRequestImpl(3, imsi, 4, false, false, null, null, RequestingNodeType.vlr, plmnId, null, true); // long mapProtocolVersion, IMSI imsi, int numberOfRequestedVectors, boolean segmentationProhibited, // boolean immediateResponsePreferred, ReSynchronisationInfo reSynchronisationInfo, MAPExtensionContainer // extensionContainer, // RequestingNodeType requestingNodeType, PlmnId requestingPlmnId, Integer numberOfRequestedAdditionalVectors, boolean // additionalVectorsAreForEPS AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); imsi = new IMSIImpl("33333444444"); ReSynchronisationInfoImpl rsi = new ReSynchronisationInfoImpl(ReSynchronisationInfoTest.getRandData(), ReSynchronisationInfoTest.getAutsData()); asc = new SendAuthenticationInfoRequestImpl(3, imsi, 5, true, true, rsi, null, RequestingNodeType.sgsn, null, 6, false); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); imsi = new IMSIImpl("250070222032767"); asc = new SendAuthenticationInfoRequestImpl(2, imsi, 0, false, false, null, null, null, null, null, false); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData_V2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.PlmnId; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * MAP V2-3: * * MAP V3: sendAuthenticationInfo OPERATION ::= { --Timer m ARGUMENT SendAuthenticationInfoArg -- optional -- within a dialogue * sendAuthenticationInfoArg shall not be present in -- subsequent invoke components. If received in a subsequent invoke * component -- it shall be discarded. * * RESULT SendAuthenticationInfoRes -- optional ERRORS { systemFailure | dataMissing | unexpectedDataValue | unknownSubscriber} * CODE local:56 } * * MAP V2: SendAuthenticationInfo ::= OPERATION --Timer m ARGUMENT sendAuthenticationInfoArg SendAuthenticationInfoArg RESULT * sendAuthenticationInfoRes SendAuthenticationInfoRes -- optional ERRORS { SystemFailure, DataMissing, UnexpectedDataValue, * UnknownSubscriber} * * * MAP V3: SendAuthenticationInfoArg ::= SEQUENCE { imsi [0] IMSI, numberOfRequestedVectors NumberOfRequestedVectors, * segmentationProhibited NULL OPTIONAL, immediateResponsePreferred [1] NULL OPTIONAL, re-synchronisationInfo * Re-synchronisationInfo OPTIONAL, extensionContainer [2] ExtensionContainer OPTIONAL, ..., requestingNodeType [3] * RequestingNodeType OPTIONAL, requestingPLMN-Id [4] PLMN-Id OPTIONAL, numberOfRequestedAdditional-Vectors [5] * NumberOfRequestedVectors OPTIONAL, additionalVectorsAreForEPS [6] NULL OPTIONAL } * * MAP V2: SendAuthenticationInfoArg ::= IMSI * * NumberOfRequestedVectors ::= INTEGER (1..5) * * * @author sergey vetyutnev * */ public interface SendAuthenticationInfoRequest extends MobilityMessage { IMSI getImsi(); int getNumberOfRequestedVectors(); boolean getSegmentationProhibited(); boolean getImmediateResponsePreferred(); ReSynchronisationInfo getReSynchronisationInfo(); MAPExtensionContainer getExtensionContainer(); RequestingNodeType getRequestingNodeType(); PlmnId getRequestingPlmnId(); Integer getNumberOfRequestedAdditionalVectors(); boolean getAdditionalVectorsAreForEPS(); long getMapProtocolVersion(); } ```
```package org.restcomm.protocols.ss7.cap.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.RPCause; import org.restcomm.protocols.ss7.cap.service.sms.ReleaseSMSRequestImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.RPCauseImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ReleaseSMSRequestTest { public byte[] getData() { return new byte[] {4, 1, 3 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ReleaseSMSRequestImpl prim = new ReleaseSMSRequestImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getRPCause().getData(), 3); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { RPCause rpCause = new RPCauseImpl(3); ReleaseSMSRequestImpl prim = new ReleaseSMSRequestImpl(rpCause); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.RPCause; /** * releaseSMS OPERATION ::= { ARGUMENT ReleaseSMSArg RETURN RESULT FALSE ALWAYS RESPONDS FALSE CODE opcode-releaseSMS} -- * Direction: gsmSCF -> gsmSSF or gprsSSF, Timer: Trelsms -- This operation is used to prevent an attempt to submit or deliver a * short message. * * ReleaseSMSArg ::= RPCause * * * * @author sergey vetyutnev * */ public interface ReleaseSMSRequest extends SmsMessage { RPCause getRPCause(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.Arrays; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.RangeAndStatusImpl; import org.testng.annotations.Test; /** * Start time:14:11:03 2009-04-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class RangeAndStatusTest extends ParameterHarness { /** * @throws IOException */ public RangeAndStatusTest() throws IOException { // super.badBodies.add(new byte[0]); } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException { RangeAndStatusImpl bci = new RangeAndStatusImpl(getBody((byte) 12, new byte[] { 0x0F, 0x04 })); // not a best here. ech. String[] methodNames = { "getRange", "getStatus", }; Object[] expectedValues = { (byte) 12, new byte[] { 0x0F, 0x04 } }; super.testValues(bci, methodNames, expectedValues); } @Test(groups = { "functional.flags", "parameter" }) public void testAffectedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException { RangeAndStatusImpl bci = new RangeAndStatusImpl(getBody((byte) 12, new byte[] { 0x0F, 0x04 })); assertEquals((byte) 12, bci.getRange()); assertTrue(bci.isAffected((byte) 0)); assertTrue(bci.isAffected((byte) 1)); assertTrue(bci.isAffected((byte) 2)); assertTrue(bci.isAffected((byte) 3)); assertTrue(!bci.isAffected((byte) 4)); assertTrue(!bci.isAffected((byte) 5)); assertTrue(!bci.isAffected((byte) 6)); assertTrue(!bci.isAffected((byte) 7)); assertTrue(!bci.isAffected((byte) 8)); assertTrue(!bci.isAffected((byte) 9)); assertTrue(bci.isAffected((byte) 10)); bci.setAffected((byte) 9, true); bci.setAffected((byte) 10, false); assertTrue(!bci.isAffected((byte) 10)); assertTrue(bci.isAffected((byte) 9)); byte[] stat = bci.getStatus(); assertTrue(Arrays.equals(new byte[] { 0x0F, 0x02 }, stat)); } private byte[] getBody(byte rannge, byte[] enabled) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bos.write(rannge); bos.write(enabled); return bos.toByteArray(); } /* * (non-Javadoc) * * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent () */ public AbstractISUPParameter getTestedComponent() { return new RangeAndStatusImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:13:52:59 2009-07-23<br> * Project: mobicents-isup-stack<br> * This RangeAndStatus indiactes whcih CICs, starting from one present in message are affected. Range indicates how many CICs * are potentially affected. Status contains bits indicating CIC affected(1 - affected, 0 - not affected) <br> * For content interpretation refer to Q.763 3.43 * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface RangeAndStatus extends ISUPParameter { int _PARAMETER_CODE = 0x16; /** * Fetches range. * * @return */ byte getRange(); /** * Sets range. * * @param range * @param addStatus - flag indicates if implementation should create proper status */ void setRange(byte range, boolean addStatus); /** * Sets range. * * @param range */ void setRange(byte range); /** * Gets raw status part. * * @return */ byte[] getStatus(); /** * Gets raw status part. * * @return */ void setStatus(byte[] status); void setAffected(byte subrange, boolean v) throws IllegalArgumentException; boolean isAffected(byte b) throws IllegalArgumentException; } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.FTNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNSubaddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGFeature; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGInfo; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGInterlock; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.CUGSubscription; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.EMLPPInfo; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtBasicServiceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtCallBarInfo; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtCallBarringFeature; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwFeature; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwInfo; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwOptions; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwOptionsForwardingReason; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtSSData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.InterCUGRestrictions; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.IntraCUGOptions; import org.restcomm.protocols.ss7.map.api.service.supplementary.CliRestrictionOption; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSSubscriptionOption; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.primitives.FTNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNSubaddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGInterlockImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGSubscriptionImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.EMLPPInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBasicServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtCallBarInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtCallBarringFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtForwFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtForwInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtForwOptionsImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSStatusImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.InterCUGRestrictionsImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSSubscriptionOptionImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ExtSSInfoTest { public byte[] getData() { return new byte[] { -96, 117, 4, 1, 0, 48, 71, 48, 69, -126, 1, 38, -124, 1, 3, -123, 4, -111, 34, 34, -8, -120, 2, 2, 5, -122, 1, -92, -121, 1, 2, -87, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -118, 4, -111, 34, 34, -9, -96, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getData1() { return new byte[] { -95, 95, 4, 1, 0, 48, 49, 48, 47, -126, 1, 38, -124, 1, 3, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getData2() { return new byte[] { -94, -127, -99, 48, 60, 48, 58, 2, 1, 1, 4, 4, 1, 2, 3, 4, 10, 1, 0, 48, 3, -126, 1, 38, -96, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 48, 52, 48, 50, -126, 1, 38, 2, 1, 1, 4, 1, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -96, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getData3() { return new byte[] { -93, 55, 4, 1, 0, -124, 1, 3, -126, 1, 0, 48, 3, -126, 1, 38, -91, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getData4() { return new byte[] { -92, 47, 2, 1, 2, 2, 1, 1, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; private byte[] getISDNSubaddressStringData() { return new byte[] { 2, 5 }; } private byte[] getcugData() { return new byte[] { 1, 2, 3, 4 }; } @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // option 1 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ExtSSInfoImpl prim = new ExtSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, ExtSSInfoImpl._TAG_forwardingInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); ExtForwInfo forwardingInfo = prim.getForwardingInfo(); ExtCallBarInfo callBarringInfo = prim.getCallBarringInfo(); CUGInfo cugInfo = prim.getCugInfo(); ExtSSData ssData = prim.getSsData(); EMLPPInfo emlppInfo = prim.getEmlppInfo(); assertNotNull(forwardingInfo); assertNull(callBarringInfo); assertNull(cugInfo); assertNull(ssData); assertNull(emlppInfo); MAPExtensionContainer extensionContainer = forwardingInfo.getExtensionContainer(); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); assertEquals(forwardingInfo.getSsCode().getSupplementaryCodeValue(), SupplementaryCodeValue.allSS); ArrayList<ExtForwFeature> forwardingFeatureList = forwardingInfo.getForwardingFeatureList(); ; assertNotNull(forwardingFeatureList); assertEquals(forwardingFeatureList.size(), 1); ExtForwFeature extForwFeature = forwardingFeatureList.get(0); assertNotNull(extForwFeature); assertEquals(extForwFeature.getBasicService().getExtBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); assertNull(extForwFeature.getBasicService().getExtTeleservice()); assertNotNull(extForwFeature.getSsStatus()); assertTrue(extForwFeature.getSsStatus().getBitA()); assertTrue(!extForwFeature.getSsStatus().getBitP()); assertTrue(!extForwFeature.getSsStatus().getBitQ()); assertTrue(extForwFeature.getSsStatus().getBitR()); ISDNAddressString forwardedToNumber = extForwFeature.getForwardedToNumber(); assertNotNull(forwardedToNumber); assertTrue(forwardedToNumber.getAddress().equals("22228")); assertEquals(forwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(forwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertTrue(Arrays.equals(extForwFeature.getForwardedToSubaddress().getData(), this.getISDNSubaddressStringData())); assertTrue(extForwFeature.getForwardingOptions().getNotificationToCallingParty()); assertTrue(extForwFeature.getForwardingOptions().getNotificationToForwardingParty()); assertTrue(!extForwFeature.getForwardingOptions().getRedirectingPresentation()); assertEquals(extForwFeature.getForwardingOptions().getExtForwOptionsForwardingReason(), ExtForwOptionsForwardingReason.msBusy); assertNotNull(extForwFeature.getNoReplyConditionTime()); assertEquals(extForwFeature.getNoReplyConditionTime().intValue(), 2); FTNAddressString longForwardedToNumber = extForwFeature.getLongForwardedToNumber(); assertNotNull(longForwardedToNumber); assertTrue(longForwardedToNumber.getAddress().equals("22227")); assertEquals(longForwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(longForwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); // option 2 data = this.getData1(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, ExtSSInfoImpl._TAG_callBarringInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); forwardingInfo = prim.getForwardingInfo(); callBarringInfo = prim.getCallBarringInfo(); cugInfo = prim.getCugInfo(); ssData = prim.getSsData(); emlppInfo = prim.getEmlppInfo(); assertNull(forwardingInfo); assertNotNull(callBarringInfo); assertNull(cugInfo); assertNull(ssData); assertNull(emlppInfo); extensionContainer = callBarringInfo.getExtensionContainer(); assertEquals(callBarringInfo.getSsCode().getSupplementaryCodeValue(), SupplementaryCodeValue.allSS); assertNotNull(callBarringInfo.getCallBarringFeatureList()); assertEquals(callBarringInfo.getCallBarringFeatureList().size(), 1); assertNotNull(callBarringInfo.getCallBarringFeatureList().get(0)); assertNotNull(extensionContainer); // option 3 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, ExtSSInfoImpl._TAG_cugInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); forwardingInfo = prim.getForwardingInfo(); callBarringInfo = prim.getCallBarringInfo(); cugInfo = prim.getCugInfo(); ssData = prim.getSsData(); emlppInfo = prim.getEmlppInfo(); assertNull(forwardingInfo); assertNull(callBarringInfo); assertNotNull(cugInfo); assertNull(ssData); assertNull(emlppInfo); extensionContainer = cugInfo.getExtensionContainer(); assertNotNull(cugInfo.getCUGSubscriptionList()); assertEquals(cugInfo.getCUGSubscriptionList().size(), 1); assertNotNull(cugInfo.getCUGSubscriptionList().get(0)); assertNotNull(cugInfo.getCUGFeatureList()); assertEquals(cugInfo.getCUGFeatureList().size(), 1); assertNotNull(cugInfo.getCUGFeatureList().get(0)); assertNotNull(extensionContainer); // option 4 data = this.getData3(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, ExtSSInfoImpl._TAG_ssData); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); forwardingInfo = prim.getForwardingInfo(); callBarringInfo = prim.getCallBarringInfo(); cugInfo = prim.getCugInfo(); ssData = prim.getSsData(); emlppInfo = prim.getEmlppInfo(); assertNull(forwardingInfo); assertNull(callBarringInfo); assertNull(cugInfo); assertNotNull(ssData); assertNull(emlppInfo); extensionContainer = ssData.getExtensionContainer(); assertEquals(ssData.getSsCode().getSupplementaryCodeValue(), SupplementaryCodeValue.allSS); assertNotNull(ssData.getSsStatus()); assertTrue(ssData.getSsStatus().getBitA()); assertTrue(!ssData.getSsStatus().getBitP()); assertTrue(!ssData.getSsStatus().getBitQ()); assertTrue(ssData.getSsStatus().getBitR()); assertNotNull(ssData.getSSSubscriptionOption()); assertNotNull(ssData.getSSSubscriptionOption().getCliRestrictionOption()); assertEquals(ssData.getSSSubscriptionOption().getCliRestrictionOption(), CliRestrictionOption.permanent); assertNull(ssData.getSSSubscriptionOption().getOverrideCategory()); assertNotNull(extensionContainer); // option 5 data = this.getData4(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ExtSSInfoImpl(); prim.decodeAll(asn); assertEquals(tag, ExtSSInfoImpl._TAG_emlppInfo); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); forwardingInfo = prim.getForwardingInfo(); callBarringInfo = prim.getCallBarringInfo(); cugInfo = prim.getCugInfo(); ssData = prim.getSsData(); emlppInfo = prim.getEmlppInfo(); assertNull(forwardingInfo); assertNull(callBarringInfo); assertNull(cugInfo); assertNull(ssData); assertNotNull(emlppInfo); extensionContainer = emlppInfo.getExtensionContainer(); assertEquals(emlppInfo.getMaximumentitledPriority(), 2); assertEquals(emlppInfo.getDefaultPriority(), 1); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { ExtBearerServiceCodeImpl b = new ExtBearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); ExtBasicServiceCodeImpl basicService = new ExtBasicServiceCodeImpl(b); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); ExtSSStatusImpl ssStatus = new ExtSSStatusImpl(false, false, true, true); ISDNAddressString forwardedToNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22228"); ISDNSubaddressString forwardedToSubaddress = new ISDNSubaddressStringImpl(this.getISDNSubaddressStringData()); ExtForwOptions forwardingOptions = new ExtForwOptionsImpl(true, false, true, ExtForwOptionsForwardingReason.msBusy); Integer noReplyConditionTime = new Integer(2); FTNAddressString longForwardedToNumber = new FTNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22227"); ExtForwFeatureImpl extForwFeature = new ExtForwFeatureImpl(basicService, ssStatus, forwardedToNumber, forwardedToSubaddress, forwardingOptions, noReplyConditionTime, extensionContainer, longForwardedToNumber); SSCode ssCode = new SSCodeImpl(SupplementaryCodeValue.allSS); ArrayList<ExtForwFeature> forwardingFeatureList = new ArrayList<ExtForwFeature>(); forwardingFeatureList.add(extForwFeature); ExtForwInfo forwardingInfo = new ExtForwInfoImpl(ssCode, forwardingFeatureList, extensionContainer); ExtCallBarringFeatureImpl callBarringFeature = new ExtCallBarringFeatureImpl(basicService, ssStatus, extensionContainer); ArrayList<ExtCallBarringFeature> callBarringFeatureList = new ArrayList<ExtCallBarringFeature>(); callBarringFeatureList.add(callBarringFeature); ExtCallBarInfo callBarringInfo = new ExtCallBarInfoImpl(ssCode, callBarringFeatureList, extensionContainer); Integer preferentialCugIndicator = new Integer(1); InterCUGRestrictions interCugRestrictions = new InterCUGRestrictionsImpl(0); CUGFeatureImpl cugFeature = new CUGFeatureImpl(basicService, preferentialCugIndicator, interCugRestrictions, extensionContainer); ArrayList<CUGFeature> cugFeatureList = new ArrayList<CUGFeature>(); cugFeatureList.add(cugFeature); ArrayList<CUGSubscription> cugSubscriptionList = new ArrayList<CUGSubscription>(); int cugIndex = 1; CUGInterlock cugInterlock = new CUGInterlockImpl(getcugData()); IntraCUGOptions intraCugOptions = IntraCUGOptions.getInstance(0); ArrayList<ExtBasicServiceCode> basicServiceList = new ArrayList<ExtBasicServiceCode>(); basicServiceList.add(basicService); CUGSubscriptionImpl cugSubscription = new CUGSubscriptionImpl(cugIndex, cugInterlock, intraCugOptions, basicServiceList, extensionContainer); cugSubscriptionList.add(cugSubscription); CUGInfoImpl cugInfo = new CUGInfoImpl(cugSubscriptionList, cugFeatureList, extensionContainer); SSSubscriptionOption ssSubscriptionOption = new SSSubscriptionOptionImpl(CliRestrictionOption.permanent); ArrayList<ExtBasicServiceCode> basicServiceGroupList = new ArrayList<ExtBasicServiceCode>(); basicServiceGroupList.add(basicService); ExtSSData ssData = new ExtSSDataImpl(ssCode, ssStatus, ssSubscriptionOption, basicServiceGroupList, extensionContainer); EMLPPInfoImpl emlppInfo = new EMLPPInfoImpl(2, 1, extensionContainer); // option 1 ExtSSInfoImpl prim = new ExtSSInfoImpl(forwardingInfo); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // option 2 prim = new ExtSSInfoImpl(callBarringInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); // option 3 prim = new ExtSSInfoImpl(cugInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); // option 4 prim = new ExtSSInfoImpl(ssData); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData3())); // option 5 prim = new ExtSSInfoImpl(emlppInfo); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData4())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * Ext-SS-Info ::= CHOICE { forwardingInfo [0] Ext-ForwInfo, callBarringInfo [1] Ext-CallBarInfo, cug-Info [2] CUG-Info, ss-Data * [3] Ext-SS-Data, emlpp-Info [4] EMLPP-Info} * * * * @author sergey vetyutnev * */ public interface ExtSSInfo extends Serializable { ExtForwInfo getForwardingInfo(); ExtCallBarInfo getCallBarringInfo(); CUGInfo getCugInfo(); ExtSSData getSsData(); EMLPPInfo getEmlppInfo(); } ```
```package org.restcomm.protocols.ss7.cap.EsiGprs; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.EsiGprs.DisconnectSpecificInformationImpl; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.InitiatingEntity; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class DisconnectSpecificInformationTest { public byte[] getData() { return new byte[] { -80, 5, -128, 1, 2, -127, 0 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); DisconnectSpecificInformationImpl prim = new DisconnectSpecificInformationImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertEquals(prim.getInitiatingEntity(), InitiatingEntity.hlr); assertTrue(prim.getRouteingAreaUpdate()); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { DisconnectSpecificInformationImpl prim = new DisconnectSpecificInformationImpl(InitiatingEntity.hlr, true); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.EsiGprs; import java.io.Serializable; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.InitiatingEntity; /** * disconnectSpecificInformation [3] SEQUENCE { initiatingEntity [0] InitiatingEntity OPTIONAL, ..., routeingAreaUpdate [1] NULL * OPTIONAL }, * * * @author sergey vetyutnev * */ public interface DisconnectSpecificInformation extends Serializable { InitiatingEntity getInitiatingEntity(); boolean getRouteingAreaUpdate(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.authentication.EpcAv; import org.restcomm.protocols.ss7.map.service.mobility.authentication.EpcAvImpl; import org.restcomm.protocols.ss7.map.service.mobility.authentication.EpsAuthenticationSetListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class EpsAuthenticationSetListTest { private byte[] getEncodedData() { return new byte[] { 48, -127, -98, 48, 76, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 2, 2, 2, 2, 4, 16, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 32, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 48, 78, 4, 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 6, 22, 22, 22, 22, 22, 22, 4, 16, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 32, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4 }; } static protected byte[] getXresData() { return new byte[] { 22, 22, 22, 22, 22, 22 }; } @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); EpsAuthenticationSetListImpl asc = new EpsAuthenticationSetListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ArrayList<EpcAv> epcAvs = asc.getEpcAv(); assertEquals(epcAvs.size(), 2); assertTrue(Arrays.equals(epcAvs.get(0).getRand(), EpcAvTest.getRandData())); assertTrue(Arrays.equals(epcAvs.get(0).getXres(), EpcAvTest.getXresData())); assertTrue(Arrays.equals(epcAvs.get(0).getAutn(), EpcAvTest.getAutnData())); assertTrue(Arrays.equals(epcAvs.get(0).getKasme(), EpcAvTest.getKasmeData())); assertTrue(Arrays.equals(epcAvs.get(1).getRand(), EpcAvTest.getRandData())); assertTrue(Arrays.equals(epcAvs.get(1).getXres(), getXresData())); assertTrue(Arrays.equals(epcAvs.get(1).getAutn(), EpcAvTest.getAutnData())); assertTrue(Arrays.equals(epcAvs.get(1).getKasme(), EpcAvTest.getKasmeData())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { EpcAvImpl d1 = new EpcAvImpl(EpcAvTest.getRandData(), EpcAvTest.getXresData(), EpcAvTest.getAutnData(), EpcAvTest.getKasmeData(), null); EpcAvImpl d2 = new EpcAvImpl(EpcAvTest.getRandData(), getXresData(), EpcAvTest.getAutnData(), EpcAvTest.getKasmeData(), null); ArrayList<EpcAv> arr = new ArrayList<EpcAv>(); arr.add(d1); arr.add(d2); EpsAuthenticationSetListImpl asc = new EpsAuthenticationSetListImpl(arr); AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import java.io.Serializable; import java.util.ArrayList; /** * EPS-AuthenticationSetList ::= SEQUENCE SIZE (1..5) OF EPC-AV * * * @author sergey vetyutnev * */ public interface EpsAuthenticationSetList extends Serializable { ArrayList<EpcAv> getEpcAv(); } ```
```package org.restcomm.protocols.ss7.cap.service.sms.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPProtocolIdentifierImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class TPProtocolIdentifierTest { public byte[] getData() { return new byte[] { 4, 1, 5 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); TPProtocolIdentifierImpl prim = new TPProtocolIdentifierImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getData(), 5); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { TPProtocolIdentifierImpl prim = new TPProtocolIdentifierImpl(5); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms.primitive; import java.io.Serializable; /** * TPProtocolIdentifier ::= OCTET STRING (SIZE (1)) -- indicates the protocol used above the SM-Transfer Layer as specified in * 3GPP TS 23.040 [6]. * * * @author sergey vetyutnev * */ public interface TPProtocolIdentifier extends Serializable { int getData(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ODBGeneralData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ODBHPLMNData; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.ODBInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ODBDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ODBGeneralDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ODBHPLMNDataImpl; import org.testng.annotations.Test; import java.util.Arrays; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; /** * @author vadim subbotin */ public class ODBInfoTest { private byte[] data = {48, 97, 48, 52, 3, 5, 3, -1, -4, 0, 0, 3, 2, 4, -96, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 5, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33}; @Test(groups = {"functional.decode", "subscriberInformation"}) public void testDecode() throws Exception { AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ODBInfoImpl odbInfo = new ODBInfoImpl(); odbInfo.decodeAll(asn); assertNotNull(odbInfo.getOdbData()); assertTrue(odbInfo.getNotificationToCSE()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(odbInfo.getExtensionContainer())); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(odbInfo.getOdbData().getExtensionContainer())); ODBGeneralData odbGeneralData = odbInfo.getOdbData().getODBGeneralData(); assertTrue(odbGeneralData.getAllOGCallsBarred()); assertTrue(odbGeneralData.getInternationalOGCallsBarred()); assertTrue(odbGeneralData.getInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsAndInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getPremiumRateInformationOGCallsBarred()); assertTrue(odbGeneralData.getPremiumRateEntertainementOGCallsBarred()); assertTrue(odbGeneralData.getSsAccessBarred()); assertTrue(odbGeneralData.getAllECTBarred()); assertTrue(odbGeneralData.getChargeableECTBarred()); assertTrue(odbGeneralData.getInternationalECTBarred()); assertTrue(odbGeneralData.getInterzonalECTBarred()); assertTrue(odbGeneralData.getDoublyChargeableECTBarred()); assertFalse(odbGeneralData.getMultipleECTBarred()); assertFalse(odbGeneralData.getAllPacketOrientedServicesBarred()); assertFalse(odbGeneralData.getRoamerAccessToHPLMNAPBarred()); assertFalse(odbGeneralData.getRoamerAccessToVPLMNAPBarred()); assertFalse(odbGeneralData.getRoamingOutsidePLMNOGCallsBarred()); assertFalse(odbGeneralData.getAllICCallsBarred()); assertFalse(odbGeneralData.getRoamingOutsidePLMNICCallsBarred()); assertFalse(odbGeneralData.getRoamingOutsidePLMNICountryICCallsBarred()); assertFalse(odbGeneralData.getRoamingOutsidePLMNBarred()); assertFalse(odbGeneralData.getRoamingOutsidePLMNCountryBarred()); assertFalse(odbGeneralData.getRegistrationAllCFBarred()); assertFalse(odbGeneralData.getRegistrationCFNotToHPLMNBarred()); assertFalse(odbGeneralData.getRegistrationInterzonalCFBarred()); assertFalse(odbGeneralData.getRegistrationInterzonalCFNotToHPLMNBarred()); assertFalse(odbGeneralData.getRegistrationInternationalCFBarred()); ODBHPLMNData odbhplmnData = odbInfo.getOdbData().getOdbHplmnData(); assertTrue(odbhplmnData.getPlmnSpecificBarringType1()); assertFalse(odbhplmnData.getPlmnSpecificBarringType2()); assertTrue(odbhplmnData.getPlmnSpecificBarringType3()); assertFalse(odbhplmnData.getPlmnSpecificBarringType4()); } @Test(groups = {"functional.encode", "subscriberInformation"}) public void testEncode() throws Exception { ODBGeneralDataImpl odbGeneralData = new ODBGeneralDataImpl(true, true, true, true, true, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false); ODBHPLMNDataImpl odbhplmnData = new ODBHPLMNDataImpl(true, false, true, false); ODBDataImpl odbData = new ODBDataImpl(odbGeneralData, odbhplmnData, MAPExtensionContainerTest.GetTestExtensionContainer()); ODBInfoImpl odbInfo = new ODBInfoImpl(odbData, true, MAPExtensionContainerTest.GetTestExtensionContainer()); AsnOutputStream asnOS = new AsnOutputStream(); odbInfo.encodeAll(asnOS); byte[] raw = asnOS.toByteArray(); assertTrue(Arrays.equals(raw, data)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ODBData; /** * <code> ODB-Info ::= SEQUENCE { odb-Data ODB-Data, notificationToCSE NULL OPTIONAL, extensionContainer ExtensionContainer OPTIONAL, ... } </code> * * * @author sergey vetyutnev * */ public interface ODBInfo extends Serializable { ODBData getOdbData(); boolean getNotificationToCSE(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.locationManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.PurgeMSRequestImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class PurgeMSRequestTest { public byte[] getData1() { return new byte[] { 48, 13, 4, 5, 17, 17, 33, 34, 34, 4, 4, -111, 34, 50, -12 }; }; public byte[] getData2() { return new byte[] { -93, 60, 4, 5, 17, 17, 33, 34, 34, -128, 4, -111, 34, 50, -12, -127, 4, -111, 34, 50, -11, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { // version 2 byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); PurgeMSRequestImpl prim = new PurgeMSRequestImpl(2); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(prim.getImsi().getData().equals("1111122222")); ISDNAddressString vlrNumber = prim.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22234")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); // version 3 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new PurgeMSRequestImpl(3); prim.decodeAll(asn); assertEquals(tag, PurgeMSRequestImpl._TAG_PurgeMSRequest); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(prim.getImsi().getData().equals("1111122222")); vlrNumber = prim.getVlrNumber(); assertTrue(vlrNumber.getAddress().equals("22234")); assertEquals(vlrNumber.getAddressNature(), AddressNature.international_number); assertEquals(vlrNumber.getNumberingPlan(), NumberingPlan.ISDN); ISDNAddressString sgsnNumber = prim.getSgsnNumber(); assertTrue(sgsnNumber.getAddress().equals("22235")); assertEquals(sgsnNumber.getAddressNature(), AddressNature.international_number); assertEquals(sgsnNumber.getNumberingPlan(), NumberingPlan.ISDN); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(prim.getExtensionContainer())); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { // version 2 ISDNAddressString vlrNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22234"); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); IMSIImpl imsi = new IMSIImpl("1111122222"); PurgeMSRequestImpl prim = new PurgeMSRequestImpl(imsi, vlrNumber, null, extensionContainer, 2); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); // version 3 ISDNAddressString sgsnNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22235"); prim = new PurgeMSRequestImpl(imsi, vlrNumber, sgsnNumber, extensionContainer, 3); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; /** * MAP V2-3: MAP V3: purgeMS OPERATION ::= { --Timer m ARGUMENT PurgeMS-Arg RESULT PurgeMS-Res -- optional ERRORS { dataMissing | unexpectedDataValue| unknownSubscriber} CODE local:67 } MAP V2: PurgeMS ::= OPERATION --Timer m ARGUMENT purgeMS-Arg PurgeMS-Arg RESULT MAP V3: PurgeMS-Arg ::= [3] SEQUENCE { imsi IMSI, vlr-Number [0] ISDN-AddressString OPTIONAL, sgsn-Number [1] ISDN-AddressString OPTIONAL, extensionContainer ExtensionContainer OPTIONAL, ... } MAP V2: PurgeMS-Arg ::= SEQUENCE { imsi IMSI, vlr-Number ISDN-AddressString, ... } * * @author sergey vetyutnev * */ public interface PurgeMSRequest extends MobilityMessage { IMSI getImsi(); ISDNAddressString getVlrNumber(); ISDNAddressString getSgsnNumber(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCodeValue; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TeleserviceCodeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class TeleserviceCodeTest { byte[] data = new byte[] { 4, 1, 0x11 }; @Test(groups = { "functional.decode", "subscriberInformation" }) public void testDecode() throws Exception { AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); assertEquals(tag, Tag.STRING_OCTET); TeleserviceCodeImpl impl = new TeleserviceCodeImpl(); impl.decodeAll(asn); assertEquals(impl.getData(), 0x11); assertEquals(impl.getTeleserviceCodeValue(), TeleserviceCodeValue.telephony); } @Test(groups = { "functional.encode", "subscriberInformation" }) public void testEncode() throws Exception { TeleserviceCodeImpl impl = new TeleserviceCodeImpl(TeleserviceCodeValue.telephony); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = data; assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * <code> TeleserviceCode ::= OCTET STRING (SIZE (1)) -- This type is used to represent the code identifying a single -- teleservice, a group of teleservices, or all teleservices. The -- services are defined in TS GSM 22.003 [4]. -- The internal structure is defined as follows: -- bits 87654321: group (bits 8765) and specific service -- (bits 4321) </code> * * * * @author sergey vetyutnev * */ public interface TeleserviceCode extends Serializable { int getData(); TeleserviceCodeValue getTeleserviceCodeValue(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ZoneCodeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ZoneCodeTest { public byte[] getData() { return new byte[] { 4, 2, 0, 2 }; }; public byte[] getData1() { return new byte[] { 4, 2, 2, 5 }; }; public byte[] getZoneCodeData() { return new byte[] { 2, 5 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ZoneCodeImpl prim = new ZoneCodeImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getValue(), 2); data = this.getData1(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new ZoneCodeImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(prim.getData(), this.getZoneCodeData())); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { ZoneCodeImpl prim = new ZoneCodeImpl(2); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); prim = new ZoneCodeImpl(this.getZoneCodeData()); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * ZoneCode ::= OCTET STRING (SIZE (2)) -- internal structure is defined in TS 3GPP TS 23.003 [17] * * * @author sergey vetyutnev * */ public interface ZoneCode extends Serializable { byte[] getData(); int getValue(); } ```
```package org.restcomm.protocols.ss7.cap.functional; /** * Steps of CAP functional test * * @author sergey vetyutnev * */ public enum FunctionalTestScenario { /** * TC-BEGIN + InitialDp */ Action_InitilDp(0); private int code; private FunctionalTestScenario(int code) { this.code = code; } public int getCode() { return this.code; } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.m3ua; /** * * @author amit bhayani * */ public enum Functionality { AS("AS"), IPSP("IPSP"), SGW("SGW"); private static final String TYPE_AS = "AS"; private static final String TYPE_IPSP = "IPSP"; private static final String TYPE_SGW = "SGW"; private String type = null; private Functionality(String type) { this.type = type; } public static Functionality getFunctionality(String type) { if (TYPE_AS.equals(type)) { return AS; } else if (TYPE_IPSP.equals(type)) { return IPSP; } else if (TYPE_SGW.equals(type)) { return SGW; } return null; } public String getType() { return this.type; } } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement.SupportedFeatures; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtBearerServiceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtTeleserviceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ODBGeneralData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.OfferedCamel4CSIs; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.RegionalSubscriptionResponse; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SupportedCamelPhases; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCodeValue; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.SupportedFeaturesImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtTeleserviceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.InsertSubscriberDataResponseImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ODBGeneralDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.OfferedCamel4CSIsImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SupportedCamelPhasesImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class InsertSubscriberDataResponseTest { public byte[] getData() { return new byte[] { 48, 81, -95, 3, 4, 1, 16, -94, 3, 4, 1, 38, -93, 3, 4, 1, 0, -124, 5, 3, 74, -43, 85, 80, -123, 1, 1, -122, 2, 4, -16, -89, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -120, 2, 1, -2, -119, 5, 6, 85, 85, 85, 64 }; }; public byte[] getData1() { return new byte[] { 48, 25, -95, 3, 4, 1, 16, -94, 3, 4, 1, 38, -93, 3, 4, 1, 0, -124, 5, 3, 74, -43, 85, 80, -123, 1, 1 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // ISD Response V3 Test byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); InsertSubscriberDataResponseImpl prim = new InsertSubscriberDataResponseImpl(3); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); // teleserviceList ArrayList<ExtTeleserviceCode> teleserviceList = prim.getTeleserviceList(); assertNotNull(teleserviceList); assertEquals(teleserviceList.size(), 1); ExtTeleserviceCode extTeleserviceCode = teleserviceList.get(0); assertEquals(extTeleserviceCode.getTeleserviceCodeValue(), TeleserviceCodeValue.allSpeechTransmissionServices); // bearerServiceList ArrayList<ExtBearerServiceCode> bearerServiceList = prim.getBearerServiceList(); assertNotNull(bearerServiceList); assertEquals(bearerServiceList.size(), 1); ExtBearerServiceCode extBearerServiceCode = bearerServiceList.get(0); assertEquals(extBearerServiceCode.getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); // ssList ArrayList<SSCode> ssList = prim.getSSList(); assertNotNull(ssList); assertEquals(ssList.size(), 1); SSCode ssCode = ssList.get(0); assertEquals(ssCode.getSupplementaryCodeValue(), SupplementaryCodeValue.allSS); ODBGeneralData odbGeneralData = prim.getODBGeneralData(); assertTrue(!odbGeneralData.getAllOGCallsBarred()); assertTrue(odbGeneralData.getInternationalOGCallsBarred()); assertTrue(!odbGeneralData.getInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsBarred()); assertTrue(!odbGeneralData.getInterzonalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsAndInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(!odbGeneralData.getPremiumRateInformationOGCallsBarred()); assertTrue(odbGeneralData.getPremiumRateEntertainementOGCallsBarred()); assertTrue(!odbGeneralData.getSsAccessBarred()); assertTrue(odbGeneralData.getAllECTBarred()); assertTrue(!odbGeneralData.getChargeableECTBarred()); assertTrue(odbGeneralData.getInternationalECTBarred()); assertTrue(!odbGeneralData.getInterzonalECTBarred()); assertTrue(odbGeneralData.getDoublyChargeableECTBarred()); assertTrue(!odbGeneralData.getMultipleECTBarred()); assertTrue(odbGeneralData.getAllPacketOrientedServicesBarred()); assertTrue(!odbGeneralData.getRoamerAccessToHPLMNAPBarred()); assertTrue(odbGeneralData.getRoamerAccessToVPLMNAPBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNOGCallsBarred()); assertTrue(odbGeneralData.getAllICCallsBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNICCallsBarred()); assertTrue(odbGeneralData.getRoamingOutsidePLMNICountryICCallsBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNBarred()); assertTrue(odbGeneralData.getRoamingOutsidePLMNCountryBarred()); assertTrue(!odbGeneralData.getRegistrationAllCFBarred()); assertTrue(odbGeneralData.getRegistrationCFNotToHPLMNBarred()); assertTrue(!odbGeneralData.getRegistrationInterzonalCFBarred()); assertTrue(odbGeneralData.getRegistrationInterzonalCFNotToHPLMNBarred()); assertTrue(!odbGeneralData.getRegistrationInternationalCFBarred()); assertEquals(prim.getRegionalSubscriptionResponse(), RegionalSubscriptionResponse.tooManyZoneCodes); SupportedCamelPhases supportedCamelPhases = prim.getSupportedCamelPhases(); assertTrue(supportedCamelPhases.getPhase1Supported()); assertTrue(supportedCamelPhases.getPhase2Supported()); assertTrue(supportedCamelPhases.getPhase3Supported()); assertTrue(supportedCamelPhases.getPhase4Supported()); assertNotNull(prim.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(prim.getExtensionContainer())); OfferedCamel4CSIs offeredCamel4CSIs = prim.getOfferedCamel4CSIs(); assertTrue(offeredCamel4CSIs.getDCsi()); assertTrue(offeredCamel4CSIs.getMgCsi()); assertTrue(offeredCamel4CSIs.getMtSmsCsi()); assertTrue(offeredCamel4CSIs.getOCsi()); assertTrue(offeredCamel4CSIs.getPsiEnhancements()); assertTrue(offeredCamel4CSIs.getTCsi()); assertTrue(offeredCamel4CSIs.getVtCsi()); SupportedFeatures supportedFeatures = prim.getSupportedFeatures(); assertTrue(!supportedFeatures.getOdbAllApn()); assertTrue(supportedFeatures.getOdbHPLMNApn()); assertTrue(!supportedFeatures.getOdbVPLMNApn()); assertTrue(supportedFeatures.getOdbAllOg()); assertTrue(!supportedFeatures.getOdbAllInternationalOg()); assertTrue(supportedFeatures.getOdbAllIntOgNotToHPLMNCountry()); assertTrue(!supportedFeatures.getOdbAllInterzonalOg()); assertTrue(supportedFeatures.getOdbAllInterzonalOgNotToHPLMNCountry()); assertTrue(!supportedFeatures.getOdbAllInterzonalOgandInternatOgNotToHPLMNCountry()); assertTrue(supportedFeatures.getRegSub()); assertTrue(!supportedFeatures.getTrace()); assertTrue(supportedFeatures.getLcsAllPrivExcep()); assertTrue(!supportedFeatures.getLcsUniversal()); assertTrue(supportedFeatures.getLcsCallSessionRelated()); assertTrue(!supportedFeatures.getLcsCallSessionUnrelated()); assertTrue(supportedFeatures.getLcsPLMNOperator()); assertTrue(!supportedFeatures.getLcsServiceType()); assertTrue(supportedFeatures.getLcsAllMOLRSS()); assertTrue(!supportedFeatures.getLcsBasicSelfLocation()); assertTrue(supportedFeatures.getLcsAutonomousSelfLocation()); assertTrue(!supportedFeatures.getLcsTransferToThirdParty()); assertTrue(supportedFeatures.getSmMoPp()); assertTrue(!supportedFeatures.getBarringOutgoingCalls()); assertTrue(supportedFeatures.getBaoc()); assertTrue(!supportedFeatures.getBoic()); assertTrue(supportedFeatures.getBoicExHC()); // IST Response V2 Test data = this.getData(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new InsertSubscriberDataResponseImpl(3); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); // teleserviceList teleserviceList = prim.getTeleserviceList(); assertNotNull(teleserviceList); assertEquals(teleserviceList.size(), 1); extTeleserviceCode = teleserviceList.get(0); assertEquals(extTeleserviceCode.getTeleserviceCodeValue(), TeleserviceCodeValue.allSpeechTransmissionServices); // bearerServiceList bearerServiceList = prim.getBearerServiceList(); assertNotNull(bearerServiceList); assertEquals(bearerServiceList.size(), 1); extBearerServiceCode = bearerServiceList.get(0); assertEquals(extBearerServiceCode.getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); // ssList ssList = prim.getSSList(); assertNotNull(ssList); assertEquals(ssList.size(), 1); ssCode = ssList.get(0); assertEquals(ssCode.getSupplementaryCodeValue(), SupplementaryCodeValue.allSS); odbGeneralData = prim.getODBGeneralData(); assertTrue(!odbGeneralData.getAllOGCallsBarred()); assertTrue(odbGeneralData.getInternationalOGCallsBarred()); assertTrue(!odbGeneralData.getInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsBarred()); assertTrue(!odbGeneralData.getInterzonalOGCallsNotToHPLMNCountryBarred()); assertTrue(odbGeneralData.getInterzonalOGCallsAndInternationalOGCallsNotToHPLMNCountryBarred()); assertTrue(!odbGeneralData.getPremiumRateInformationOGCallsBarred()); assertTrue(odbGeneralData.getPremiumRateEntertainementOGCallsBarred()); assertTrue(!odbGeneralData.getSsAccessBarred()); assertTrue(odbGeneralData.getAllECTBarred()); assertTrue(!odbGeneralData.getChargeableECTBarred()); assertTrue(odbGeneralData.getInternationalECTBarred()); assertTrue(!odbGeneralData.getInterzonalECTBarred()); assertTrue(odbGeneralData.getDoublyChargeableECTBarred()); assertTrue(!odbGeneralData.getMultipleECTBarred()); assertTrue(odbGeneralData.getAllPacketOrientedServicesBarred()); assertTrue(!odbGeneralData.getRoamerAccessToHPLMNAPBarred()); assertTrue(odbGeneralData.getRoamerAccessToVPLMNAPBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNOGCallsBarred()); assertTrue(odbGeneralData.getAllICCallsBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNICCallsBarred()); assertTrue(odbGeneralData.getRoamingOutsidePLMNICountryICCallsBarred()); assertTrue(!odbGeneralData.getRoamingOutsidePLMNBarred()); assertTrue(odbGeneralData.getRoamingOutsidePLMNCountryBarred()); assertTrue(!odbGeneralData.getRegistrationAllCFBarred()); assertTrue(odbGeneralData.getRegistrationCFNotToHPLMNBarred()); assertTrue(!odbGeneralData.getRegistrationInterzonalCFBarred()); assertTrue(odbGeneralData.getRegistrationInterzonalCFNotToHPLMNBarred()); assertTrue(!odbGeneralData.getRegistrationInternationalCFBarred()); assertEquals(prim.getRegionalSubscriptionResponse(), RegionalSubscriptionResponse.tooManyZoneCodes); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { // Start ISD Response Vesrion 3 Test // teleserviceList ArrayList<ExtTeleserviceCode> teleserviceList = new ArrayList<ExtTeleserviceCode>(); ExtTeleserviceCode extTeleservice = new ExtTeleserviceCodeImpl(TeleserviceCodeValue.allSpeechTransmissionServices); teleserviceList.add(extTeleservice); // bearerServiceList ArrayList<ExtBearerServiceCode> bearerServiceList = new ArrayList<ExtBearerServiceCode>(); ExtBearerServiceCodeImpl extBearerServiceCode = new ExtBearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); bearerServiceList.add(extBearerServiceCode); // ssList ArrayList<SSCode> ssList = new ArrayList<SSCode>(); SSCode ssCode = new SSCodeImpl(SupplementaryCodeValue.allSS); ssList.add(ssCode); ODBGeneralData odbGeneralData = new ODBGeneralDataImpl(false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false); RegionalSubscriptionResponse regionalSubscriptionResponse = RegionalSubscriptionResponse.tooManyZoneCodes; SupportedCamelPhases supportedCamelPhases = new SupportedCamelPhasesImpl(true, true, true, true); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); OfferedCamel4CSIs offeredCamel4CSIs = new OfferedCamel4CSIsImpl(true, true, true, true, true, true, true); SupportedFeatures supportedFeatures = new SupportedFeaturesImpl(false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true); InsertSubscriberDataResponseImpl prim = new InsertSubscriberDataResponseImpl(3, teleserviceList, bearerServiceList, ssList, odbGeneralData, regionalSubscriptionResponse, supportedCamelPhases, extensionContainer, offeredCamel4CSIs, supportedFeatures); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // Start ISD Response Vesrion 2 Test prim = new InsertSubscriberDataResponseImpl(2, teleserviceList, bearerServiceList, ssList, odbGeneralData, regionalSubscriptionResponse); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.MobilityMessage; import org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement.SupportedFeatures; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; /** * <code> MAP V3: InsertSubscriberDataRes ::= SEQUENCE { teleserviceList [1] TeleserviceList OPTIONAL, bearerServiceList [2] BearerServiceList OPTIONAL, ss-List [3] SS-List OPTIONAL, odb-GeneralData [4] ODB-GeneralData OPTIONAL, regionalSubscriptionResponse [5] RegionalSubscriptionResponse OPTIONAL, supportedCamelPhases [6] SupportedCamelPhases OPTIONAL, extensionContainer [7] ExtensionContainer OPTIONAL, ... , offeredCamel4CSIs [8] OfferedCamel4CSIs OPTIONAL, supportedFeatures [9] SupportedFeatures OPTIONAL } MAP V2: InsertSubscriberDataRes ::= SEQUENCE { teleserviceList [1] TeleserviceList OPTIONAL, bearerServiceList [2] BearerServiceList OPTIONAL, ss-List [3] SS-List OPTIONAL, odb-GeneralData [4] ODB-GeneralData OPTIONAL, regionalSubscriptionResponse [5] RegionalSubscriptionResponse OPTIONAL, -- regionalSubscriptionResponse must be absent in version 1 ... } TeleserviceList ::= SEQUENCE SIZE (1..20) OF Ext-TeleserviceCode BearerServiceList ::= SEQUENCE SIZE (1..50) OF Ext-BearerServiceCode SS-List ::= SEQUENCE SIZE (1..30) OF SS-Code </code> * * * * @author sergey vetyutnev * */ public interface InsertSubscriberDataResponse extends MobilityMessage { ArrayList<ExtTeleserviceCode> getTeleserviceList(); ArrayList<ExtBearerServiceCode> getBearerServiceList(); ArrayList<SSCode> getSSList(); ODBGeneralData getODBGeneralData(); RegionalSubscriptionResponse getRegionalSubscriptionResponse(); SupportedCamelPhases getSupportedCamelPhases(); MAPExtensionContainer getExtensionContainer(); OfferedCamel4CSIs getOfferedCamel4CSIs(); SupportedFeatures getSupportedFeatures(); } ```
```package org.restcomm.protocols.ss7.map.service.supplementary; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.EMLPPPriority; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BasicServiceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.api.service.supplementary.SSCode; import org.restcomm.protocols.ss7.map.api.service.supplementary.SupplementaryCodeValue; import org.restcomm.protocols.ss7.map.primitives.AddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.BasicServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.BearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.supplementary.RegisterSSRequestImpl; import org.restcomm.protocols.ss7.map.service.supplementary.SSCodeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class RegisterSSRequestTest { private byte[] getEncodedData1() { return new byte[] { 48, 36, 4, 1, 18, -126, 1, 35, -124, 5, -111, 17, 1, 0, -15, -122, 5, -111, 17, 1, 0, -14, -123, 1, 1, -121, 1, 6, -120, 1, 2, -119, 5, -111, 17, 1, 0, -13 }; } @Test(groups = { "functional.decode", "service.supplementary" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData1(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); RegisterSSRequestImpl impl = new RegisterSSRequestImpl(); impl.decodeAll(asn); assertEquals(impl.getSsCode().getSupplementaryCodeValue(), SupplementaryCodeValue.clir); assertEquals(impl.getBasicService().getBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_1200_75bps); assertEquals(impl.getForwardedToNumber().getAddress(), "1110001"); assertEquals(impl.getForwardedToSubaddress().getAddress(), "1110002"); assertEquals((int)impl.getNoReplyConditionTime(), 1); assertEquals(impl.getDefaultPriority(), EMLPPPriority.priorityLevelA); assertEquals((int)impl.getNbrUser(), 2); assertEquals(impl.getLongFTNSupported().getAddress(), "1110003"); } @Test(groups = { "functional.encode", "service.supplementary" }) public void testEncode() throws Exception { SSCode ssCode = new SSCodeImpl(SupplementaryCodeValue.clir); BearerServiceCode bearerService = new BearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_1200_75bps); BasicServiceCode basicService = new BasicServiceCodeImpl(bearerService); AddressString forwardedToNumber = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1110001"); ISDNAddressString forwardedToSubaddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1110002"); ISDNAddressString longFTNSupported = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1110003");; RegisterSSRequestImpl impl = new RegisterSSRequestImpl(ssCode, basicService, forwardedToNumber, forwardedToSubaddress, 1, EMLPPPriority.priorityLevelA, 2, longFTNSupported); // SSCode ssCode, BasicServiceCode basicService, AddressString forwardedToNumber, ISDNAddressString forwardedToSubaddress, // Integer noReplyConditionTime, EMLPPPriority defaultPriority, Integer nbrUser, ISDNAddressString longFTNSupported AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData1(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.supplementary; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.EMLPPPriority; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BasicServiceCode; /** * <code> MAP V2: registerSS OPERATION ::= { --Timer m ARGUMENT RegisterSS-Arg RESULT SS-Info -- optional ERRORS { systemFailure | dataMissing | unexpectedDataValue | bearerServiceNotProvisioned | teleserviceNotProvisioned | callBarred | illegalSS-Operation | ss-ErrorStatus | ss-Incompatibility} CODE local:10 } RegisterSS-Arg ::= SEQUENCE { ss-Code SS-Code, basicService BasicServiceCode OPTIONAL, forwardedToNumber [4] AddressString OPTIONAL, forwardedToSubaddress [6] ISDN-SubaddressString OPTIONAL, noReplyConditionTime [5] NoReplyConditionTime OPTIONAL, ..., defaultPriority [7] EMLPP-Priority OPTIONAL, nbrUser [8] MC-Bearers OPTIONAL, longFTN-Supported [9] NULL OPTIONAL } NoReplyConditionTime ::= INTEGER (5..30) MC-Bearers ::= INTEGER (1..7) </code> * * * @author sergey vetyutnev * */ public interface RegisterSSRequest extends SupplementaryMessage { SSCode getSsCode(); BasicServiceCode getBasicService(); AddressString getForwardedToNumber(); ISDNAddressString getForwardedToSubaddress(); Integer getNoReplyConditionTime(); EMLPPPriority getDefaultPriority(); Integer getNbrUser(); ISDNAddressString getLongFTNSupported(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.locationManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.primitives.IMEIImpl; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.ADDInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ADDInfoTest { private byte[] getEncodedData() { return new byte[] { 48, 12, -128, 8, 33, 67, 101, -121, 9, 33, 67, -11, -127, 0 }; } @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); ADDInfoImpl asc = new ADDInfoImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getImeisv().getIMEI().equals("123456789012345")); assertTrue(asc.getSkipSubscriberDataUpdate()); } @Test(groups = { "functional.encode" }) public void testEncode() throws Exception { IMEIImpl imeisv = new IMEIImpl("123456789012345"); ADDInfoImpl asc = new ADDInfoImpl(imeisv, true); // IMEI imeisv, boolean skipSubscriberDataUpdate AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.IMEI; /** * ADD-Info ::= SEQUENCE { imeisv [0] IMEI, skipSubscriberDataUpdate [1] NULL OPTIONAL, -- The skipSubscriberDataUpdate * parameter in the UpdateLocationArg and the ADD-Info -- structures carry the same semantic. ...} * * * @author sergey vetyutnev * */ public interface ADDInfo extends Serializable { IMEI getImeisv(); boolean getSkipSubscriberDataUpdate(); } ```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.MonitorMode; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.GPRSEventType; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.GPRSEventImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class GPRSEventTest { public byte[] getData() { return new byte[] { 48, 6, -128, 1, 2, -127, 1, 1 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); GPRSEventImpl prim = new GPRSEventImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getGPRSEventType(), GPRSEventType.attachChangeOfPosition); assertEquals(prim.getMonitorMode(), MonitorMode.notifyAndContinue); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { GPRSEventImpl prim = new GPRSEventImpl(GPRSEventType.attachChangeOfPosition, MonitorMode.notifyAndContinue); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; import org.restcomm.protocols.ss7.cap.api.primitives.MonitorMode; /** * GPRSEvent ::= SEQUENCE { gPRSEventType [0] GPRSEventType, monitorMode [1] MonitorMode } -- Indicates the GPRS event * information for monitoring. * * * @author sergey vetyutnev * */ public interface GPRSEvent extends Serializable { GPRSEventType getGPRSEventType(); MonitorMode getMonitorMode(); }```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.*; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtQoSSubscribed_BitRateImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ExtQoSSubscribed_BitRateTest { @Test(groups = { "functional.decode", "mobility.subscriberManagement" }) public void testDecode() throws Exception { ExtQoSSubscribed_BitRateImpl prim = new ExtQoSSubscribed_BitRateImpl(1, true); assertEquals(prim.getBitRate(), 1); prim = new ExtQoSSubscribed_BitRateImpl(63, true); assertEquals(prim.getBitRate(), 63); prim = new ExtQoSSubscribed_BitRateImpl(64, true); assertEquals(prim.getBitRate(), 64); prim = new ExtQoSSubscribed_BitRateImpl(120, true); assertEquals(prim.getBitRate(), 512); prim = new ExtQoSSubscribed_BitRateImpl(127, true); assertEquals(prim.getBitRate(), 568); prim = new ExtQoSSubscribed_BitRateImpl(128, true); assertEquals(prim.getBitRate(), 576); prim = new ExtQoSSubscribed_BitRateImpl(129, true); assertEquals(prim.getBitRate(), 576 + 64); prim = new ExtQoSSubscribed_BitRateImpl(232, true); assertEquals(prim.getBitRate(), 7232); prim = new ExtQoSSubscribed_BitRateImpl(254, true); assertEquals(prim.getBitRate(), 8640); prim = new ExtQoSSubscribed_BitRateImpl(0, true); assertEquals(prim.getBitRate(), 0); prim = new ExtQoSSubscribed_BitRateImpl(255, true); assertEquals(prim.getBitRate(), 0); prim = new ExtQoSSubscribed_BitRateImpl(300, true); assertEquals(prim.getBitRate(), 0); } @Test(groups = { "functional.encode", "mobility.subscriberManagement" }) public void testEncode() throws Exception { ExtQoSSubscribed_BitRateImpl prim = new ExtQoSSubscribed_BitRateImpl(1, false); assertEquals(prim.getSourceData(), 1); prim = new ExtQoSSubscribed_BitRateImpl(63, false); assertEquals(prim.getSourceData(), 63); prim = new ExtQoSSubscribed_BitRateImpl(64, false); assertEquals(prim.getSourceData(), 64); prim = new ExtQoSSubscribed_BitRateImpl(512, false); assertEquals(prim.getSourceData(), 120); prim = new ExtQoSSubscribed_BitRateImpl(568, false); assertEquals(prim.getSourceData(), 127); prim = new ExtQoSSubscribed_BitRateImpl(576, false); assertEquals(prim.getSourceData(), 128); prim = new ExtQoSSubscribed_BitRateImpl(576 + 64, false); assertEquals(prim.getSourceData(), 129); prim = new ExtQoSSubscribed_BitRateImpl(7232, false); assertEquals(prim.getSourceData(), 232); prim = new ExtQoSSubscribed_BitRateImpl(8640, false); assertEquals(prim.getSourceData(), 254); prim = new ExtQoSSubscribed_BitRateImpl(0, false); assertEquals(prim.getSourceData(), 0); prim = new ExtQoSSubscribed_BitRateImpl(100000, false); assertEquals(prim.getSourceData(), 0); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; /** * <code> Maximum bit rate for uplink, octet 8 Bits 8 7 6 5 4 3 2 1 In MS to network direction: 0 0 0 0 0 0 0 0 Subscribed maximum bit rate for uplink In network to MS direction: 0 0 0 0 0 0 0 0 Reserved In MS to network direction and in network to MS direction: 0 0 0 0 0 0 0 1 The maximum bit rate is binary coded in 8 bits, using a granularity of 1 kbps 0 0 1 1 1 1 1 1 giving a range of values from 1 kbps to 63 kbps in 1 kbps increments. 0 1 0 0 0 0 0 0 The maximum bit rate is 64 kbps + ((the binary coded value in 8 bits 01000000) * 8 kbps) 0 1 1 1 1 1 1 1 giving a range of values from 64 kbps to 568 kbps in 8 kbps increments. 1 0 0 0 0 0 0 0 The maximum bit rate is 576 kbps + ((the binary coded value in 8 bits 10000000) * 64 kbps) 1 1 1 1 1 1 1 0 giving a range of values from 576 kbps to 8640 kbps in 64 kbps increments. 1 1 1 1 1 1 1 1 0kbps If the sending entity wants to indicate a Maximum bit rate for uplink higher than 8640 kbps, it shall set octet 8 to 11111110, i.e. 8640 kbps, and shall encode the value for the Maximum bit rate in octet 17. </code> * * @author sergey vetyutnev * */ public interface ExtQoSSubscribed_BitRate { int getSourceData(); /** * @return BitRate (kbit/s) value or 0 when source==0 or not specified in * 23.107 */ int getBitRate(); } ```
```package org.restcomm.protocols.ss7.map.smstpdu; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.restcomm.protocols.ss7.map.smstpdu.AbsoluteTimeStampImpl; import org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl; import org.restcomm.protocols.ss7.map.smstpdu.FailureCauseImpl; import org.restcomm.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl; import org.restcomm.protocols.ss7.map.smstpdu.SmsSubmitReportTpduImpl; import org.restcomm.protocols.ss7.map.smstpdu.UserDataImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class SmsSubmitReportTpduTest { public byte[] getData1() { return new byte[] { 1, -56, 6, 112, 80, 81, 81, 16, 17, 33, 0, 10, -56, 50, -101, -3, 6, -123, 66, -95, 16 }; } public byte[] getData2() { return new byte[] { 1, 1, 112, 80, 81, 81, 16, 17, 33, 44 }; } @Test(groups = { "functional.decode", "smstpdu" }) public void testDecode() throws Exception { SmsSubmitReportTpduImpl impl = new SmsSubmitReportTpduImpl(this.getData1(), null); assertFalse(impl.getUserDataHeaderIndicator()); assertEquals(impl.getFailureCause().getCode(), 200); assertEquals(impl.getServiceCentreTimeStamp().getYear(), 7); assertEquals(impl.getServiceCentreTimeStamp().getMonth(), 5); assertEquals(impl.getServiceCentreTimeStamp().getDay(), 15); assertEquals(impl.getServiceCentreTimeStamp().getHour(), 15); assertEquals(impl.getServiceCentreTimeStamp().getMinute(), 1); assertEquals(impl.getServiceCentreTimeStamp().getSecond(), 11); assertEquals(impl.getServiceCentreTimeStamp().getTimeZone(), 12); assertEquals(impl.getParameterIndicator().getCode(), 6); assertNull(impl.getProtocolIdentifier()); impl.getUserData().decode(); assertEquals(impl.getDataCodingScheme().getCode(), 0); assertTrue(impl.getUserData().getDecodedMessage().equals("Hello !!!!")); impl = new SmsSubmitReportTpduImpl(this.getData2(), null); assertFalse(impl.getUserDataHeaderIndicator()); assertNull(impl.getFailureCause()); assertEquals(impl.getServiceCentreTimeStamp().getYear(), 7); assertEquals(impl.getServiceCentreTimeStamp().getMonth(), 5); assertEquals(impl.getServiceCentreTimeStamp().getDay(), 15); assertEquals(impl.getServiceCentreTimeStamp().getHour(), 15); assertEquals(impl.getServiceCentreTimeStamp().getMinute(), 1); assertEquals(impl.getServiceCentreTimeStamp().getSecond(), 11); assertEquals(impl.getServiceCentreTimeStamp().getTimeZone(), 12); assertEquals(impl.getParameterIndicator().getCode(), 1); assertEquals(impl.getProtocolIdentifier().getCode(), 44); assertNull(impl.getDataCodingScheme()); assertNull(impl.getUserData()); } @Test(groups = { "functional.encode", "smstpdu" }) public void testEncode() throws Exception { UserDataImpl ud = new UserDataImpl("Hello !!!!", new DataCodingSchemeImpl(0), null, null); FailureCauseImpl failureCause = new FailureCauseImpl(200); AbsoluteTimeStampImpl serviceCentreTimeStamp = new AbsoluteTimeStampImpl(7, 5, 15, 15, 1, 11, 12); SmsSubmitReportTpduImpl impl = new SmsSubmitReportTpduImpl(failureCause, serviceCentreTimeStamp, null, ud); byte[] enc = impl.encodeData(); assertTrue(Arrays.equals(enc, this.getData1())); ProtocolIdentifierImpl pi = new ProtocolIdentifierImpl(44); impl = new SmsSubmitReportTpduImpl(null, serviceCentreTimeStamp, pi, null); enc = impl.encodeData(); assertTrue(Arrays.equals(enc, this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.smstpdu; /** * SMS-SUBMIT-REPORT pdu * * @author sergey vetyutnev * */ public interface SmsSubmitReportTpdu extends SmsTpdu { /** * @return TP-UDHI field */ boolean getUserDataHeaderIndicator(); /** * @return TP-FCS field Returns null if no failure occured and the result is ACK */ FailureCause getFailureCause(); /** * @return TP-PI field */ ParameterIndicator getParameterIndicator(); /** * @return TP-SCTS field */ AbsoluteTimeStamp getServiceCentreTimeStamp(); /** * @return TP-PID field */ ProtocolIdentifier getProtocolIdentifier(); /** * @return TP-DCS field */ DataCodingScheme getDataCodingScheme(); /** * @return TP-UDL field */ int getUserDataLength(); /** * @return TP-UD field */ UserData getUserData(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.CircuitIdentificationCodeImpl; import org.testng.annotations.Test; /** * Start time:14:11:03 2009-04-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class CircuitIdentificationCodeTest extends ParameterHarness { /** * @throws IOException */ public CircuitIdentificationCodeTest() throws IOException { super.goodBodies.add(getBody1()); super.goodBodies.add(getBody2()); super.badBodies.add(new byte[1]); super.badBodies.add(new byte[3]); } private byte[] getBody1() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); // we will use odd number of digits, so we leave zero as MSB return new byte[] { (byte) 0xFF, 0x0F }; } private byte[] getBody2() throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); // we will use odd number of digits, so we leave zero as MSB return new byte[] { (byte) 0xAB, 0x0C }; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException { CircuitIdentificationCodeImpl bci = new CircuitIdentificationCodeImpl(); bci.decode(getBody1()); String[] methodNames = { "getCIC" }; Object[] expectedValues = { (int) 0xFFF }; super.testValues(bci, methodNames, expectedValues); } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody2EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException { CircuitIdentificationCodeImpl bci = new CircuitIdentificationCodeImpl(); bci.decode(getBody2()); String[] methodNames = { "getCIC" }; Object[] expectedValues = { (int) 0xCAB }; super.testValues(bci, methodNames, expectedValues); } /* * (non-Javadoc) * * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent () */ public AbstractISUPParameter getTestedComponent() { return new CircuitIdentificationCodeImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; import java.io.Serializable; /** * Start time:14:43:22 2009-09-18<br> * Project: mobicents-isup-stack<br> * This is not real parameter, its present to follow same way of defining message, null not present, != null present. * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface CircuitIdentificationCode extends Serializable { int getCIC(); void setCIC(int cic); } ```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.HopCounterImpl; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class InvokingPivotReasonTest extends ParameterHarness { public InvokingPivotReasonTest() { super(); super.goodBodies.add(getBody1()); } private byte[] getBody1() { byte[] body = new byte[] { (byte) 0x0F }; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { HopCounterImpl at = new HopCounterImpl(getBody1()); String[] methodNames = { "getHopCounter" }; Object[] expectedValues = { 0x0F }; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.HopCounterImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:13:20:48 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface InvokingPivotReason extends Information { void setReason(PivotReason... reasons); PivotReason[] getReason(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.BearerServiceCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.InterCUGRestrictions; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.InterCUGRestrictionsValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TeleserviceCodeValue; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CUGFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBasicServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtBearerServiceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtTeleserviceCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.InterCUGRestrictionsImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class CUGFeatureTest { public byte[] getData() { return new byte[] { 48, 50, -126, 1, 38, 2, 1, 1, 4, 1, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getData1() { return new byte[] { 48, 50, -125, 1, 17, 2, 1, 1, 4, 1, 0, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); CUGFeatureImpl prim = new CUGFeatureImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); // assertTrue(Arrays.equals(prim.getBasicService().getExtBearerService().getData(), // this.getData2())); assertEquals(prim.getBasicService().getExtBearerService().getBearerServiceCodeValue(), BearerServiceCodeValue.padAccessCA_9600bps); assertNull(prim.getBasicService().getExtTeleservice()); // assertTrue(prim.getPreferentialCugIndicator().equals(new Integer(1))); assertEquals((int) prim.getPreferentialCugIndicator(), 1); // assertTrue(prim.getInterCugRestrictions().getInterCUGRestrictionsValue().equals( // InterCUGRestrictionsValue.CUGOnlyFacilities)); assertEquals(prim.getInterCugRestrictions().getInterCUGRestrictionsValue(), InterCUGRestrictionsValue.CUGOnlyFacilities); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } { byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); CUGFeatureImpl prim = new CUGFeatureImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); // assertTrue(Arrays.equals(prim.getBasicService().getExtTeleservice().getData(), // this.getData3())); assertEquals(prim.getBasicService().getExtTeleservice().getTeleserviceCodeValue(), TeleserviceCodeValue.telephony); assertNull(prim.getBasicService().getExtBearerService()); // assertTrue(prim.getPreferentialCugIndicator().equals(new Integer(1))); assertEquals((int) prim.getPreferentialCugIndicator(), 1); assertTrue(prim.getInterCugRestrictions().getInterCUGRestrictionsValue() .equals(InterCUGRestrictionsValue.CUGOnlyFacilities)); assertNotNull(extensionContainer); } } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { { // ExtBearerServiceCodeImpl b = new ExtBearerServiceCodeImpl(this.getData2()); ExtBearerServiceCodeImpl b = new ExtBearerServiceCodeImpl(BearerServiceCodeValue.padAccessCA_9600bps); ExtBasicServiceCodeImpl basicService = new ExtBasicServiceCodeImpl(b); // Integer preferentialCugIndicator = new Integer(1); Integer preferentialCugIndicator = 1; // InterCUGRestrictions interCugRestrictions = new InterCUGRestrictionsImpl(0); InterCUGRestrictions interCugRestrictions = new InterCUGRestrictionsImpl( InterCUGRestrictionsValue.CUGOnlyFacilities); // MAPExtensionContainer extensionContainer = getMapExtensionContainer(); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); CUGFeatureImpl prim = new CUGFeatureImpl(basicService, preferentialCugIndicator, interCugRestrictions, extensionContainer); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } { // ExtTeleserviceCodeImpl b = new ExtTeleserviceCodeImpl(this.getData3()); ExtTeleserviceCodeImpl b = new ExtTeleserviceCodeImpl(TeleserviceCodeValue.telephony); ExtBasicServiceCodeImpl basicService = new ExtBasicServiceCodeImpl(b); Integer preferentialCugIndicator = new Integer(1); InterCUGRestrictions interCugRestrictions = new InterCUGRestrictionsImpl(0); // MAPExtensionContainer extensionContainer = getMapExtensionContainer(); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); CUGFeatureImpl prim = new CUGFeatureImpl(basicService, preferentialCugIndicator, interCugRestrictions, extensionContainer); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); } } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * CUG-Feature ::= SEQUENCE { basicService Ext-BasicServiceCode OPTIONAL, preferentialCUG-Indicator CUG-Index OPTIONAL, * interCUG-Restrictions InterCUG-Restrictions, extensionContainer ExtensionContainer OPTIONAL, ...} * * CUG-Index ::= INTEGER (0..32767) -- The internal structure is defined in ETS 300 138. * * * * @author sergey vetyutnev * */ public interface CUGFeature extends Serializable { ExtBasicServiceCode getBasicService(); Integer getPreferentialCugIndicator(); InterCUGRestrictions getInterCugRestrictions(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.CallHistoryInformationImpl; import org.testng.annotations.Test; /** * Start time:14:11:03 2009-04-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class CallHistoryInformationTest extends ParameterHarness { /** * @throws IOException */ public CallHistoryInformationTest() throws IOException { super.badBodies.add(new byte[1]); super.badBodies.add(new byte[3]); super.goodBodies.add(getBody1()); } private byte[] getBody1() throws IOException { // we will use odd number of digits, so we leave zero as MSB byte[] body = new byte[2]; body[0] = 12; body[1] = 120; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, IOException, ParameterException { CallHistoryInformationImpl bci = new CallHistoryInformationImpl(getBody1()); String[] methodNames = { "getCallHistory" }; Object[] expectedValues = { ((12 << 8) | 120) & 0xFFFF }; super.testValues(bci, methodNames, expectedValues); } /* * (non-Javadoc) * * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent () */ public AbstractISUPParameter getTestedComponent() throws ParameterException { return new CallHistoryInformationImpl(new byte[2]); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:11:54:44 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface CallHistoryInformation extends ISUPParameter { int _PARAMETER_CODE = 0x2D; int getCallHistory(); void setCallHistory(int callHistory); } ```
```package org.restcomm.protocols.ss7.cap.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.TimerID; import org.restcomm.protocols.ss7.cap.primitives.CAPExtensionsTest; import org.restcomm.protocols.ss7.cap.service.sms.ResetTimerSMSRequestImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ResetTimerSMSRequestTest { public byte[] getData() { return new byte[] { 48, 26, -128, 1, 0, -127, 1, 2, -94, 18, 48, 5, 2, 1, 2, -127, 0, 48, 9, 2, 1, 3, 10, 1, 1, -127, 1, -1 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ResetTimerSMSRequestImpl prim = new ResetTimerSMSRequestImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getTimerID(), TimerID.tssf); assertEquals(prim.getTimerValue(), 2); CAPExtensionsTest.checkTestCAPExtensions(prim.getExtensions()); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { TimerID timerID = TimerID.tssf; int timerValue = 2; CAPExtensions extensions = CAPExtensionsTest.createTestCAPExtensions(); ; ResetTimerSMSRequestImpl prim = new ResetTimerSMSRequestImpl(timerID, timerValue, extensions); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.TimerID; /** * resetTimerSMS {PARAMETERS-BOUND : bound} OPERATION ::= { ARGUMENT ResetTimerSMSArg {bound} RETURN RESULT FALSE ERRORS {missingParameter | parameterOutOfRange | taskRefused | unexpectedComponentSequence | unexpectedDataValue | unexpectedParameter} CODE opcode-resetTimerSMS } -- Direction: gsmSCF -> smsSSF, Timer: T rtsms -- This operation is used to request the smsSSF to refresh an application -- timer in the smsSSF. ResetTimerSMSArg {PARAMETERS-BOUND : bound} ::= SEQUENCE { timerID [0] TimerID DEFAULT tssf, timervalue [1] TimerValue, extensions [2] Extensions {bound} OPTIONAL, ... } TimerValue ::= Integer4 -- Indicates the timer value (in seconds). * * * @author sergey vetyutnev * */ public interface ResetTimerSMSRequest extends SmsMessage { TimerID getTimerID(); int getTimerValue(); CAPExtensions getExtensions(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.ContinuityIndicatorsImpl; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class ContinuityIndicatorsTest extends ParameterHarness { public ContinuityIndicatorsTest() { super(); super.goodBodies.add(getBody1()); } private byte[] getBody1() { byte[] body = new byte[]{0x01}; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { ContinuityIndicatorsImpl at = new ContinuityIndicatorsImpl(getBody1()); String[] methodNames = { "isContinuityCheck" }; Object[] expectedValues = { true }; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.ContinuityIndicatorsImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:12:34:42 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface ContinuityIndicators extends ISUPParameter { int _PARAMETER_CODE = 0x10; /** * See Q.763 3.18 */ boolean _CONTINUITY_CHECK_FAILED = false; /** * See Q.763 3.18 */ boolean _CONTINUITY_CHECK_SUCCESSFUL = true; boolean isContinuityCheck(); void setContinuityCheck(boolean continuityCheck); } ```
```package org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.cap.api.primitives.SendingSideID; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.CAI_GSM0224; import org.restcomm.protocols.ss7.cap.primitives.CAPExtensionsTest; import org.restcomm.protocols.ss7.cap.primitives.SendingSideIDImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.SendChargingInformationRequestImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.AOCSubsequentImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAI_GSM0224Impl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.SCIBillingChargingCharacteristicsImpl; import org.restcomm.protocols.ss7.inap.api.primitives.LegType; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class SendChargingInformationRequestTest { public byte[] getData1() { return new byte[] { 48, 43, (byte) 128, 16, (byte) 161, 14, (byte) 160, 9, (byte) 128, 1, 1, (byte) 129, 1, 2, (byte) 130, 1, 3, (byte) 129, 1, 100, (byte) 161, 3, (byte) 128, 1, 2, (byte) 162, 18, 48, 5, 2, 1, 2, (byte) 129, 0, 48, 9, 2, 1, 3, 10, 1, 1, (byte) 129, 1, (byte) 255 }; } @Test(groups = { "functional.decode", "circuitSwitchedCall.primitive" }) public void testDecode() throws Exception { byte[] data = this.getData1(); AsnInputStream ais = new AsnInputStream(data); SendChargingInformationRequestImpl elem = new SendChargingInformationRequestImpl(); int tag = ais.readTag(); elem.decodeAll(ais); this.testCAI_GSM0224(elem.getSCIBillingChargingCharacteristics().getAOCSubsequent().getCAI_GSM0224()); assertEquals((int) elem.getSCIBillingChargingCharacteristics().getAOCSubsequent().getTariffSwitchInterval(), 100); assertEquals(elem.getPartyToCharge().getSendingSideID(), LegType.leg2); assertTrue(CAPExtensionsTest.checkTestCAPExtensions(elem.getExtensions())); } @Test(groups = { "functional.encode", "circuitSwitchedCall.primitive" }) public void testEncode() throws Exception { CAI_GSM0224Impl gsm224 = new CAI_GSM0224Impl(1, 2, 3, null, null, null, null); AOCSubsequentImpl aocSubsequent = new AOCSubsequentImpl(gsm224, 100); SendingSideID partyToCharge = new SendingSideIDImpl(LegType.leg2); SCIBillingChargingCharacteristicsImpl sciBillingChargingCharacteristics = new SCIBillingChargingCharacteristicsImpl( aocSubsequent); SendChargingInformationRequestImpl elem = new SendChargingInformationRequestImpl(sciBillingChargingCharacteristics, partyToCharge, CAPExtensionsTest.createTestCAPExtensions()); AsnOutputStream aos = new AsnOutputStream(); elem.encodeAll(aos); assertTrue(Arrays.equals(aos.toByteArray(), this.getData1())); // SCIBillingChargingCharacteristics sciBillingChargingCharacteristics, SendingSideID partyToCharge, // CAPExtensions extensions } private void testCAI_GSM0224(CAI_GSM0224 gsm224) { assertEquals((int) gsm224.getE1(), 1); assertEquals((int) gsm224.getE2(), 2); assertEquals((int) gsm224.getE3(), 3); assertNull(gsm224.getE4()); assertNull(gsm224.getE5()); assertNull(gsm224.getE6()); assertNull(gsm224.getE7()); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.SendingSideID; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.SCIBillingChargingCharacteristics; /** * sendChargingInformation {PARAMETERS-BOUND : bound} OPERATION ::= { ARGUMENT SendChargingInformationArg {bound} RETURN RESULT * FALSE ERRORS {missingParameter | unexpectedComponentSequence | unexpectedParameter | parameterOutOfRange | systemFailure | * taskRefused | unexpectedDataValue | unknownLegID} CODE opcode-sendChargingInformation} -- Direction: gsmSCF -> gsmSSF, Timer: * Tsci -- This operation is used to instruct the gsmSSF on the charging information to send by the gsmSSF. -- The charging * information can either be sent back by means of signalling or internal -- if the gsmSSF is located in the local exchange. In * the local exchange -- this information may be used to update the charge meter or to create a standard call record. * * SendChargingInformationArg {PARAMETERS-BOUND : bound}::= SEQUENCE { sCIBillingChargingCharacteristics [0] * SCIBillingChargingCharacteristics {bound}, partyToCharge [1] SendingSideID, extensions [2] Extensions {bound} OPTIONAL, ... } * * * @author sergey vetyutnev * */ public interface SendChargingInformationRequest extends CircuitSwitchedCallMessage { SCIBillingChargingCharacteristics getSCIBillingChargingCharacteristics(); SendingSideID getPartyToCharge(); CAPExtensions getExtensions(); }```
```package org.restcomm.protocols.ss7.map.primitives; import static org.testng.Assert.*; import org.restcomm.protocols.ss7.map.api.primitives.GSNAddressAddressType; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class GSNAddressAddressTypeTest { private int getEncodedData() { return 4; } private int getEncodedData2() { return 80; } @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { int firstByte = getEncodedData(); GSNAddressAddressType asc = GSNAddressAddressType.getFromGSNAddressFirstByte(firstByte); assertEquals(asc, GSNAddressAddressType.IPv4); firstByte = getEncodedData2(); asc = GSNAddressAddressType.getFromGSNAddressFirstByte(firstByte); assertEquals(asc, GSNAddressAddressType.IPv6); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { GSNAddressAddressType asc = GSNAddressAddressType.IPv4; int firstByte = asc.createGSNAddressFirstByte(); assertEquals(firstByte, getEncodedData()); asc = GSNAddressAddressType.IPv6; firstByte = asc.createGSNAddressFirstByte(); assertEquals(firstByte, getEncodedData2()); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.primitives; /** * <code> Address Type 0 and Address Length 4 are used when Address is an IPv4 address. Address Type 1 and Address Length 16 are used when Address is an IPv6 address. </code> * * * @author sergey vetyutnev * */ public enum GSNAddressAddressType { IPv4(0), IPv6(1); private int code; private GSNAddressAddressType(int code) { this.code = code; } public int getCode() { return code; } public static GSNAddressAddressType getInstance(int code) { switch (code) { case 0: return IPv4; case 1: return IPv6; default: return null; } } // this part is for GSNAddress for first byte encoding purpose public int createGSNAddressFirstByte() { int val = (this.code << 6); if (this.code == 0) // IPv4 val += 4; if (this.code == 1) // IPv6 val += 16; return val; } public static GSNAddressAddressType getFromGSNAddressFirstByte(int firstByte) { int val1 = (firstByte >> 6); int len = (firstByte & 0x3F); GSNAddressAddressType res = getInstance(val1); if (res != null) { switch(res){ case IPv4: if (len == 4) return res; break; case IPv6: if (len == 16) return res; break; } } return null; } } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.FTNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwFeature; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtSSStatus; import org.restcomm.protocols.ss7.map.primitives.FTNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.CallForwardingDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtForwFeatureImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtSSStatusImpl; import org.testng.annotations.Test; import java.util.ArrayList; import java.util.Arrays; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; /** * @author vadim subbotin */ public class CallForwardingDataTest { private byte[] data = {48, 67, 48, 22, 48, 20, -124, 1, 5, -123, 6, -111, -119, 103, 69, 35, -15, -121, 1, 5, -118, 4, -111, 33, 67, -11, 5, 0, -96, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33}; @Test(groups = {"functional.decode", "subscriberInformation"}) public void testDecode() throws Exception { AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); CallForwardingDataImpl callForwardingData = new CallForwardingDataImpl(); callForwardingData.decodeAll(asn); assertNotNull(callForwardingData.getForwardingFeatureList()); assertEquals(callForwardingData.getForwardingFeatureList().size(), 1); assertTrue(callForwardingData.getNotificationToCSE()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(callForwardingData.getExtensionContainer())); ExtForwFeature extForwFeature = callForwardingData.getForwardingFeatureList().get(0); ISDNAddressString forwardedToNumber = extForwFeature.getForwardedToNumber(); ExtSSStatus extSSStatus = extForwFeature.getSsStatus(); FTNAddressString longForwardedToNumber = extForwFeature.getLongForwardedToNumber(); assertNull(extForwFeature.getBasicService()); assertNull(extForwFeature.getForwardedToSubaddress()); assertNull(extForwFeature.getForwardingOptions()); assertNull(extForwFeature.getExtensionContainer()); assertEquals(extForwFeature.getNoReplyConditionTime().intValue(), 5); assertEquals(forwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(forwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(forwardedToNumber.getAddress(), "987654321"); assertFalse(extSSStatus.getBitQ()); assertTrue(extSSStatus.getBitP()); assertFalse(extSSStatus.getBitR()); assertTrue(extSSStatus.getBitA()); assertEquals(longForwardedToNumber.getAddressNature(), AddressNature.international_number); assertEquals(longForwardedToNumber.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(longForwardedToNumber.getAddress(), "12345"); } @Test(groups = {"functional.encode", "subscriberInformation"}) public void testEncode() throws Exception { ISDNAddressStringImpl forwardedToNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "987654321"); FTNAddressStringImpl longForwardedToNumber = new FTNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "12345"); final ExtForwFeatureImpl extForwFeature = new ExtForwFeatureImpl(null, new ExtSSStatusImpl(false, true, false, true), forwardedToNumber, null, null, 5, null, longForwardedToNumber); CallForwardingDataImpl callForwardingData = new CallForwardingDataImpl(new ArrayList<ExtForwFeature>(){{add(extForwFeature);}}, true, MAPExtensionContainerTest.GetTestExtensionContainer()); AsnOutputStream asnOS = new AsnOutputStream(); callForwardingData.encodeAll(asnOS); byte[] raw = asnOS.toByteArray(); assertTrue(Arrays.equals(raw, data)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ExtForwFeature; /** * <code> CallForwardingData ::= SEQUENCE { forwardingFeatureList Ext-ForwFeatureList, notificationToCSE NULL OPTIONAL, extensionContainer [0] ExtensionContainer OPTIONAL, ... } Ext-ForwFeatureList ::= SEQUENCE SIZE (1..32) OF Ext-ForwFeature </code> * * * @author sergey vetyutnev * */ public interface CallForwardingData extends Serializable { ArrayList<ExtForwFeature> getForwardingFeatureList(); boolean getNotificationToCSE(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.smstpdu; import static org.testng.Assert.*; import org.restcomm.protocols.ss7.map.smstpdu.ApplicationPortAddressing16BitAddressImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ApplicationPortAddressing16BitAddressTest { private byte[] getData() { return new byte[] { 0x3e, (byte) 0x94, 0, 1 }; } @Test(groups = { "functional.decode", "smstpdu" }) public void testDecode() throws Exception { ApplicationPortAddressing16BitAddressImpl dcs = new ApplicationPortAddressing16BitAddressImpl(getData()); assertEquals(dcs.getDestinationPort(), 16020); assertEquals(dcs.getOriginatorPort(), 1); } @Test(groups = { "functional.encode", "smstpdu" }) public void testEncode() throws Exception { ApplicationPortAddressing16BitAddressImpl dcs = new ApplicationPortAddressing16BitAddressImpl(16020, 1); assertEquals(dcs.getEncodedInformationElementData(), getData()); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.smstpdu; /** * This facility allows short messages to be routed to one of multiple * applications, using a method similar to TCP/UDP ports in a TCP/IP network. An * application entity is uniquely identified by the pair of TP-DA/TP-OA and the * port address. The port addressing is transparent to the transport, and also * useful in Status Reports. * * @author sergey vetyutnev * */ public interface ApplicationPortAddressing16BitAddress extends UserDataHeaderElement { int getDestinationPort(); int getOriginatorPort(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LIPAPermission; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.SIPTOPermission; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.AMBR; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APN; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APNConfiguration; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APNConfigurationProfile; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APNOIReplacement; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.AllocationRetentionPriority; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ChargingCharacteristics; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.EPSQoSSubscribed; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.FQDN; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNGWAllocationType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNGWIdentity; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNTypeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDPAddress; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.QoSClassIdentifier; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SpecificAPNInfo; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.AMBRImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNConfigurationImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNConfigurationProfileImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNOIReplacementImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.AllocationRetentionPriorityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ChargingCharacteristicsImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.EPSQoSSubscribedImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.EPSSubscriptionDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.FQDNImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDNGWIdentityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDNTypeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDPAddressImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SpecificAPNInfoImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class EPSSubscriptionDataTest { public byte[] getData() { return new byte[] { 48, -126, 2, 73, -128, 9, 48, 12, 17, 17, 119, 22, 62, 34, 12, -126, 1, 4, -93, 47, -128, 1, 2, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -92, -126, 1, -45, 2, 1, 2, 5, 0, -95, -126, 1, -95, 48, -126, 1, -99, -128, 1, 1, -127, 1, 1, -126, 3, 5, 6, 7, -125, 2, 6, 7, -92, 96, -128, 1, 1, -95, 50, -128, 1, 1, -127, 1, -1, -126, 1, -1, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -91, 63, -128, 3, 5, 6, 7, -127, 3, 5, 6, 7, -126, 10, 4, 1, 6, 8, 3, 2, 5, 6, 1, 7, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -122, 1, 1, -121, 0, -120, 2, 6, 5, -87, 47, -128, 1, 2, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -86, 112, 48, 110, -128, 2, 6, 7, -95, 63, -128, 3, 5, 6, 7, -127, 3, 5, 6, 7, -126, 10, 4, 1, 6, 8, 3, 2, 5, 6, 1, 7, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -85, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -116, 3, 5, 6, 7, -115, 9, 48, 12, 17, 17, 119, 22, 62, 34, 12, -114, 1, 0, -113, 1, 2, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -122, 4, -111, 34, 34, -8, -91, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -121, 0, -120, 0 }; }; public byte[] getAPNOIReplacementData() { return new byte[] { 48, 12, 17, 17, 119, 22, 62, 34, 12 }; }; public byte[] getPDPAddressData() { return new byte[] { 5, 6, 7 }; }; public byte[] getAPNData() { return new byte[] { 6, 7 }; }; public byte[] getFQDNData() { return new byte[] { 4, 1, 6, 8, 3, 2, 5, 6, 1, 7 }; }; public byte[] getChargingCharacteristicsData() { return new byte[] { 6, 5 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); EPSSubscriptionDataImpl prim = new EPSSubscriptionDataImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); AMBR ambrPrim = prim.getAmbr(); MAPExtensionContainer extensionContainerambrambrPrim = ambrPrim.getExtensionContainer(); assertEquals(ambrPrim.getMaxRequestedBandwidthDL(), 4); assertEquals(ambrPrim.getMaxRequestedBandwidthUL(), 2); assertNotNull(extensionContainerambrambrPrim); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerambrambrPrim)); assertTrue(Arrays.equals(prim.getApnOiReplacement().getData(), this.getAPNOIReplacementData())); MAPExtensionContainer primMAPExtensionContainer = prim.getExtensionContainer(); assertNotNull(primMAPExtensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(primMAPExtensionContainer)); assertTrue(prim.getMpsCSPriority()); assertTrue(prim.getMpsEPSPriority()); assertEquals(prim.getRfspId().intValue(), 4); ISDNAddressString stnSr = prim.getStnSr(); assertTrue(stnSr.getAddress().equals("22228")); assertEquals(stnSr.getAddressNature(), AddressNature.international_number); assertEquals(stnSr.getNumberingPlan(), NumberingPlan.ISDN); APNConfigurationProfile apnConfigurationProfile = prim.getAPNConfigurationProfile(); assertEquals(apnConfigurationProfile.getDefaultContext(), 2); assertTrue(apnConfigurationProfile.getCompleteDataListIncluded()); MAPExtensionContainer apnConfigurationProfileExtensionContainer = apnConfigurationProfile.getExtensionContainer(); assertNotNull(apnConfigurationProfileExtensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(apnConfigurationProfileExtensionContainer)); ArrayList<APNConfiguration> ePSDataList = apnConfigurationProfile.getEPSDataList(); assertNotNull(ePSDataList); assertEquals(ePSDataList.size(), 1); APNConfiguration apnConfiguration = ePSDataList.get(0); assertEquals(apnConfiguration.getContextId(), 1); assertEquals(apnConfiguration.getPDNType().getPDNTypeValue(), PDNTypeValue.IPv4); PDPAddress servedPartyIPIPv4Address = apnConfiguration.getServedPartyIPIPv4Address(); assertNotNull(servedPartyIPIPv4Address); assertTrue(Arrays.equals(this.getPDPAddressData(), servedPartyIPIPv4Address.getData())); assertTrue(Arrays.equals(apnConfiguration.getApn().getData(), this.getAPNData())); EPSQoSSubscribed ePSQoSSubscribed = apnConfiguration.getEPSQoSSubscribed(); AllocationRetentionPriority allocationRetentionPriority = ePSQoSSubscribed.getAllocationRetentionPriority(); MAPExtensionContainer extensionContainerePSQoSSubscribed = ePSQoSSubscribed.getExtensionContainer(); assertEquals(allocationRetentionPriority.getPriorityLevel(), 1); assertTrue(allocationRetentionPriority.getPreEmptionCapability()); assertTrue(allocationRetentionPriority.getPreEmptionVulnerability()); assertNotNull(allocationRetentionPriority.getExtensionContainer()); ; assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(allocationRetentionPriority.getExtensionContainer())); assertNotNull(extensionContainerePSQoSSubscribed); assertEquals(ePSQoSSubscribed.getQoSClassIdentifier(), QoSClassIdentifier.QCI_1); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerePSQoSSubscribed)); PDNGWIdentity pdnGWIdentity = apnConfiguration.getPdnGwIdentity(); PDPAddress pdnGwIpv4Address = pdnGWIdentity.getPdnGwIpv4Address(); assertNotNull(pdnGwIpv4Address); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv4Address.getData())); PDPAddress pdnGwIpv6Address = pdnGWIdentity.getPdnGwIpv6Address(); assertNotNull(pdnGwIpv6Address); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv6Address.getData())); FQDN pdnGwName = pdnGWIdentity.getPdnGwName(); assertNotNull(pdnGwName); assertTrue(Arrays.equals(this.getFQDNData(), pdnGwName.getData())); assertNotNull(pdnGWIdentity.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(pdnGWIdentity.getExtensionContainer())); assertEquals(apnConfiguration.getPdnGwAllocationType(), PDNGWAllocationType._dynamic); assertTrue(apnConfiguration.getVplmnAddressAllowed()); assertTrue(Arrays .equals(this.getChargingCharacteristicsData(), apnConfiguration.getChargingCharacteristics().getData())); AMBR ambr = apnConfiguration.getAmbr(); MAPExtensionContainer extensionContainerambr = ambr.getExtensionContainer(); assertEquals(ambr.getMaxRequestedBandwidthDL(), 4); assertEquals(ambr.getMaxRequestedBandwidthUL(), 2); assertNotNull(extensionContainerambr); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerambr)); ArrayList<SpecificAPNInfo> specificAPNInfoList = apnConfiguration.getSpecificAPNInfoList(); assertNotNull(specificAPNInfoList); assertEquals(specificAPNInfoList.size(), 1); SpecificAPNInfo specificAPNInfo = specificAPNInfoList.get(0); PDNGWIdentity pdnGWIdentitySpecificAPNInfo = specificAPNInfo.getPdnGwIdentity(); PDPAddress pdnGwIpv4AddressSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwIpv4Address(); assertNotNull(pdnGwIpv4AddressSpecificAPNInfo); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv4AddressSpecificAPNInfo.getData())); PDPAddress pdnGwIpv6AddressSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwIpv6Address(); assertNotNull(pdnGwIpv6AddressSpecificAPNInfo); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv6AddressSpecificAPNInfo.getData())); FQDN pdnGwNameSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwName(); assertNotNull(pdnGwNameSpecificAPNInfo); assertTrue(Arrays.equals(this.getFQDNData(), pdnGwNameSpecificAPNInfo.getData())); assertNotNull(pdnGWIdentitySpecificAPNInfo.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(pdnGWIdentitySpecificAPNInfo.getExtensionContainer())); MAPExtensionContainer extensionContainerspecificAPNInfo = specificAPNInfo.getExtensionContainer(); assertNotNull(extensionContainerspecificAPNInfo); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerspecificAPNInfo)); assertTrue(Arrays.equals(specificAPNInfo.getAPN().getData(), this.getAPNData())); PDPAddress servedPartyIPIPv6Address = apnConfiguration.getServedPartyIPIPv6Address(); assertNotNull(servedPartyIPIPv6Address); assertTrue(Arrays.equals(this.getPDPAddressData(), servedPartyIPIPv6Address.getData())); assertTrue(Arrays.equals(this.getAPNOIReplacementData(), apnConfiguration.getApnOiReplacement().getData())); assertEquals(apnConfiguration.getSiptoPermission(), SIPTOPermission.siptoAllowed); assertEquals(apnConfiguration.getLipaPermission(), LIPAPermission.lipaConditional); MAPExtensionContainer extensionContainer = apnConfiguration.getExtensionContainer(); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); APNOIReplacement apnOiReplacement = new APNOIReplacementImpl(this.getAPNOIReplacementData()); Integer rfspId = new Integer(4); AMBR ambr = new AMBRImpl(2, 4, extensionContainer); int defaultContext = 2; boolean completeDataListIncluded = true; ArrayList<APNConfiguration> ePSDataList = new ArrayList<APNConfiguration>(); int contextId = 1; PDNType pDNType = new PDNTypeImpl(PDNTypeValue.IPv4); PDPAddress servedPartyIPIPv4Address = new PDPAddressImpl(this.getPDPAddressData()); APN apn = new APNImpl(this.getAPNData()); QoSClassIdentifier qoSClassIdentifier = QoSClassIdentifier.QCI_1; AllocationRetentionPriority allocationRetentionPriority = new AllocationRetentionPriorityImpl(1, Boolean.TRUE, Boolean.TRUE, extensionContainer); EPSQoSSubscribed ePSQoSSubscribed = new EPSQoSSubscribedImpl(qoSClassIdentifier, allocationRetentionPriority, extensionContainer); PDPAddress pdnGwIpv4Address = new PDPAddressImpl(this.getPDPAddressData()); PDPAddress pdnGwIpv6Address = new PDPAddressImpl(this.getPDPAddressData()); FQDN pdnGwName = new FQDNImpl(this.getFQDNData()); PDNGWIdentity pdnGwIdentity = new PDNGWIdentityImpl(pdnGwIpv4Address, pdnGwIpv6Address, pdnGwName, extensionContainer); PDNGWAllocationType pdnGwAllocationType = PDNGWAllocationType._dynamic; boolean vplmnAddressAllowed = true; ChargingCharacteristics chargingCharacteristics = new ChargingCharacteristicsImpl(this.getChargingCharacteristicsData()); SpecificAPNInfo specificAPNInfo = new SpecificAPNInfoImpl(apn, pdnGwIdentity, extensionContainer); ArrayList<SpecificAPNInfo> specificAPNInfoList = new ArrayList<SpecificAPNInfo>(); specificAPNInfoList.add(specificAPNInfo); PDPAddress servedPartyIPIPv6Address = new PDPAddressImpl(this.getPDPAddressData()); SIPTOPermission siptoPermission = SIPTOPermission.siptoAllowed; LIPAPermission lipaPermission = LIPAPermission.lipaConditional; APNConfiguration APNConfiguration = new APNConfigurationImpl(contextId, pDNType, servedPartyIPIPv4Address, apn, ePSQoSSubscribed, pdnGwIdentity, pdnGwAllocationType, vplmnAddressAllowed, chargingCharacteristics, ambr, specificAPNInfoList, extensionContainer, servedPartyIPIPv6Address, apnOiReplacement, siptoPermission, lipaPermission); ePSDataList.add(APNConfiguration); APNConfigurationProfile apnConfigurationProfile = new APNConfigurationProfileImpl(defaultContext, completeDataListIncluded, ePSDataList, extensionContainer); ISDNAddressString stnSr = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22228"); boolean mpsCSPriority = true; boolean mpsEPSPriority = true; EPSSubscriptionDataImpl prim = new EPSSubscriptionDataImpl(apnOiReplacement, rfspId, ambr, apnConfigurationProfile, stnSr, extensionContainer, mpsCSPriority, mpsEPSPriority); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * <code> EPS-SubscriptionData ::= SEQUENCE { apn-oi-Replacement [0] APN-OI-Replacement OPTIONAL, -- this apn-oi-Replacement refers to the UE level apn-oi-Replacement. rfsp-id [2] RFSP-ID OPTIONAL, ambr [3] AMBR OPTIONAL, apn-ConfigurationProfile [4] APN-ConfigurationProfile OPTIONAL, stn-sr [6] ISDN-AddressString OPTIONAL, extensionContainer [5] ExtensionContainer OPTIONAL, ..., mps-CSPriority [7] NULL OPTIONAL, mps-EPSPriority [8] NULL OPTIONAL } -- mps-CSPriority by its presence indicates that the UE is subscribed to the eMLPP in -- the CS domain, referring to the 3GPP TS 29.272 [144] for details. -- mps-EPSPriority by its presence indicates that the UE is subscribed to the MPS in -- the EPS domain, referring to the 3GPP TS 29.272 [144] for details. RFSP-ID ::= INTEGER (1..256) </code> * * * * @author sergey vetyutnev * */ public interface EPSSubscriptionData extends Serializable { APNOIReplacement getApnOiReplacement(); Integer getRfspId(); AMBR getAmbr(); APNConfigurationProfile getAPNConfigurationProfile(); ISDNAddressString getStnSr(); MAPExtensionContainer getExtensionContainer(); boolean getMpsCSPriority(); boolean getMpsEPSPriority(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.CSAllocationRetentionPriorityImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class CSAllocationRetentionPriorityTest { public byte[] getData() { return new byte[] { 4, 1, 4 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); CSAllocationRetentionPriorityImpl prim = new CSAllocationRetentionPriorityImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getData(), 4); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { CSAllocationRetentionPriorityImpl prim = new CSAllocationRetentionPriorityImpl(4); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; /** * CS-AllocationRetentionPriority ::= OCTET STRING (SIZE (1)) -- This data type encodes each priority level defined in TS 23.107 * as the binary value -- of the priority level. * * * * @author sergey vetyutnev * */ public interface CSAllocationRetentionPriority extends Serializable { int getData(); } ```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.oam.GGSNInterfaceListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class GGSNInterfaceListTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 5, 96 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); GGSNInterfaceListImpl asc = new GGSNInterfaceListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertFalse(asc.getGn()); assertTrue(asc.getGi()); assertTrue(asc.getGmb()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { GGSNInterfaceListImpl asc = new GGSNInterfaceListImpl(false, true, true); // boolean gn, boolean gi, boolean gmb AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> GGSN-InterfaceList ::= BIT STRING { gn (0), gi (1), gmb (2) } (SIZE (3..8)) -- Other bits than listed above shall be discarded. </code> * * * @author sergey vetyutnev * */ public interface GGSNInterfaceList extends Serializable { boolean getGn(); boolean getGi(); boolean getGmb(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultCallHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.TBcsmTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.TBcsmCamelTDPDataImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class TBcsmCamelTDPDataTest { private byte[] getEncodedData() { return new byte[] { 48, 16, 10, 1, 12, 2, 1, 3, -128, 5, -111, 17, 34, 51, -13, -127, 1, 1 }; } private byte[] getEncodedDataFull() { return new byte[] { 48, 57, 10, 1, 12, 2, 1, 3, -128, 5, -111, 17, 34, 51, -13, -127, 1, 1, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; } @Test(groups = { "functional.decode", "service.mobility.subscriberManagement" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); TBcsmCamelTDPDataImpl ind = new TBcsmCamelTDPDataImpl(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ind.decodeAll(asn); assertEquals(ind.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.termAttemptAuthorized); assertEquals(ind.getServiceKey(), 3); assertEquals(ind.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(ind.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(ind.getGsmSCFAddress().getAddress().equals("1122333")); assertEquals(ind.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertNull(ind.getExtensionContainer()); rawData = getEncodedDataFull(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new TBcsmCamelTDPDataImpl(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ind.decodeAll(asn); assertEquals(ind.getTBcsmTriggerDetectionPoint(), TBcsmTriggerDetectionPoint.termAttemptAuthorized); assertEquals(ind.getServiceKey(), 3); assertEquals(ind.getGsmSCFAddress().getAddressNature(), AddressNature.international_number); assertEquals(ind.getGsmSCFAddress().getNumberingPlan(), NumberingPlan.ISDN); assertTrue(ind.getGsmSCFAddress().getAddress().equals("1122333")); assertEquals(ind.getDefaultCallHandling(), DefaultCallHandling.releaseCall); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.mobility.subscriberManagement" }) public void testEncode() throws Exception { ISDNAddressStringImpl gsmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1122333"); TBcsmCamelTDPDataImpl ind = new TBcsmCamelTDPDataImpl(TBcsmTriggerDetectionPoint.termAttemptAuthorized, 3, gsmSCFAddress, DefaultCallHandling.releaseCall, null); AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); ind = new TBcsmCamelTDPDataImpl(TBcsmTriggerDetectionPoint.termAttemptAuthorized, 3, gsmSCFAddress, DefaultCallHandling.releaseCall, MAPExtensionContainerTest.GetTestExtensionContainer()); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataFull(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * T-BcsmCamelTDPData ::= SEQUENCE { t-BcsmTriggerDetectionPoint T-BcsmTriggerDetectionPoint, serviceKey ServiceKey, * gsmSCF-Address [0] ISDN-AddressString, defaultCallHandling [1] DefaultCallHandling, extensionContainer [2] ExtensionContainer * OPTIONAL, ... } * * ServiceKey ::= INTEGER (0..2147483647) * * * * @author sergey vetyutnev * */ public interface TBcsmCamelTDPData extends Serializable { TBcsmTriggerDetectionPoint getTBcsmTriggerDetectionPoint(); long getServiceKey(); ISDNAddressString getGsmSCFAddress(); DefaultCallHandling getDefaultCallHandling(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.*; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ExtQoSSubscribed_BitRateExtendedImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ExtQoSSubscribed_BitRateExtendedTest { @Test(groups = { "functional.decode", "mobility.subscriberManagement" }) public void testDecode() throws Exception { ExtQoSSubscribed_BitRateExtendedImpl prim = new ExtQoSSubscribed_BitRateExtendedImpl(0, true); assertEquals(prim.getBitRate(), 0); assertTrue(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(1, true); assertEquals(prim.getBitRate(), 8700); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(10, true); assertEquals(prim.getBitRate(), 9600); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(74, true); assertEquals(prim.getBitRate(), 16000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(75, true); assertEquals(prim.getBitRate(), 17000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(158, true); assertEquals(prim.getBitRate(), 100000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(186, true); assertEquals(prim.getBitRate(), 128000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(187, true); assertEquals(prim.getBitRate(), 130000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(192, true); assertEquals(prim.getBitRate(), 140000); assertFalse(prim.isUseNonextendedValue()); prim = new ExtQoSSubscribed_BitRateExtendedImpl(250, true); assertEquals(prim.getBitRate(), 256000); assertFalse(prim.isUseNonextendedValue()); } @Test(groups = { "functional.encode", "mobility.subscriberManagement" }) public void testEncode() throws Exception { ExtQoSSubscribed_BitRateExtendedImpl prim = new ExtQoSSubscribed_BitRateExtendedImpl(8700, false); assertEquals(prim.getSourceData(), 1); prim = new ExtQoSSubscribed_BitRateExtendedImpl(9600, false); assertEquals(prim.getSourceData(), 10); prim = new ExtQoSSubscribed_BitRateExtendedImpl(16000, false); assertEquals(prim.getSourceData(), 74); prim = new ExtQoSSubscribed_BitRateExtendedImpl(17000, false); assertEquals(prim.getSourceData(), 75); prim = new ExtQoSSubscribed_BitRateExtendedImpl(100000, false); assertEquals(prim.getSourceData(), 158); prim = new ExtQoSSubscribed_BitRateExtendedImpl(128000, false); assertEquals(prim.getSourceData(), 186); prim = new ExtQoSSubscribed_BitRateExtendedImpl(130000, false); assertEquals(prim.getSourceData(), 187); prim = new ExtQoSSubscribed_BitRateExtendedImpl(140000, false); assertEquals(prim.getSourceData(), 192); prim = new ExtQoSSubscribed_BitRateExtendedImpl(256000, false); assertEquals(prim.getSourceData(), 250); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; /** * <code> Maximum bit rate for downlink (extended), octet 15 Bits 8 7 6 5 4 3 2 1 In MS to network direction and in network to MS direction: 0 0 0 0 0 0 0 0 Use the value indicated by the Maximum bit rate for downlink in octet 9. For all other values: Ignore the value indicated by the Maximum bit rate for downlink in octet 9 and use the following value: 0 0 0 0 0 0 0 1 The maximum bit rate is 8600 kbps + ((the binary coded value in 8 bits) * 100 kbps), 0 1 0 0 1 0 1 0 giving a range of values from 8700 kbps to 16000 kbps in 100 kbps increments. 0 1 0 0 1 0 1 1 The maximum bit rate is 16 Mbps + ((the binary coded value in 8 bits - 01001010) * 1 Mbps), 1 0 1 1 1 0 1 0 giving a range of values from 17 Mbps to 128 Mbps in 1 Mbps increments. 1 0 1 1 1 0 1 1 The maximum bit rate is 128 Mbps + ((the binary coded value in 8 bits - 10111010) * 2 Mbps), 1 1 1 1 1 0 1 0 giving a range of values from 130 Mbps to 256 Mbps in 2 Mbps increments. The network shall map all other values not explicitly defined onto one of the values defined in this version of the protocol. The network shall return a negotiated value which is explicitly defined in this version of the protocol. The MS shall map all other values not explicitly defined onto the maximum value defined in this version of the protocol. </code> * * @author sergey vetyutnev * */ public interface ExtQoSSubscribed_BitRateExtended { int getSourceData(); boolean isUseNonextendedValue(); /** * @return BitRate (kbit/s) value or 0 when source==0 or not specified in * 23.107 */ int getBitRate(); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.AddressString; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA; import org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_OA; import org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo; import org.restcomm.protocols.ss7.map.primitives.AddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.IMSIImpl; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.sms.MoForwardShortMessageRequestImpl; import org.restcomm.protocols.ss7.map.service.sms.SM_RP_DAImpl; import org.restcomm.protocols.ss7.map.service.sms.SM_RP_OAImpl; import org.restcomm.protocols.ss7.map.service.sms.SmsSignalInfoImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class MoForwardShortMessageRequestTest { private byte[] getEncodedDataSimple() { return new byte[] { 48, 38, -124, 7, -111, 34, 51, 67, -103, 32, 50, -126, 8, -111, 50, 17, 50, 33, 67, 51, -12, 4, 17, 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 }; } private byte[] getEncodedDataComplex() { return new byte[] { 48, 71, -124, 8, -111, 50, 17, 50, 33, 67, 51, -12, -126, 7, -111, 34, 51, 67, -103, 32, 50, 4, 40, 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 8, 0, 1, 33, 50, 51, -108, 9, -14 }; } private byte[] getEncodedDataNoDaOa() { return new byte[] { 48, 58, -123, 0, -123, 0, 4, 52, 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 99, 88, 77, 66, 55, 44, 44, 33, 22, 11, 11, 0 }; } private byte[] getEncodedDataFull() { return new byte[] { 48, 80, -128, 8, 2, 1, 17, 50, 84, 118, -104, -16, -124, 6, -74, 16, 50, 84, 118, -104, 4, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 4, 8, 66, -128, 24, 33, 50, 67, 84, -11 }; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedDataSimple(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); MoForwardShortMessageRequestImpl ind = new MoForwardShortMessageRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); SM_RP_DA da = ind.getSM_RP_DA(); SM_RP_OA oa = ind.getSM_RP_OA(); SmsSignalInfo ui = ind.getSM_RP_UI(); assertEquals(da.getServiceCentreAddressDA().getAddressNature(), AddressNature.international_number); assertEquals(da.getServiceCentreAddressDA().getNumberingPlan(), NumberingPlan.ISDN); assertEquals(da.getServiceCentreAddressDA().getAddress(), "223334990223"); assertEquals(oa.getMsisdn().getAddressNature(), AddressNature.international_number); assertEquals(oa.getMsisdn().getNumberingPlan(), NumberingPlan.ISDN); assertEquals(oa.getMsisdn().getAddress(), "2311231234334"); assertTrue(Arrays.equals(ui.getData(), new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 })); rawData = getEncodedDataComplex(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new MoForwardShortMessageRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); da = ind.getSM_RP_DA(); oa = ind.getSM_RP_OA(); ui = ind.getSM_RP_UI(); IMSI imsi = ind.getIMSI(); assertEquals(da.getServiceCentreAddressDA().getAddressNature(), AddressNature.international_number); assertEquals(da.getServiceCentreAddressDA().getNumberingPlan(), NumberingPlan.ISDN); assertEquals(da.getServiceCentreAddressDA().getAddress(), "2311231234334"); assertEquals(oa.getMsisdn().getAddressNature(), AddressNature.international_number); assertEquals(oa.getMsisdn().getNumberingPlan(), NumberingPlan.ISDN); assertEquals(oa.getMsisdn().getAddress(), "223334990223"); assertTrue(Arrays.equals(ui.getData(), new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 })); // assertEquals( (long)imsi.getMCC(),1); // assertEquals( (long)imsi.getMNC(),1); assertEquals(imsi.getData(), "001012233349902"); rawData = getEncodedDataNoDaOa(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new MoForwardShortMessageRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); da = ind.getSM_RP_DA(); oa = ind.getSM_RP_OA(); ui = ind.getSM_RP_UI(); assertNull(da.getServiceCentreAddressDA()); assertNull(da.getIMSI()); assertNull(da.getLMSI()); assertNull(oa.getMsisdn()); assertNull(oa.getServiceCentreAddressOA()); assertTrue(Arrays.equals(ui.getData(), new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 99, 88, 77, 66, 55, 44, 44, 33, 22, 11, 11, 0 })); rawData = getEncodedDataFull(); asn = new AsnInputStream(rawData); tag = asn.readTag(); ind = new MoForwardShortMessageRequestImpl(); ind.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); da = ind.getSM_RP_DA(); oa = ind.getSM_RP_OA(); ui = ind.getSM_RP_UI(); imsi = ind.getIMSI(); // assertEquals( (long)da.getIMSI().getMCC(),201); // assertEquals( (long)da.getIMSI().getMNC(),1); assertEquals(da.getIMSI().getData(), "201011234567890"); assertEquals(oa.getServiceCentreAddressOA().getAddressNature(), AddressNature.network_specific_number); assertEquals(oa.getServiceCentreAddressOA().getNumberingPlan(), NumberingPlan.land_mobile); assertEquals(oa.getServiceCentreAddressOA().getAddress(), "0123456789"); assertTrue(Arrays.equals(ui.getData(), new byte[] { 11, 22, 33, 44, 55, 66, 77, 88, 99 })); // assertEquals( (long)imsi.getMCC(),240); // assertEquals( (long)imsi.getMNC(),88); assertEquals(imsi.getData(), "240881122334455"); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(ind.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { AddressString sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "223334990223"); SM_RP_DA sm_RP_DA = new SM_RP_DAImpl(sca); ISDNAddressString msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2311231234334"); SM_RP_OAImpl sm_RP_OA = new SM_RP_OAImpl(); sm_RP_OA.setMsisdn(msisdn); SmsSignalInfo sm_RP_UI = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8 }, null); MoForwardShortMessageRequestImpl ind = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, null, null); AsnOutputStream asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedDataSimple(); assertTrue(Arrays.equals(rawData, encodedData)); sca = new AddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2311231234334"); sm_RP_DA = new SM_RP_DAImpl(sca); msisdn = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "223334990223"); sm_RP_OA = new SM_RP_OAImpl(); sm_RP_OA.setMsisdn(msisdn); sm_RP_UI = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4 }, null); IMSI imsi = new IMSIImpl("001012233349902"); ind = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, null, imsi); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataComplex(); assertTrue(Arrays.equals(rawData, encodedData)); sm_RP_DA = new SM_RP_DAImpl(); sm_RP_OA = new SM_RP_OAImpl(); sm_RP_UI = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55, 66, 77, 0, 1, 2, 3, 4, 5, 6, 7, 9, 8, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 99, 88, 77, 66, 55, 44, 44, 33, 22, 11, 11, 0 }, null); ind = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, null, null); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataNoDaOa(); assertTrue(Arrays.equals(rawData, encodedData)); IMSI imsi0 = new IMSIImpl("201011234567890"); sm_RP_DA = new SM_RP_DAImpl(imsi0); msisdn = new ISDNAddressStringImpl(AddressNature.network_specific_number, NumberingPlan.land_mobile, "0123456789"); sm_RP_OA = new SM_RP_OAImpl(); sm_RP_OA.setServiceCentreAddressOA(msisdn); sm_RP_UI = new SmsSignalInfoImpl(new byte[] { 11, 22, 33, 44, 55, 66, 77, 88, 99 }, null); MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); imsi = new IMSIImpl("240881122334455"); ind = new MoForwardShortMessageRequestImpl(sm_RP_DA, sm_RP_OA, sm_RP_UI, extensionContainer, imsi); asnOS = new AsnOutputStream(); ind.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedDataFull(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import org.restcomm.protocols.ss7.map.api.primitives.IMSI; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * MAP V3: * * mo-ForwardSM OPERATION ::= { --Timer ml ARGUMENT MO-ForwardSM-Arg RESULT MO-ForwardSM-Res -- optional ERRORS { systemFailure * | unexpectedDataValue | facilityNotSupported | sm-DeliveryFailure} CODE local:46 } * * MO-ForwardSM-Arg ::= SEQUENCE { sm-RP-DA SM-RP-DA, sm-RP-OA SM-RP-OA, sm-RP-UI SignalInfo, extensionContainer * ExtensionContainer OPTIONAL, ... , imsi IMSI OPTIONAL } * * * * * @author sergey vetyutnev * */ public interface MoForwardShortMessageRequest extends SmsMessage { SM_RP_DA getSM_RP_DA(); SM_RP_OA getSM_RP_OA(); SmsSignalInfo getSM_RP_UI(); MAPExtensionContainer getExtensionContainer(); IMSI getIMSI(); } ```
```package org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall; import javolution.xml.XMLFormat; import javolution.xml.stream.XMLStreamException; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.cap.api.CAPException; import org.restcomm.protocols.ss7.cap.api.CAPMessageType; import org.restcomm.protocols.ss7.cap.api.CAPOperationCode; import org.restcomm.protocols.ss7.cap.api.CAPParsingComponentException; import org.restcomm.protocols.ss7.cap.api.CAPParsingComponentExceptionReason; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.ActivityTestResponse; /** * * @author sergey vetyutnev * */ public class ActivityTestResponseImpl extends CircuitSwitchedCallMessageImpl implements ActivityTestResponse { public static final String _PrimitiveName = "ActivityTestResponse"; @Override public CAPMessageType getMessageType() { return CAPMessageType.activityTest_Response; } @Override public int getOperationCode() { return CAPOperationCode.activityTest; } @Override public int getTag() throws CAPException { throw new CAPException("Parameter " + _PrimitiveName + ": does not support encoding"); } @Override public int getTagClass() { return 0; } @Override public boolean getIsPrimitive() { return false; } @Override public void decodeAll(AsnInputStream ansIS) throws CAPParsingComponentException { throw new CAPParsingComponentException("Parameter " + _PrimitiveName + ": does not support encoding", CAPParsingComponentExceptionReason.MistypedParameter); } @Override public void decodeData(AsnInputStream ansIS, int length) throws CAPParsingComponentException { throw new CAPParsingComponentException("Parameter " + _PrimitiveName + ": does not support encoding", CAPParsingComponentExceptionReason.MistypedParameter); } @Override public void encodeAll(AsnOutputStream asnOs) throws CAPException { throw new CAPException("Parameter " + _PrimitiveName + ": does not support encoding"); } @Override public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws CAPException { throw new CAPException("Parameter " + _PrimitiveName + ": does not support encoding"); } @Override public void encodeData(AsnOutputStream asnOs) throws CAPException { throw new CAPException("Parameter " + _PrimitiveName + ": does not support encoding"); } /** * XML Serialization/Deserialization */ protected static final XMLFormat<ActivityTestResponseImpl> ACTIVITY_TEST_RESPONSE_XML = new XMLFormat<ActivityTestResponseImpl>( ActivityTestResponseImpl.class) { @Override public void read(javolution.xml.XMLFormat.InputElement xml, ActivityTestResponseImpl activityTestResponse) throws XMLStreamException { CIRCUIT_SWITCHED_CALL_MESSAGE_XML.read(xml, activityTestResponse); } @Override public void write(ActivityTestResponseImpl activityTestResponse, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { CIRCUIT_SWITCHED_CALL_MESSAGE_XML.write(activityTestResponse, xml); } }; @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(_PrimitiveName); sb.append(" ["); this.addInvokeIdInfo(sb); sb.append("]"); return sb.toString(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive; import java.io.IOException; import javolution.xml.XMLFormat; import javolution.xml.stream.XMLStreamException; import org.mobicents.protocols.asn.AsnException; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.CAPException; import org.restcomm.protocols.ss7.cap.api.CAPParsingComponentException; import org.restcomm.protocols.ss7.cap.api.CAPParsingComponentExceptionReason; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.Tone; import org.restcomm.protocols.ss7.cap.primitives.SequenceBase; /** * * @author sergey vetyutnev * */ public class ToneImpl extends SequenceBase implements Tone { public static final int _ID_toneID = 0; public static final int _ID_duration = 1; private static final String TONE_ID = "toneID"; private static final String DURATION = "duration"; private int toneID; private Integer duration; public ToneImpl() { super("Tone"); } public ToneImpl(int toneID, Integer duration) { super("Tone"); this.toneID = toneID; this.duration = duration; } @Override public int getToneID() { return toneID; } @Override public Integer getDuration() { return duration; } protected void _decode(AsnInputStream ansIS, int length) throws CAPParsingComponentException, IOException, AsnException { this.toneID = 0; this.duration = null; boolean toneIDRecieved = false; AsnInputStream ais = ansIS.readSequenceStreamData(length); while (true) { if (ais.available() == 0) break; int tag = ais.readTag(); if (ais.getTagClass() == Tag.CLASS_CONTEXT_SPECIFIC) { switch (tag) { case _ID_toneID: this.toneID = (int) ais.readInteger(); toneIDRecieved = true; break; case _ID_duration: this.duration = (int) ais.readInteger(); break; default: ais.advanceElement(); break; } } else { ais.advanceElement(); } } if (toneIDRecieved == false) throw new CAPParsingComponentException("Error while decoding " + _PrimitiveName + ": toneID is mandatory but not found", CAPParsingComponentExceptionReason.MistypedParameter); } @Override public void encodeData(AsnOutputStream aos) throws CAPException { try { aos.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _ID_toneID, this.toneID); if (this.duration != null) aos.writeInteger(Tag.CLASS_CONTEXT_SPECIFIC, _ID_duration, this.duration); } catch (IOException e) { throw new CAPException("IOException when encoding " + _PrimitiveName + ": " + e.getMessage(), e); } catch (AsnException e) { throw new CAPException("AsnException when encoding " + _PrimitiveName + ": " + e.getMessage(), e); } } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(_PrimitiveName); sb.append(" ["); sb.append("toneID="); sb.append(this.toneID); if (this.duration != null) { sb.append(", duration="); sb.append(this.duration); } sb.append("]"); return sb.toString(); } /** * XML Serialization/Deserialization */ protected static final XMLFormat<ToneImpl> TONE_XML = new XMLFormat<ToneImpl>(ToneImpl.class) { @Override public void read(javolution.xml.XMLFormat.InputElement xml, ToneImpl tone) throws XMLStreamException { tone.toneID = xml.getAttribute(TONE_ID, 0); int vali = xml.getAttribute(DURATION, -1); if (vali != -1) tone.duration = vali; } @Override public void write(ToneImpl tone, javolution.xml.XMLFormat.OutputElement xml) throws XMLStreamException { xml.setAttribute(TONE_ID, tone.toneID); if (tone.duration != null) xml.setAttribute(DURATION, (int) tone.duration); } }; } ```
```package org.restcomm.protocols.ss7.map.service.mobility.authentication; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.mobility.authentication.Cksn; import org.restcomm.protocols.ss7.map.api.service.mobility.authentication.Kc; import org.restcomm.protocols.ss7.map.service.mobility.authentication.CksnImpl; import org.restcomm.protocols.ss7.map.service.mobility.authentication.GSMSecurityContextDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.authentication.KcImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class GSMSecurityContextDataTest { public byte[] getData() { return new byte[] { 48, 13, 4, 8, 4, 4, 1, 2, 3, 4, 4, 4, 4, 1, 4 }; }; public byte[] getDataKc() { return new byte[] { 4, 4, 1, 2, 3, 4, 4, 4 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); GSMSecurityContextDataImpl prim = new GSMSecurityContextDataImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(Arrays.equals(prim.getKc().getData(), getDataKc())); assertEquals(prim.getCksn().getData(), 4); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { Kc kc = new KcImpl(getDataKc()); Cksn cksn = new CksnImpl(4); GSMSecurityContextDataImpl prim = new GSMSecurityContextDataImpl(kc, cksn); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.authentication; import java.io.Serializable; /** * GSM-SecurityContextData ::= SEQUENCE { kc Kc, cksn Cksn, ... } * * * @author sergey vetyutnev * */ public interface GSMSecurityContextData extends Serializable { Kc getKc(); Cksn getCksn(); } ```
```package org.restcomm.protocols.ss7.tcap.asn; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.tcap.asn.AbortSource; import org.restcomm.protocols.ss7.tcap.asn.AbortSourceType; import org.restcomm.protocols.ss7.tcap.asn.DialogAbortAPDU; import org.restcomm.protocols.ss7.tcap.asn.TcapFactory; import org.restcomm.protocols.ss7.tcap.asn.UserInformation; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ @Test(groups = { "asn" }) public class DialogAbortAPDUTest { private byte[] getData() { return new byte[] { 100, 3, (byte) 128, 1, 0 }; } private byte[] getData2() { return new byte[] { 100, 21, (byte) 128, 1, 1, (byte) 190, 16, 40, 14, 6, 7, 4, 0, 0, 1, 1, 1, 1, (byte) 160, 3, 1, 2, 3 }; } @Test(groups = { "functional.decode" }) public void testDecode() throws Exception { byte[] b = getData(); AsnInputStream asnIs = new AsnInputStream(b); int tag = asnIs.readTag(); assertEquals(4, tag); DialogAbortAPDU d = TcapFactory.createDialogAPDUAbort(); d.decode(asnIs); AbortSource as = d.getAbortSource(); assertEquals(AbortSourceType.User, as.getAbortSourceType()); UserInformation ui = d.getUserInformation(); assertNull(ui); AsnOutputStream aos = new AsnOutputStream(); d.encode(aos); assertTrue(Arrays.equals(b, aos.toByteArray())); b = getData2(); asnIs = new AsnInputStream(b); tag = asnIs.readTag(); assertEquals(4, tag); d = TcapFactory.createDialogAPDUAbort(); d.decode(asnIs); as = d.getAbortSource(); assertEquals(AbortSourceType.Provider, as.getAbortSourceType()); ui = d.getUserInformation(); assertNotNull(ui); assertTrue(Arrays.equals(new byte[] { 1, 2, 3 }, ui.getEncodeType())); aos = new AsnOutputStream(); d.encode(aos); assertTrue(Arrays.equals(b, aos.toByteArray())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.tcap.asn; /** * @author baranowb * */ public interface DialogAbortAPDU extends DialogAPDU { // mandatory void setAbortSource(AbortSource as); AbortSource getAbortSource(); // opt UserInformation getUserInformation(); void setUserInformation(UserInformation ui); } ```
```package org.restcomm.protocols.ss7.map.service.sms; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.sms.ReadyForSMResponseImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class ReadyForSMResponseTest { private byte[] getEncodedData() { return new byte[] { 48, 41, 48, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33 }; } @Test(groups = { "functional.decode", "service.sms" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); ReadyForSMResponseImpl impl = new ReadyForSMResponseImpl(); impl.decodeAll(asn); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(impl.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.sms" }) public void testEncode() throws Exception { ReadyForSMResponseImpl impl = new ReadyForSMResponseImpl(MAPExtensionContainerTest.GetTestExtensionContainer()); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.sms; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * <code> MAP V3: ReadyForSM-Res ::= SEQUENCE { extensionContainer ExtensionContainer OPTIONAL, ... } <code> * * * @author sergey vetyutnev * */ public interface ReadyForSMResponse extends SmsMessage { MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.tcap.asn; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.tcap.asn.DialogResponseAPDU; import org.restcomm.protocols.ss7.tcap.asn.DialogServiceProviderType; import org.restcomm.protocols.ss7.tcap.asn.DialogServiceUserType; import org.restcomm.protocols.ss7.tcap.asn.Result; import org.restcomm.protocols.ss7.tcap.asn.ResultSourceDiagnostic; import org.restcomm.protocols.ss7.tcap.asn.ResultType; import org.restcomm.protocols.ss7.tcap.asn.TcapFactory; import org.restcomm.protocols.ss7.tcap.asn.UserInformation; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ @Test(groups = { "asn" }) public class DialogResponseAPDUTest { private byte[] getData() { return new byte[] { 97, 44, (byte) 128, 2, 7, (byte) 128, (byte) 161, 9, 6, 7, 4, 0, 0, 1, 0, 21, 2, (byte) 162, 3, 2, 1, 0, (byte) 163, 5, (byte) 161, 3, 2, 1, 0, (byte) 190, 15, 40, 13, 6, 7, 4, 0, 0, 1, 1, 1, 1, (byte) 160, 2, (byte) 161, 0 }; } private byte[] getData2() { return new byte[] { 97, 27, (byte) 128, 2, 7, (byte) 128, (byte) 161, 9, 6, 7, 4, 0, 0, 1, 0, 25, 2, (byte) 162, 3, 2, 1, 1, (byte) 163, 5, (byte) 161, 3, 2, 1, 2 }; } private byte[] getData3() { return new byte[] { 97, 27, (byte) 128, 2, 7, (byte) 128, (byte) 161, 9, 6, 7, 4, 0, 0, 1, 0, 25, 2, (byte) 162, 3, 2, 1, 1, (byte) 163, 5, (byte) 162, 3, 2, 1, 2 }; } @Test(groups = { "functional.encode", "functional.decode" }) public void testResponseAPDU() throws Exception { byte[] b = getData(); AsnInputStream asnIs = new AsnInputStream(b); int tag = asnIs.readTag(); assertEquals(1, tag); DialogResponseAPDU d = TcapFactory.createDialogAPDUResponse(); d.decode(asnIs); assertTrue(Arrays.equals(new long[] { 0, 4, 0, 0, 1, 0, 21, 2 }, d.getApplicationContextName().getOid())); Result r = d.getResult(); assertEquals(ResultType.Accepted, r.getResultType()); ResultSourceDiagnostic diag = d.getResultSourceDiagnostic(); assertNotNull(diag.getDialogServiceUserType()); assertEquals(DialogServiceUserType.Null, diag.getDialogServiceUserType()); UserInformation ui = d.getUserInformation(); assertNotNull(ui); assertNotNull(ui.getEncodeType()); ui.getEncodeType(); assertTrue(Arrays.equals(new byte[] { -95, 0 }, ui.getEncodeType())); AsnOutputStream aos = new AsnOutputStream(); d.encode(aos); assertTrue(Arrays.equals(b, aos.toByteArray())); b = getData2(); asnIs = new AsnInputStream(b); tag = asnIs.readTag(); assertEquals(1, tag); d = TcapFactory.createDialogAPDUResponse(); d.decode(asnIs); assertTrue(Arrays.equals(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 }, d.getApplicationContextName().getOid())); r = d.getResult(); assertEquals(ResultType.RejectedPermanent, r.getResultType()); diag = d.getResultSourceDiagnostic(); assertNotNull(diag.getDialogServiceUserType()); assertEquals(DialogServiceUserType.AcnNotSupported, diag.getDialogServiceUserType()); ui = d.getUserInformation(); assertNull(ui); aos = new AsnOutputStream(); d.encode(aos); assertTrue(Arrays.equals(b, aos.toByteArray())); b = getData3(); asnIs = new AsnInputStream(b); tag = asnIs.readTag(); assertEquals(1, tag); d = TcapFactory.createDialogAPDUResponse(); d.decode(asnIs); assertTrue(Arrays.equals(new long[] { 0, 4, 0, 0, 1, 0, 25, 2 }, d.getApplicationContextName().getOid())); r = d.getResult(); assertEquals(ResultType.RejectedPermanent, r.getResultType()); diag = d.getResultSourceDiagnostic(); assertNotNull(diag.getDialogServiceProviderType()); assertEquals(DialogServiceProviderType.NoCommonDialogPortion, diag.getDialogServiceProviderType()); ui = d.getUserInformation(); assertNull(ui); aos = new AsnOutputStream(); d.encode(aos); assertTrue(Arrays.equals(b, aos.toByteArray())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.tcap.asn; /** * @author baranowb * */ public interface DialogResponseAPDU extends DialogAPDU { void setDoNotSendProtocolVersion(boolean val); ProtocolVersion getProtocolVersion(); // mandatory ApplicationContextName getApplicationContextName(); void setApplicationContextName(ApplicationContextName acn); Result getResult(); void setResult(Result acn); ResultSourceDiagnostic getResultSourceDiagnostic(); void setResultSourceDiagnostic(ResultSourceDiagnostic acn); // opt UserInformation getUserInformation(); void setUserInformation(UserInformation ui); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.LIPAPermission; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.SIPTOPermission; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.AMBR; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APN; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APNConfiguration; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.APNOIReplacement; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.AllocationRetentionPriority; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.ChargingCharacteristics; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.EPSQoSSubscribed; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.FQDN; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNGWAllocationType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNGWIdentity; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDNTypeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.PDPAddress; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.QoSClassIdentifier; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SpecificAPNInfo; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.AMBRImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNConfigurationImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNConfigurationProfileImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.APNOIReplacementImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.AllocationRetentionPriorityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.ChargingCharacteristicsImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.EPSQoSSubscribedImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.FQDNImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDNGWIdentityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDNTypeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.PDPAddressImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SpecificAPNInfoImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class APNConfigurationProfileTest { public byte[] getData() { return new byte[] { 48, -126, 1, -45, 2, 1, 2, 5, 0, -95, -126, 1, -95, 48, -126, 1, -99, -128, 1, 1, -127, 1, 1, -126, 3, 5, 6, 7, -125, 2, 6, 7, -92, 96, -128, 1, 1, -95, 50, -128, 1, 1, -127, 1, -1, -126, 1, -1, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -91, 63, -128, 3, 5, 6, 7, -127, 3, 5, 6, 7, -126, 10, 4, 1, 6, 8, 3, 2, 5, 6, 1, 7, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -122, 1, 1, -121, 0, -120, 2, 6, 5, -87, 47, -128, 1, 2, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -86, 112, 48, 110, -128, 2, 6, 7, -95, 63, -128, 3, 5, 6, 7, -127, 3, 5, 6, 7, -126, 10, 4, 1, 6, 8, 3, 2, 5, 6, 1, 7, -93, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -85, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -116, 3, 5, 6, 7, -115, 9, 48, 12, 17, 17, 119, 22, 62, 34, 12, -114, 1, 0, -113, 1, 2, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33 }; }; public byte[] getPDPAddressData() { return new byte[] { 5, 6, 7 }; }; public byte[] getAPNData() { return new byte[] { 6, 7 }; }; public byte[] getFQDNData() { return new byte[] { 4, 1, 6, 8, 3, 2, 5, 6, 1, 7 }; }; public byte[] getChargingCharacteristicsData() { return new byte[] { 6, 5 }; }; public byte[] getAPNOIReplacementData() { return new byte[] { 48, 12, 17, 17, 119, 22, 62, 34, 12 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); APNConfigurationProfileImpl prim = new APNConfigurationProfileImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getDefaultContext(), 2); assertTrue(prim.getCompleteDataListIncluded()); MAPExtensionContainer primExtensionContainer = prim.getExtensionContainer(); assertNotNull(primExtensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(primExtensionContainer)); ArrayList<APNConfiguration> ePSDataList = prim.getEPSDataList(); assertNotNull(ePSDataList); assertEquals(ePSDataList.size(), 1); APNConfiguration apnConfiguration = ePSDataList.get(0); assertEquals(apnConfiguration.getContextId(), 1); assertEquals(apnConfiguration.getPDNType().getPDNTypeValue(), PDNTypeValue.IPv4); PDPAddress servedPartyIPIPv4Address = apnConfiguration.getServedPartyIPIPv4Address(); assertNotNull(servedPartyIPIPv4Address); assertTrue(Arrays.equals(this.getPDPAddressData(), servedPartyIPIPv4Address.getData())); assertTrue(Arrays.equals(apnConfiguration.getApn().getData(), this.getAPNData())); EPSQoSSubscribed ePSQoSSubscribed = apnConfiguration.getEPSQoSSubscribed(); AllocationRetentionPriority allocationRetentionPriority = ePSQoSSubscribed.getAllocationRetentionPriority(); MAPExtensionContainer extensionContainerePSQoSSubscribed = ePSQoSSubscribed.getExtensionContainer(); assertEquals(allocationRetentionPriority.getPriorityLevel(), 1); assertTrue(allocationRetentionPriority.getPreEmptionCapability()); assertTrue(allocationRetentionPriority.getPreEmptionVulnerability()); assertNotNull(allocationRetentionPriority.getExtensionContainer()); ; assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(allocationRetentionPriority.getExtensionContainer())); assertNotNull(extensionContainerePSQoSSubscribed); assertEquals(ePSQoSSubscribed.getQoSClassIdentifier(), QoSClassIdentifier.QCI_1); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerePSQoSSubscribed)); PDNGWIdentity pdnGWIdentity = apnConfiguration.getPdnGwIdentity(); PDPAddress pdnGwIpv4Address = pdnGWIdentity.getPdnGwIpv4Address(); assertNotNull(pdnGwIpv4Address); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv4Address.getData())); PDPAddress pdnGwIpv6Address = pdnGWIdentity.getPdnGwIpv6Address(); assertNotNull(pdnGwIpv6Address); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv6Address.getData())); FQDN pdnGwName = pdnGWIdentity.getPdnGwName(); assertNotNull(pdnGwName); assertTrue(Arrays.equals(this.getFQDNData(), pdnGwName.getData())); assertNotNull(pdnGWIdentity.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(pdnGWIdentity.getExtensionContainer())); assertEquals(apnConfiguration.getPdnGwAllocationType(), PDNGWAllocationType._dynamic); assertTrue(apnConfiguration.getVplmnAddressAllowed()); assertTrue(Arrays .equals(this.getChargingCharacteristicsData(), apnConfiguration.getChargingCharacteristics().getData())); AMBR ambr = apnConfiguration.getAmbr(); MAPExtensionContainer extensionContainerambr = ambr.getExtensionContainer(); assertEquals(ambr.getMaxRequestedBandwidthDL(), 4); assertEquals(ambr.getMaxRequestedBandwidthUL(), 2); assertNotNull(extensionContainerambr); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerambr)); ArrayList<SpecificAPNInfo> specificAPNInfoList = apnConfiguration.getSpecificAPNInfoList(); assertNotNull(specificAPNInfoList); assertEquals(specificAPNInfoList.size(), 1); SpecificAPNInfo specificAPNInfo = specificAPNInfoList.get(0); PDNGWIdentity pdnGWIdentitySpecificAPNInfo = specificAPNInfo.getPdnGwIdentity(); PDPAddress pdnGwIpv4AddressSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwIpv4Address(); assertNotNull(pdnGwIpv4AddressSpecificAPNInfo); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv4AddressSpecificAPNInfo.getData())); PDPAddress pdnGwIpv6AddressSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwIpv6Address(); assertNotNull(pdnGwIpv6AddressSpecificAPNInfo); assertTrue(Arrays.equals(this.getPDPAddressData(), pdnGwIpv6AddressSpecificAPNInfo.getData())); FQDN pdnGwNameSpecificAPNInfo = pdnGWIdentitySpecificAPNInfo.getPdnGwName(); assertNotNull(pdnGwNameSpecificAPNInfo); assertTrue(Arrays.equals(this.getFQDNData(), pdnGwNameSpecificAPNInfo.getData())); assertNotNull(pdnGWIdentitySpecificAPNInfo.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(pdnGWIdentitySpecificAPNInfo.getExtensionContainer())); MAPExtensionContainer extensionContainerspecificAPNInfo = specificAPNInfo.getExtensionContainer(); assertNotNull(extensionContainerspecificAPNInfo); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainerspecificAPNInfo)); assertTrue(Arrays.equals(specificAPNInfo.getAPN().getData(), this.getAPNData())); PDPAddress servedPartyIPIPv6Address = apnConfiguration.getServedPartyIPIPv6Address(); assertNotNull(servedPartyIPIPv6Address); assertTrue(Arrays.equals(this.getPDPAddressData(), servedPartyIPIPv6Address.getData())); assertTrue(Arrays.equals(this.getAPNOIReplacementData(), apnConfiguration.getApnOiReplacement().getData())); assertEquals(apnConfiguration.getSiptoPermission(), SIPTOPermission.siptoAllowed); assertEquals(apnConfiguration.getLipaPermission(), LIPAPermission.lipaConditional); MAPExtensionContainer extensionContainer = apnConfiguration.getExtensionContainer(); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); int defaultContext = 2; boolean completeDataListIncluded = true; ArrayList<APNConfiguration> ePSDataList = new ArrayList<APNConfiguration>(); int contextId = 1; PDNType pDNType = new PDNTypeImpl(PDNTypeValue.IPv4); PDPAddress servedPartyIPIPv4Address = new PDPAddressImpl(this.getPDPAddressData()); APN apn = new APNImpl(this.getAPNData()); QoSClassIdentifier qoSClassIdentifier = QoSClassIdentifier.QCI_1; AllocationRetentionPriority allocationRetentionPriority = new AllocationRetentionPriorityImpl(1, Boolean.TRUE, Boolean.TRUE, extensionContainer); EPSQoSSubscribed ePSQoSSubscribed = new EPSQoSSubscribedImpl(qoSClassIdentifier, allocationRetentionPriority, extensionContainer); PDPAddress pdnGwIpv4Address = new PDPAddressImpl(this.getPDPAddressData()); PDPAddress pdnGwIpv6Address = new PDPAddressImpl(this.getPDPAddressData()); FQDN pdnGwName = new FQDNImpl(this.getFQDNData()); PDNGWIdentity pdnGwIdentity = new PDNGWIdentityImpl(pdnGwIpv4Address, pdnGwIpv6Address, pdnGwName, extensionContainer); PDNGWAllocationType pdnGwAllocationType = PDNGWAllocationType._dynamic; boolean vplmnAddressAllowed = true; ChargingCharacteristics chargingCharacteristics = new ChargingCharacteristicsImpl(this.getChargingCharacteristicsData()); AMBR ambr = new AMBRImpl(2, 4, extensionContainer); SpecificAPNInfo specificAPNInfo = new SpecificAPNInfoImpl(apn, pdnGwIdentity, extensionContainer); ArrayList<SpecificAPNInfo> specificAPNInfoList = new ArrayList<SpecificAPNInfo>(); specificAPNInfoList.add(specificAPNInfo); PDPAddress servedPartyIPIPv6Address = new PDPAddressImpl(this.getPDPAddressData()); APNOIReplacement apnOiReplacement = new APNOIReplacementImpl(this.getAPNOIReplacementData()); SIPTOPermission siptoPermission = SIPTOPermission.siptoAllowed; LIPAPermission lipaPermission = LIPAPermission.lipaConditional; APNConfiguration APNConfiguration = new APNConfigurationImpl(contextId, pDNType, servedPartyIPIPv4Address, apn, ePSQoSSubscribed, pdnGwIdentity, pdnGwAllocationType, vplmnAddressAllowed, chargingCharacteristics, ambr, specificAPNInfoList, extensionContainer, servedPartyIPIPv6Address, apnOiReplacement, siptoPermission, lipaPermission); ePSDataList.add(APNConfiguration); APNConfigurationProfileImpl prim = new APNConfigurationProfileImpl(defaultContext, completeDataListIncluded, ePSDataList, extensionContainer); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * APN-ConfigurationProfile ::= SEQUENCE { defaultContext ContextId, completeDataListIncluded NULL OPTIONAL, -- If segmentation * is used, completeDataListIncluded may only be present in the -- first segment of APN-ConfigurationProfile. epsDataList [1] * EPS-DataList, extensionContainer [2] ExtensionContainer OPTIONAL, ... } * * ContextId ::= INTEGER (1..50) * * EPS-DataList ::= SEQUENCE SIZE (1..50) OF APN-Configuration * * * * @author sergey vetyutnev * */ public interface APNConfigurationProfile extends Serializable { int getDefaultContext(); boolean getCompleteDataListIncluded(); ArrayList<APNConfiguration> getEPSDataList(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.supplementary; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.supplementary.CliRestrictionOption; import org.restcomm.protocols.ss7.map.api.service.supplementary.OverrideCategory; import org.restcomm.protocols.ss7.map.service.supplementary.SSSubscriptionOptionImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class SSSubscriptionOptionTest { private byte[] getData1() { return new byte[] { -126, 1, 0 }; } private byte[] getData2() { return new byte[] { -127, 1, 1 }; } @Test(groups = { "functional.decode", "service.supplementary" }) public void testDecode() throws Exception { byte[] data = this.getData1(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); SSSubscriptionOptionImpl prim = new SSSubscriptionOptionImpl(); prim.decodeAll(asn); assertEquals(tag, SSSubscriptionOptionImpl._TAG_cliRestrictionOption); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNotNull(prim.getCliRestrictionOption()); assertNull(prim.getOverrideCategory()); assertTrue(prim.getCliRestrictionOption().getCode() == CliRestrictionOption.permanent.getCode()); data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new SSSubscriptionOptionImpl(); prim.decodeAll(asn); assertEquals(tag, SSSubscriptionOptionImpl._TAG_overrideCategory); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertNull(prim.getCliRestrictionOption()); assertNotNull(prim.getOverrideCategory()); assertTrue(prim.getOverrideCategory().getCode() == OverrideCategory.overrideDisabled.getCode()); } @Test(groups = { "functional.encode", "service.supplementary" }) public void testEncode() throws Exception { SSSubscriptionOptionImpl impl = new SSSubscriptionOptionImpl(CliRestrictionOption.permanent); AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); assertEquals(asnOS.toByteArray(), this.getData1()); impl = new SSSubscriptionOptionImpl(OverrideCategory.overrideDisabled); asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); assertEquals(asnOS.toByteArray(), this.getData2()); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.supplementary; import java.io.Serializable; /** * <code> SS-SubscriptionOption ::= CHOICE { cliRestrictionOption [2] CliRestrictionOption, overrideCategory [1] OverrideCategory } </code> * * * * @author sergey vetyutnev * */ public interface SSSubscriptionOption extends Serializable { CliRestrictionOption getCliRestrictionOption(); OverrideCategory getOverrideCategory(); }```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.service.oam.BMSCEventList; import org.restcomm.protocols.ss7.map.api.service.oam.GGSNEventList; import org.restcomm.protocols.ss7.map.api.service.oam.MGWEventList; import org.restcomm.protocols.ss7.map.api.service.oam.MMEEventList; import org.restcomm.protocols.ss7.map.api.service.oam.MSCSEventList; import org.restcomm.protocols.ss7.map.api.service.oam.PGWEventList; import org.restcomm.protocols.ss7.map.api.service.oam.SGSNEventList; import org.restcomm.protocols.ss7.map.api.service.oam.SGWEventList; import org.restcomm.protocols.ss7.map.service.oam.BMSCEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.GGSNEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.MGWEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.MMEEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.MSCSEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.PGWEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.SGSNEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.SGWEventListImpl; import org.restcomm.protocols.ss7.map.service.oam.TraceEventListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class TraceEventListTest { private byte[] getEncodedData() { return new byte[] { 48, 32, (byte) 128, 2, 3, (byte) 128, (byte) 129, 2, 7, (byte) 128, (byte) 130, 2, 4, 64, (byte) 131, 2, 6, 64, (byte) 132, 2, 7, (byte) 128, (byte) 133, 2, 2, 36, (byte) 134, 2, 5, 32, (byte) 135, 2, 5, 64 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); TraceEventListImpl asc = new TraceEventListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getMscSList().getMoMtCall()); assertFalse(asc.getMscSList().getSs()); assertTrue(asc.getMgwList().getContext()); assertTrue(asc.getSgsnList().getMoMtSms()); assertFalse(asc.getSgsnList().getMbmsContext()); assertTrue(asc.getGgsnList().getMbmsContext()); assertFalse(asc.getGgsnList().getPdpContext()); assertTrue(asc.getBmscList().getMbmsMulticastServiceActivation()); assertTrue(asc.getMmeList().getInitialAttachTrackingAreaUpdateDetach()); assertTrue(asc.getMmeList().getHandover()); assertFalse(asc.getMmeList().getServiceRequestts()); assertTrue(asc.getSgwList().getBearerActivationModificationDeletion()); assertFalse(asc.getSgwList().getPdnConnectionCreation()); assertTrue(asc.getPgwList().getPdnConnectionTermination()); assertFalse(asc.getPgwList().getBearerActivationModificationDeletion()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { MSCSEventList mscSList = new MSCSEventListImpl(true, false, false, false, false); MGWEventList mgwList = new MGWEventListImpl(true); SGSNEventList sgsnList = new SGSNEventListImpl(false, true, false, false); GGSNEventList ggsnList = new GGSNEventListImpl(false, true); BMSCEventList bmscList = new BMSCEventListImpl(true); MMEEventList mmeList = new MMEEventListImpl(false, false, true, false, false, true); SGWEventList sgwList = new SGWEventListImpl(false, false, true); PGWEventList pgwList = new PGWEventListImpl(false, true, false); TraceEventListImpl asc = new TraceEventListImpl(mscSList, mgwList, sgsnList, ggsnList, bmscList, mmeList, sgwList, pgwList); // MSCSEventList mscSList, MGWEventList mgwList, SGSNEventList sgsnList, GGSNEventList ggsnList, // BMSCEventList bmscList, MMEEventList mmeList, SGWEventList sgwList, PGWEventList pgwList AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> TraceEventList ::= SEQUENCE { msc-s-List [0] MSC-S-EventList OPTIONAL, mgw-List [1] MGW-EventList OPTIONAL, sgsn-List [2] SGSN-EventList OPTIONAL, ggsn-List [3] GGSN-EventList OPTIONAL, bmsc-List [4] BMSC-EventList OPTIONAL, ..., mme-List [5] MME-EventList OPTIONAL, sgw-List [6] SGW-EventList OPTIONAL, pgw-List [7] PGW-EventList OPTIONAL } </code> * * * @author sergey vetyutnev * */ public interface TraceEventList extends Serializable { MSCSEventList getMscSList(); MGWEventList getMgwList(); SGSNEventList getSgsnList(); GGSNEventList getGgsnList(); BMSCEventList getBmscList(); MMEEventList getMmeList(); SGWEventList getSgwList(); PGWEventList getPgwList(); } ```
```package org.restcomm.protocols.ss7.cap.service.sms.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.service.sms.primitive.TPDataCodingSchemeImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class TPDataCodingSchemeTest { public byte[] getData() { return new byte[] { 4, 1, 5 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); TPDataCodingSchemeImpl prim = new TPDataCodingSchemeImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_OCTET); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getData(), 5); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { TPDataCodingSchemeImpl prim = new TPDataCodingSchemeImpl(5); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms.primitive; import java.io.Serializable; /** * TPDataCodingScheme ::= OCTET STRING (SIZE (1)) -- TP Data Coding Scheme according to 3GPP TS 23.040 [6] * * * @author sergey vetyutnev * */ public interface TPDataCodingScheme extends Serializable { int getData(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.CallOfferingTreatmentIndicatorsImpl; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class CallOfferingTreatmentIndicatorsTest extends ParameterHarness { public CallOfferingTreatmentIndicatorsTest() { super(); super.goodBodies.add(getBody1()); } private byte[] getBody1() { byte[] body = new byte[]{ CallOfferingTreatmentIndicatorsImpl._CTBOI_COA, CallOfferingTreatmentIndicatorsImpl._CTBOI_NO_INDICATION }; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { CallOfferingTreatmentIndicatorsImpl at = new CallOfferingTreatmentIndicatorsImpl(getBody1()); String[] methodNames = { "getCallOfferingTreatmentIndicators" }; Object[] expectedValues = { new byte[]{CallOfferingTreatmentIndicatorsImpl._CTBOI_COA, CallOfferingTreatmentIndicatorsImpl._CTBOI_NO_INDICATION} }; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.CallOfferingTreatmentIndicatorsImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:11:59:38 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface CallOfferingTreatmentIndicators extends ISUPParameter { int _PARAMETER_CODE = 0x70; /** * See Q.763 3.74 Call to be offered indicator : no indication */ int _CTBOI_NO_INDICATION = 0; /** * See Q.763 3.74 Call to be offered indicator : call offering not allowed */ int _CTBOI_CONA = 1; /** * See Q.763 3.74 Call to be offered indicator : call offering allowed */ int _CTBOI_COA = 2; byte[] getCallOfferingTreatmentIndicators(); void setCallOfferingTreatmentIndicators(byte[] callOfferingTreatmentIndicators); int getCallOfferingIndicator(byte b); } ```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.GlobalCellId; import org.restcomm.protocols.ss7.map.api.primitives.LAIFixedLength; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.EUtranCgi; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.RAIdentity; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.TAId; import org.restcomm.protocols.ss7.map.primitives.GlobalCellIdImpl; import org.restcomm.protocols.ss7.map.primitives.LAIFixedLengthImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.EUtranCgiImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.RAIdentityImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberInformation.TAIdImpl; import org.restcomm.protocols.ss7.map.service.oam.AreaScopeImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AreaScopeTest { private byte[] getEncodedData() { return new byte[] { 48, 11, (byte) 160, 9, 4, 7, 82, (byte) 240, 112, 69, (byte) 224, 87, (byte) 172 }; } private byte[] getEncodedData2() { return new byte[] { 48, 91, (byte) 160, 9, 4, 7, 82, (byte) 240, 112, 69, (byte) 224, 87, (byte) 172, (byte) 161, 9, 4, 7, 1, 2, 3, 4, 5, 6, 7, (byte) 162, 8, 4, 6, 11, 12, 13, 14, 15, 16, (byte) 163, 7, 4, 5, 81, (byte) 240, 17, 13, 5, (byte) 164, 7, 4, 5, 21, 22, 23, 24, 25, (byte) 165, 39, (byte) 160, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, (byte) 161, 3, 31, 32, 33 }; } private byte[] getEUtranCgiData() { return new byte[] { 1, 2, 3, 4, 5, 6, 7 }; } private byte[] getRAIdentity() { return new byte[] { 11, 12, 13, 14, 15, 16 }; } private byte[] getTAId() { return new byte[] { 21, 22, 23, 24, 25 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); AreaScopeImpl asc = new AreaScopeImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getCgiList().size(), 1); assertEquals(asc.getCgiList().get(0).getMcc(), 250); assertEquals(asc.getCgiList().get(0).getMnc(), 7); assertEquals(asc.getCgiList().get(0).getCellId(), 22444); assertNull(asc.getEUutranCgiList()); assertNull(asc.getRoutingAreaIdList()); assertNull(asc.getLocationAreaIdList()); assertNull(asc.getTrackingAreaIdList()); assertNull(asc.getExtensionContainer()); rawData = getEncodedData2(); asn = new AsnInputStream(rawData); tag = asn.readTag(); asc = new AreaScopeImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(asc.getCgiList().size(), 1); assertEquals(asc.getCgiList().get(0).getMcc(), 250); assertEquals(asc.getCgiList().get(0).getMnc(), 7); assertEquals(asc.getCgiList().get(0).getCellId(), 22444); assertEquals(asc.getEUutranCgiList().size(), 1); assertEquals(asc.getEUutranCgiList().get(0).getData(), getEUtranCgiData()); assertEquals(asc.getRoutingAreaIdList().size(), 1); assertEquals(asc.getRoutingAreaIdList().get(0).getData(), getRAIdentity()); assertEquals(asc.getLocationAreaIdList().size(), 1); assertEquals(asc.getLocationAreaIdList().get(0).getMCC(), 150); assertEquals(asc.getLocationAreaIdList().get(0).getMNC(), 11); assertEquals(asc.getLocationAreaIdList().get(0).getLac(), 3333); assertEquals(asc.getTrackingAreaIdList().size(), 1); assertEquals(asc.getTrackingAreaIdList().get(0).getData(), getTAId()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(asc.getExtensionContainer())); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { ArrayList<GlobalCellId> cgiList = new ArrayList<GlobalCellId>(); GlobalCellId gci = new GlobalCellIdImpl(250, 7, 17888, 22444); // int mcc, int mnc, int lac, int cellId cgiList.add(gci); AreaScopeImpl asc = new AreaScopeImpl(cgiList, null, null, null, null, null); // ArrayList<GlobalCellId> cgiList, ArrayList<EUtranCgi> eUtranCgiList, ArrayList<RAIdentity> routingAreaIdList, // ArrayList<LAIFixedLength> locationAreaIdList, ArrayList<TAId> trackingAreaIdList, MAPExtensionContainer extensionContainer AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); ArrayList<EUtranCgi> eUtranCgiList = new ArrayList<EUtranCgi>(); EUtranCgi eUtranCgi = new EUtranCgiImpl(getEUtranCgiData()); eUtranCgiList.add(eUtranCgi); ArrayList<RAIdentity> routingAreaIdList = new ArrayList<RAIdentity>(); RAIdentity raIdentity = new RAIdentityImpl(getRAIdentity()); routingAreaIdList.add(raIdentity); ArrayList<LAIFixedLength> locationAreaIdList = new ArrayList<LAIFixedLength>(); LAIFixedLength laiFixedLength = new LAIFixedLengthImpl(150, 11, 3333); // int mcc, int mnc, int lac locationAreaIdList.add(laiFixedLength); ArrayList<TAId> trackingAreaIdList = new ArrayList<TAId>(); TAId taId = new TAIdImpl(getTAId()); trackingAreaIdList.add(taId); asc = new AreaScopeImpl(cgiList, eUtranCgiList, routingAreaIdList, locationAreaIdList, trackingAreaIdList, MAPExtensionContainerTest.GetTestExtensionContainer()); asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); encodedData = asnOS.toByteArray(); rawData = getEncodedData2(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.GlobalCellId; import org.restcomm.protocols.ss7.map.api.primitives.LAIFixedLength; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.EUtranCgi; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.RAIdentity; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.TAId; /** * <code> AreaScope ::= SEQUENCE { cgi-List [0] CGI-List OPTIONAL, e-utran-cgi-List [1] E-UTRAN-CGI-List OPTIONAL, routingAreaId-List [2] RoutingAreaId-List OPTIONAL, locationAreaId-List [3] LocationAreaId-List OPTIONAL, trackingAreaId-List [4] TrackingAreaId-List OPTIONAL, extensionContainer [5] ExtensionContainer OPTIONAL, ... } CGI-List ::= SEQUENCE SIZE (1..32) OF GlobalCellId E-UTRAN-CGI-List ::= SEQUENCE SIZE (1..32) OF E-UTRAN-CGI RoutingAreaId-List ::= SEQUENCE SIZE (1..8) OF RAIdentity LocationAreaId-List ::= SEQUENCE SIZE (1..8) OF LAIFixedLength TrackingAreaId-List ::= SEQUENCE SIZE (1..8) OF TA-Id </code> * * * @author sergey vetyutnev * */ public interface AreaScope extends Serializable { ArrayList<GlobalCellId> getCgiList(); ArrayList<EUtranCgi> getEUutranCgiList(); ArrayList<RAIdentity> getRoutingAreaIdList(); ArrayList<LAIFixedLength> getLocationAreaIdList(); ArrayList<TAId> getTrackingAreaIdList(); MAPExtensionContainer getExtensionContainer(); } ```
```package org.restcomm.protocols.ss7.map.service.lsm; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.TypeOfShape; import org.restcomm.protocols.ss7.map.service.lsm.AddGeographicalInformationImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AddGeographicalInformationTest { private byte[] getEncodedData_EllipsoidPointWithUncertaintyCircle() { return new byte[] { 4, 8, 16, 92, 113, -57, -106, 11, 97, 7 }; } @Test(groups = { "functional.decode", "lsm" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData_EllipsoidPointWithUncertaintyCircle(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); AddGeographicalInformationImpl impl = new AddGeographicalInformationImpl(); impl.decodeAll(asn); assertEquals(impl.getTypeOfShape(), TypeOfShape.EllipsoidPointWithUncertaintyCircle); assertTrue(Math.abs(impl.getLatitude() - 65) < 0.01); assertTrue(Math.abs(impl.getLongitude() - (-149)) < 0.01); // -31 assertTrue(Math.abs(impl.getUncertainty() - 9.48) < 0.01); } @Test(groups = { "functional.encode", "lsm" }) public void testEncode() throws Exception { AddGeographicalInformationImpl impl = new AddGeographicalInformationImpl( TypeOfShape.EllipsoidPointWithUncertaintyCircle, 65, -149, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); // TypeOfShape typeOfShape, double latitude, double longitude, double uncertainty, double uncertaintySemiMajorAxis, // double uncertaintySemiMinorAxis, double angleOfMajorAxis, int confidence, int altitude, double uncertaintyAltitude, // int innerRadius, // double uncertaintyRadius, double offsetAngle, double includedAngle AsnOutputStream asnOS = new AsnOutputStream(); impl.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData_EllipsoidPointWithUncertaintyCircle(); assertTrue(Arrays.equals(rawData, encodedData)); } // TODO: add processing missed: TypeOfShape.Polygon, TypeOfShape.EllipsoidPointWithAltitude } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.lsm; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberInformation.TypeOfShape; /** * <code> Add-GeographicalInformation ::= OCTET STRING (SIZE (1..91)) -- Refers to geographical Information defined in 3GPP TS 23.032. -- This is composed of 1 or more octets with an internal structure according to -- 3GPP TS 23.032 -- Octet 1: Type of shape, all the shapes defined in 3GPP TS 23.032 are allowed: -- Octets 2 to n (where n is the total number of octets necessary to encode the shape -- according to 3GPP TS 23.032) are used to encode the shape itself in accordance with the -- encoding defined in 3GPP TS 23.032 -- -- An Add-GeographicalInformation parameter, whether valid or invalid, received -- together with a valid Ext-GeographicalInformation parameter in the same message -- shall be discarded. -- -- An Add-GeographicalInformation parameter containing any shape not defined in -- 3GPP TS 23.032 or an incorrect number of octets or coding according to -- 3GPP TS 23.032 shall be treated as invalid data by a receiver if not received -- together with a valid Ext-GeographicalInformation parameter in the same message. maxAdd-GeographicalInformation INTEGER ::= 91 -- the maximum length allows support for all the shapes currently defined in 3GPP TS 23.032 </code> * * * @author sergey vetyutnev * */ public interface AddGeographicalInformation extends Serializable { byte[] getData(); TypeOfShape getTypeOfShape(); /** * @return Latitude value in degrees (-90 ... 90) */ double getLatitude(); /** * @return Longitude value in degrees (-180 ... 180) */ double getLongitude(); /** * @return Uncertainty value in meters */ double getUncertainty(); /** * @return Uncertainty value in meters */ double getUncertaintySemiMajorAxis(); /** * @return Uncertainty value in meters */ double getUncertaintySemiMinorAxis(); /** * @return Angle value in degrees */ double getAngleOfMajorAxis(); int getConfidence(); /** * @return Altitude value in meters */ int getAltitude(); /** * @return Uncertainty value in meters */ double getUncertaintyAltitude(); /** * @return Radius value in meters */ int getInnerRadius(); /** * @return Uncertainty value in meters */ double getUncertaintyRadius(); /** * @return Angle value in degrees */ double getOffsetAngle(); /** * @return Angle value in degrees */ double getIncludedAngle(); // TODO: add processing missed: TypeOfShape.Polygon, TypeOfShape.EllipsoidPointWithAltitude } ```
```package org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.ArrayList; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultGPRSHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.DefaultSMSHandling; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.GPRSCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.GPRSCamelTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.GPRSTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MGCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MMCode; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MMCodeValue; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MTSMSTPDUType; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.MTsmsCAMELTDPCriteria; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSCAMELTDPData; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSCSI; import org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement.SMSTriggerDetectionPoint; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.GPRSCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.GPRSCamelTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MGCSIImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MMCodeImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.MTsmsCAMELTDPCriteriaImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SGSNCAMELSubscriptionInfoImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCAMELTDPDataImpl; import org.restcomm.protocols.ss7.map.service.mobility.subscriberManagement.SMSCSIImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class SGSNCAMELSubscriptionInfoTest { public byte[] getData() { return new byte[] { 48, -126, 1, -66, -96, 108, -96, 58, 48, 56, -128, 1, 2, -127, 1, 2, -126, 4, -111, 34, 34, -8, -125, 1, 1, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -125, 0, -124, 0, -95, 108, -96, 58, 48, 56, -128, 1, 1, -127, 1, 2, -126, 4, -111, 34, 34, -8, -125, 1, 0, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -125, 0, -124, 0, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -93, 104, -96, 58, 48, 56, -128, 1, 1, -127, 1, 2, -126, 4, -111, 34, 34, -8, -125, 1, 0, -92, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -127, 1, 4, -94, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -92, 13, 48, 11, 10, 1, 1, -96, 6, 10, 1, 0, 10, 1, 2, -91, 62, 48, 6, 4, 1, -125, 4, 1, 2, 2, 1, 3, -128, 4, -111, 34, 34, -8, -95, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, -126, 0, -125, 0 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); SGSNCAMELSubscriptionInfoImpl prim = new SGSNCAMELSubscriptionInfoImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); // start gprsCsi GPRSCSI gprsCsi = prim.getGprsCsi(); assertNotNull(gprsCsi.getGPRSCamelTDPDataList()); assertEquals(gprsCsi.getGPRSCamelTDPDataList().size(), 1); GPRSCamelTDPData gprsCamelTDPData = gprsCsi.getGPRSCamelTDPDataList().get(0); MAPExtensionContainer extensionContainergprsCamelTDPData = gprsCamelTDPData.getExtensionContainer(); ISDNAddressString gsmSCFAddress = gprsCamelTDPData.getGsmSCFAddress(); assertTrue(gsmSCFAddress.getAddress().equals("22228")); assertEquals(gsmSCFAddress.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddress.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(gprsCamelTDPData.getDefaultSessionHandling(), DefaultGPRSHandling.releaseTransaction); assertEquals(gprsCamelTDPData.getGPRSTriggerDetectionPoint(), GPRSTriggerDetectionPoint.attachChangeOfPosition); assertEquals(gprsCamelTDPData.getServiceKey(), 2); assertNotNull(extensionContainergprsCamelTDPData); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainergprsCamelTDPData)); assertEquals(gprsCsi.getCamelCapabilityHandling().intValue(), 4); assertNotNull(gprsCsi.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(gprsCsi.getExtensionContainer())); assertTrue(gprsCsi.getCsiActive()); assertTrue(gprsCsi.getNotificationToCSE()); // end gprsCsi // start moSmsCsi SMSCSI moSmsCsi = prim.getMoSmsCsi(); ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = moSmsCsi.getSmsCamelTdpDataList(); assertNotNull(smsCamelTdpDataList); assertEquals(smsCamelTdpDataList.size(), 1); SMSCAMELTDPData one = smsCamelTdpDataList.get(0); assertNotNull(one); assertEquals(one.getServiceKey(), 2); assertEquals(one.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); ISDNAddressString gsmSCFAddressMoSmsCsi = one.getGsmSCFAddress(); assertTrue(gsmSCFAddressMoSmsCsi.getAddress().equals("22228")); assertEquals(gsmSCFAddressMoSmsCsi.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressMoSmsCsi.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(one.getDefaultSMSHandling(), DefaultSMSHandling.continueTransaction); assertNotNull(one.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(one.getExtensionContainer())); assertNotNull(moSmsCsi.getExtensionContainer()); assertTrue(moSmsCsi.getCsiActive()); assertTrue(moSmsCsi.getNotificationToCSE()); assertEquals(moSmsCsi.getCamelCapabilityHandling().intValue(), 4); // end moSmsCsi // start mtSmsCsi SMSCSI mtSmsCsi = prim.getMtSmsCsi(); ArrayList<SMSCAMELTDPData> smsCamelTdpDataListMtSmsCsi = mtSmsCsi.getSmsCamelTdpDataList(); assertNotNull(smsCamelTdpDataListMtSmsCsi); assertEquals(smsCamelTdpDataListMtSmsCsi.size(), 1); SMSCAMELTDPData oneSmsCamelTdpDataListMtSmsCsi = smsCamelTdpDataListMtSmsCsi.get(0); assertNotNull(oneSmsCamelTdpDataListMtSmsCsi); assertEquals(oneSmsCamelTdpDataListMtSmsCsi.getServiceKey(), 2); assertEquals(oneSmsCamelTdpDataListMtSmsCsi.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); ISDNAddressString gsmSCFAddressmtSmsCsi = one.getGsmSCFAddress(); assertTrue(gsmSCFAddressmtSmsCsi.getAddress().equals("22228")); assertEquals(gsmSCFAddressmtSmsCsi.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressmtSmsCsi.getNumberingPlan(), NumberingPlan.ISDN); assertEquals(one.getDefaultSMSHandling(), DefaultSMSHandling.continueTransaction); assertNotNull(one.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(one.getExtensionContainer())); assertNotNull(mtSmsCsi.getExtensionContainer()); assertFalse(mtSmsCsi.getCsiActive()); assertFalse(mtSmsCsi.getNotificationToCSE()); assertEquals(mtSmsCsi.getCamelCapabilityHandling().intValue(), 4); // end mtSmsCsi // start mtSmsCamelTdpCriteriaList ArrayList<MTsmsCAMELTDPCriteria> mtSmsCamelTdpCriteriaList = prim.getMtSmsCamelTdpCriteriaList(); assertNotNull(mtSmsCamelTdpCriteriaList); assertEquals(mtSmsCamelTdpCriteriaList.size(), 1); MTsmsCAMELTDPCriteria mtSmsCAMELTDPCriteria = mtSmsCamelTdpCriteriaList.get(0); ArrayList<MTSMSTPDUType> tPDUTypeCriterion = mtSmsCAMELTDPCriteria.getTPDUTypeCriterion(); assertNotNull(tPDUTypeCriterion); assertEquals(tPDUTypeCriterion.size(), 2); MTSMSTPDUType oneMTSMSTPDUType = tPDUTypeCriterion.get(0); assertNotNull(oneMTSMSTPDUType); assertEquals(oneMTSMSTPDUType, MTSMSTPDUType.smsDELIVER); MTSMSTPDUType twoMTSMSTPDUType = tPDUTypeCriterion.get(1); assertNotNull(twoMTSMSTPDUType); assertEquals(twoMTSMSTPDUType, MTSMSTPDUType.smsSTATUSREPORT); assertEquals(mtSmsCAMELTDPCriteria.getSMSTriggerDetectionPoint(), SMSTriggerDetectionPoint.smsCollectedInfo); // end mtSmsCamelTdpCriteriaList // start mgCsi MGCSI mgCsi = prim.getMgCsi(); ArrayList<MMCode> mobilityTriggers = mgCsi.getMobilityTriggers(); assertNotNull(mobilityTriggers); assertEquals(mobilityTriggers.size(), 2); MMCode oneMMCode = mobilityTriggers.get(0); assertNotNull(oneMMCode); assertEquals(oneMMCode.getMMCodeValue(), MMCodeValue.GPRSAttach); MMCode twoMMCode = mobilityTriggers.get(1); assertNotNull(twoMMCode); assertEquals(twoMMCode.getMMCodeValue(), MMCodeValue.IMSIAttach); assertEquals(mgCsi.getServiceKey(), 3); ISDNAddressString gsmSCFAddressMgCsi = mgCsi.getGsmSCFAddress(); assertTrue(gsmSCFAddressMgCsi.getAddress().equals("22228")); assertEquals(gsmSCFAddressMgCsi.getAddressNature(), AddressNature.international_number); assertEquals(gsmSCFAddressMgCsi.getNumberingPlan(), NumberingPlan.ISDN); assertNotNull(mgCsi.getExtensionContainer()); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(mgCsi.getExtensionContainer())); assertTrue(mgCsi.getCsiActive()); assertTrue(mgCsi.getNotificationToCSE()); // end mgCsi MAPExtensionContainer extensionContainer = prim.getExtensionContainer(); assertNotNull(extensionContainer); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(extensionContainer)); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { MAPExtensionContainer extensionContainer = MAPExtensionContainerTest.GetTestExtensionContainer(); // start gprsCsi GPRSTriggerDetectionPoint gprsTriggerDetectionPoint = GPRSTriggerDetectionPoint.attachChangeOfPosition; long serviceKey = 2; ISDNAddressString gsmSCFAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "22228"); DefaultGPRSHandling defaultSessionHandling = DefaultGPRSHandling.releaseTransaction; GPRSCamelTDPDataImpl gprsCamelTDPData = new GPRSCamelTDPDataImpl(gprsTriggerDetectionPoint, serviceKey, gsmSCFAddress, defaultSessionHandling, extensionContainer); ArrayList<GPRSCamelTDPData> gprsCamelTDPDataList = new ArrayList<GPRSCamelTDPData>(); gprsCamelTDPDataList.add(gprsCamelTDPData); Integer camelCapabilityHandling = new Integer(4); boolean notificationToCSE = true; boolean csiActive = true; GPRSCSI gprsCsi = new GPRSCSIImpl(gprsCamelTDPDataList, camelCapabilityHandling, extensionContainer, notificationToCSE, csiActive); // end gprsCsi // start moSmsCsi SMSTriggerDetectionPoint smsTriggerDetectionPoint = SMSTriggerDetectionPoint.smsCollectedInfo; DefaultSMSHandling defaultSMSHandling = DefaultSMSHandling.continueTransaction; ArrayList<SMSCAMELTDPData> smsCamelTdpDataList = new ArrayList<SMSCAMELTDPData>(); SMSCAMELTDPDataImpl smsCAMELTDPData = new SMSCAMELTDPDataImpl(smsTriggerDetectionPoint, serviceKey, gsmSCFAddress, defaultSMSHandling, extensionContainer); smsCamelTdpDataList.add(smsCAMELTDPData); SMSCSI moSmsCsi = new SMSCSIImpl(smsCamelTdpDataList, camelCapabilityHandling, extensionContainer, notificationToCSE, csiActive); // end moSmsCsi // start mtSmsCsi SMSCSI mtSmsCsi = new SMSCSIImpl(smsCamelTdpDataList, camelCapabilityHandling, extensionContainer, false, false); // end mtSmsCsi // start mtSmsCamelTdpCriteriaList ArrayList<MTsmsCAMELTDPCriteria> mtSmsCamelTdpCriteriaList = new ArrayList<MTsmsCAMELTDPCriteria>(); ArrayList<MTSMSTPDUType> tPDUTypeCriterion = new ArrayList<MTSMSTPDUType>(); tPDUTypeCriterion.add(MTSMSTPDUType.smsDELIVER); tPDUTypeCriterion.add(MTSMSTPDUType.smsSTATUSREPORT); MTsmsCAMELTDPCriteria mtSmsCAMELTDPCriteria = new MTsmsCAMELTDPCriteriaImpl(smsTriggerDetectionPoint, tPDUTypeCriterion); mtSmsCamelTdpCriteriaList.add(mtSmsCAMELTDPCriteria); // end mtSmsCamelTdpCriteriaList // start mgCsi ArrayList<MMCode> mobilityTriggers = new ArrayList<MMCode>(); mobilityTriggers.add(new MMCodeImpl(MMCodeValue.GPRSAttach)); mobilityTriggers.add(new MMCodeImpl(MMCodeValue.IMSIAttach)); MGCSI mgCsi = new MGCSIImpl(mobilityTriggers, 3, gsmSCFAddress, extensionContainer, true, true); // end mgCsi SGSNCAMELSubscriptionInfoImpl prim = new SGSNCAMELSubscriptionInfoImpl(gprsCsi, moSmsCsi, extensionContainer, mtSmsCsi, mtSmsCamelTdpCriteriaList, mgCsi); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.subscriberManagement; import java.io.Serializable; import java.util.ArrayList; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; /** * <code> SGSN-CAMEL-SubscriptionInfo ::= SEQUENCE { gprs-CSI [0] GPRS-CSI OPTIONAL, mo-sms-CSI [1] SMS-CSI OPTIONAL, extensionContainer [2] ExtensionContainer OPTIONAL, ..., mt-sms-CSI [3] SMS-CSI OPTIONAL, mt-smsCAMELTDP-CriteriaList [4] MT-smsCAMELTDP-CriteriaList OPTIONAL, mg-csi [5] MG-CSI OPTIONAL } MT-smsCAMELTDP-CriteriaList ::= SEQUENCE SIZE (1.. 10) OF MT-smsCAMELTDP-Criteria </code> * * * * @author sergey vetyutnev * */ public interface SGSNCAMELSubscriptionInfo extends Serializable { GPRSCSI getGprsCsi(); SMSCSI getMoSmsCsi(); MAPExtensionContainer getExtensionContainer(); SMSCSI getMtSmsCsi(); ArrayList<MTsmsCAMELTDPCriteria> getMtSmsCamelTdpCriteriaList(); MGCSI getMgCsi(); } ```
```package org.restcomm.protocols.ss7.map.smstpdu; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Arrays; import org.restcomm.protocols.ss7.map.smstpdu.AbsoluteTimeStampImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class AbsoluteTimeStampTest { public byte[] getData() { return new byte[] { 112, 80, 81, 81, 0, 20, 33 }; } @Test(groups = { "functional.decode", "smstpdu" }) public void testDecode() throws Exception { InputStream stm = new ByteArrayInputStream(this.getData()); AbsoluteTimeStampImpl impl = AbsoluteTimeStampImpl.createMessage(stm); assertEquals(impl.getYear(), 7); assertEquals(impl.getMonth(), 5); assertEquals(impl.getDay(), 15); assertEquals(impl.getHour(), 15); assertEquals(impl.getMinute(), 0); assertEquals(impl.getSecond(), 41); assertEquals(impl.getTimeZone(), 12); } @Test(groups = { "functional.encode", "smstpdu" }) public void testEncode() throws Exception { AbsoluteTimeStampImpl impl = new AbsoluteTimeStampImpl(7, 5, 15, 15, 0, 41, 12); ByteArrayOutputStream stm = new ByteArrayOutputStream(); impl.encodeData(stm); assertTrue(Arrays.equals(stm.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.smstpdu; import java.io.OutputStream; import java.io.Serializable; import org.restcomm.protocols.ss7.map.api.MAPException; /** * The TP-Service-Centre-Time-Stamp field is given in semi-octet representation, and represents the local time in the following * way: * * Year: Month: Day: Hour: Minute: Second: Time Zone Digits: 2 2 2 2 2 2 2 (Semi-octets) * * The Time Zone indicates the difference, expressed in quarters of an hour, between the local time and GMT. In the first of the * two semi-octets, the first bit (bit 3 of the seventh octet of the TP-Service-Centre-Time-Stamp field) represents the * algebraic sign of this difference (0: positive, 1: negative). * * @author sergey vetyutnev * */ public interface AbsoluteTimeStamp extends Serializable { int getYear(); int getMonth(); int getDay(); int getHour(); int getMinute(); int getSecond(); /** * @return the timeZone in in quarters of an hour */ int getTimeZone(); void encodeData(OutputStream stm) throws MAPException; }```
```package org.restcomm.protocols.ss7.map.dialog; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.restcomm.protocols.ss7.map.api.dialog.Reason; import org.restcomm.protocols.ss7.map.dialog.MAPRefuseInfoImpl; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerTest; import org.restcomm.protocols.ss7.tcap.asn.ApplicationContextName; import org.restcomm.protocols.ss7.tcap.asn.ApplicationContextNameImpl; import org.testng.annotations.Test; /** * * @author amit bhayani * @author sergey vetyutnev * */ public class MAPRefuseInfoTest { private byte[] getData() { return new byte[] { (byte) 0xA3, 0x03, (byte) 0x0A, 0x01, 0x00 }; } private byte[] getDataFull() { return new byte[] { -93, 51, 10, 1, 2, 48, 39, -96, 32, 48, 10, 6, 3, 42, 3, 4, 11, 12, 13, 14, 15, 48, 5, 6, 3, 42, 3, 6, 48, 11, 6, 3, 42, 3, 5, 21, 22, 23, 24, 25, 26, -95, 3, 31, 32, 33, 6, 5, 42, 3, 4, 5, 6 }; } @Test(groups = { "functional.decode", "dialog" }) public void testDecode() throws Exception { // The raw data is from last packet of long ussd-abort from msc2.txt byte[] data = this.getData(); AsnInputStream asnIs = new AsnInputStream(data); int tag = asnIs.readTag(); assertEquals(tag, 3); MAPRefuseInfoImpl mapRefuseInfoImpl = new MAPRefuseInfoImpl(); mapRefuseInfoImpl.decodeAll(asnIs); Reason reason = mapRefuseInfoImpl.getReason(); assertNotNull(reason); assertEquals(reason, Reason.noReasonGiven); data = this.getDataFull(); asnIs = new AsnInputStream(data); tag = asnIs.readTag(); assertEquals(tag, 3); mapRefuseInfoImpl = new MAPRefuseInfoImpl(); mapRefuseInfoImpl.decodeAll(asnIs); reason = mapRefuseInfoImpl.getReason(); assertNotNull(reason); assertEquals(reason, Reason.invalidOriginatingReference); assertTrue(MAPExtensionContainerTest.CheckTestExtensionContainer(mapRefuseInfoImpl.getExtensionContainer())); assertNotNull(mapRefuseInfoImpl.getAlternativeAcn()); assertTrue(Arrays.equals(new long[] { 1, 2, 3, 4, 5, 6 }, mapRefuseInfoImpl.getAlternativeAcn().getOid())); } @Test(groups = { "functional.encode", "dialog" }) public void testEncode() throws Exception { MAPRefuseInfoImpl mapRefuseInfoImpl = new MAPRefuseInfoImpl(); mapRefuseInfoImpl.setReason(Reason.noReasonGiven); AsnOutputStream asnOS = new AsnOutputStream(); mapRefuseInfoImpl.encodeAll(asnOS); byte[] data = asnOS.toByteArray(); assertTrue(Arrays.equals(this.getData(), data)); mapRefuseInfoImpl = new MAPRefuseInfoImpl(); mapRefuseInfoImpl.setReason(Reason.invalidOriginatingReference); ApplicationContextName acn = new ApplicationContextNameImpl(); acn.setOid(new long[] { 1, 2, 3, 4, 5, 6 }); mapRefuseInfoImpl.setAlternativeAcn(acn); mapRefuseInfoImpl.setExtensionContainer(MAPExtensionContainerTest.GetTestExtensionContainer()); asnOS = new AsnOutputStream(); mapRefuseInfoImpl.encodeAll(asnOS); data = asnOS.toByteArray(); assertTrue(Arrays.equals(this.getDataFull(), data)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.dialog; import java.io.IOException; import org.mobicents.protocols.asn.AsnException; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.api.MAPException; import org.restcomm.protocols.ss7.map.api.MAPParsingComponentException; import org.restcomm.protocols.ss7.map.api.MAPParsingComponentExceptionReason; import org.restcomm.protocols.ss7.map.api.dialog.Reason; import org.restcomm.protocols.ss7.map.api.primitives.MAPExtensionContainer; import org.restcomm.protocols.ss7.map.primitives.MAPAsnPrimitive; import org.restcomm.protocols.ss7.map.primitives.MAPExtensionContainerImpl; import org.restcomm.protocols.ss7.tcap.asn.ApplicationContextName; import org.restcomm.protocols.ss7.tcap.asn.ApplicationContextNameImpl; /** * MAP-RefuseInfo ::= SEQUENCE { reason Reason, ..., extensionContainer ExtensionContainer -- extensionContainer must not be * used in version 2 } * * @author amit bhayani * @author sergey vetyutnev * */ public class MAPRefuseInfoImpl implements MAPAsnPrimitive { public static final int MAP_REFUSE_INFO_TAG = 0x03; protected static final int REFUSE_TAG_CLASS = Tag.CLASS_CONTEXT_SPECIFIC; protected static final boolean REFUSE_TAG_PC_CONSTRUCTED = false; protected static final boolean REFUSE_TAG_PC_PRIMITIVE = true; private Reason reason; private MAPExtensionContainer extensionContainer; private ApplicationContextName alternativeAcn; public Reason getReason() { return this.reason; } public MAPExtensionContainer getExtensionContainer() { return extensionContainer; } public ApplicationContextName getAlternativeAcn() { return this.alternativeAcn; } public void setReason(Reason reason) { this.reason = reason; } public void setExtensionContainer(MAPExtensionContainer extensionContainer) { this.extensionContainer = extensionContainer; } public void setAlternativeAcn(ApplicationContextName alternativeAcn) { this.alternativeAcn = alternativeAcn; } public int getTag() throws MAPException { return MAP_REFUSE_INFO_TAG; } public int getTagClass() { return Tag.CLASS_CONTEXT_SPECIFIC; } public boolean getIsPrimitive() { return false; } public void decodeAll(AsnInputStream ansIS) throws MAPParsingComponentException { try { int length = ansIS.readLength(); this._decode(ansIS, length); } catch (IOException e) { throw new MAPParsingComponentException("IOException when decoding MAP-RefuseInfo: " + e.getMessage(), e, MAPParsingComponentExceptionReason.MistypedParameter); } catch (AsnException e) { throw new MAPParsingComponentException("AsnException when decoding MAP-RefuseInfo: " + e.getMessage(), e, MAPParsingComponentExceptionReason.MistypedParameter); } } public void decodeData(AsnInputStream ansIS, int length) throws MAPParsingComponentException { try { this._decode(ansIS, length); } catch (IOException e) { throw new MAPParsingComponentException("IOException when decoding MAP-RefuseInfo: " + e.getMessage(), e, MAPParsingComponentExceptionReason.MistypedParameter); } catch (AsnException e) { throw new MAPParsingComponentException("AsnException when decoding MAP-RefuseInfo: " + e.getMessage(), e, MAPParsingComponentExceptionReason.MistypedParameter); } } private void _decode(AsnInputStream ais, int length) throws MAPParsingComponentException, IOException, AsnException { // MAP-RefuseInfo ::= SEQUENCE { // reason ENUMERATED { // noReasonGiven ( 0 ), // invalidDestinationReference ( 1 ), // invalidOriginatingReference ( 2 ) }, // ... , // extensionContainer SEQUENCE { // privateExtensionList [0] IMPLICIT SEQUENCE ( SIZE( 1 .. 10 ) ) OF // SEQUENCE { // extId MAP-EXTENSION .&extensionId ( { // , // ...} ) , // extType MAP-EXTENSION .&ExtensionType ( { // , // ...} { @extId } ) OPTIONAL} OPTIONAL, // pcs-Extensions [1] IMPLICIT SEQUENCE { // ... } OPTIONAL, // ... } OPTIONAL, // alternativeApplicationContext OBJECT IDENTIFIER OPTIONAL} this.reason = null; this.alternativeAcn = null; this.extensionContainer = null; AsnInputStream localAis = ais.readSequenceStreamData(length); int tag = localAis.readTag(); if (tag != Tag.ENUMERATED || localAis.getTagClass() != Tag.CLASS_UNIVERSAL) throw new MAPParsingComponentException("Error decoding MAP-RefuseInfo.Reason: bad tag or tagClass", MAPParsingComponentExceptionReason.MistypedParameter); int reasonCode = (int) localAis.readInteger(); this.reason = Reason.getReason(reasonCode); while (localAis.available() > 0) { tag = localAis.readTag(); switch (localAis.getTagClass()) { case Tag.CLASS_UNIVERSAL: switch (tag) { case Tag.SEQUENCE: this.extensionContainer = new MAPExtensionContainerImpl(); ((MAPExtensionContainerImpl) this.extensionContainer).decodeAll(localAis); break; case Tag.OBJECT_IDENTIFIER: this.alternativeAcn = new ApplicationContextNameImpl(); long[] oid = localAis.readObjectIdentifier(); this.alternativeAcn.setOid(oid); break; default: localAis.advanceElement(); break; } break; default: localAis.advanceElement(); break; } } } public void encodeAll(AsnOutputStream asnOs) throws MAPException { this.encodeAll(asnOs, Tag.CLASS_CONTEXT_SPECIFIC, MAP_REFUSE_INFO_TAG); } public void encodeAll(AsnOutputStream asnOs, int tagClass, int tag) throws MAPException { try { asnOs.writeTag(tagClass, false, tag); int pos = asnOs.StartContentDefiniteLength(); this.encodeData(asnOs); asnOs.FinalizeContent(pos); } catch (AsnException e) { throw new MAPException("AsnException when encoding MAPRefuseInfo: " + e.getMessage(), e); } } public void encodeData(AsnOutputStream asnOS) throws MAPException { if (this.reason == null) throw new MAPException("Error decoding MAP-RefuseInfo: Reason field must not be empty"); try { asnOS.writeInteger(Tag.CLASS_UNIVERSAL, Tag.ENUMERATED, this.reason.getCode()); if (this.extensionContainer != null) ((MAPExtensionContainerImpl) this.extensionContainer).encodeAll(asnOS); if (this.alternativeAcn != null) asnOS.writeObjectIdentifier(this.alternativeAcn.getOid()); } catch (IOException e) { throw new MAPException("IOException when encoding MAPRefuseInfo: " + e.getMessage(), e); } catch (AsnException e) { throw new MAPException("AsnException when encoding MAPRefuseInfo: " + e.getMessage(), e); } } } ```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.TransferredVolumeImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.VolumeIfTariffSwitchImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class TransferredVolumeTest { public byte[] getData() { return new byte[] { -128, 1, 25 }; }; public byte[] getData2() { return new byte[] { -95, 6, -128, 1, 12, -127, 1, 24 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // Option 1 byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); TransferredVolumeImpl prim = new TransferredVolumeImpl(); prim.decodeAll(asn); assertEquals(tag, TransferredVolumeImpl._ID_volumeIfNoTariffSwitch); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertTrue(prim.getIsPrimitive()); assertEquals(prim.getVolumeIfNoTariffSwitch().longValue(), 25); assertNull(prim.getVolumeIfTariffSwitch()); // Option 2 data = this.getData2(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new TransferredVolumeImpl(); prim.decodeAll(asn); assertEquals(tag, TransferredVolumeImpl._ID_volumeIfTariffSwitch); assertEquals(asn.getTagClass(), Tag.CLASS_CONTEXT_SPECIFIC); assertFalse(prim.getIsPrimitive()); assertNull(prim.getVolumeIfNoTariffSwitch()); assertEquals(prim.getVolumeIfTariffSwitch().getVolumeSinceLastTariffSwitch(), 12); assertEquals(prim.getVolumeIfTariffSwitch().getVolumeTariffSwitchInterval().longValue(), 24); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { // Option 1 TransferredVolumeImpl prim = new TransferredVolumeImpl(new Long(25)); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // Option 2 VolumeIfTariffSwitchImpl volumeIfTariffSwitch = new VolumeIfTariffSwitchImpl(12, new Long(24)); prim = new TransferredVolumeImpl(volumeIfTariffSwitch); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData2())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; /** * TransferredVolume ::= CHOICE { volumeIfNoTariffSwitch [0] INTEGER (0..4294967295), volumeIfTariffSwitch [1] SEQUENCE { * volumeSinceLastTariffSwitch [0] INTEGER (0..4294967295), volumeTariffSwitchInterval [1] INTEGER (0..4294967295) OPTIONAL } } * -- volumeIfNoTariffSwitch, volumeSinceLastTariffSwitch and volumeTariffSwitchInterval -- are measured in bytes. * * * @author sergey vetyutnev * */ public interface TransferredVolume extends Serializable { Long getVolumeIfNoTariffSwitch(); VolumeIfTariffSwitch getVolumeIfTariffSwitch(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.ForwardCallIndicatorsImpl; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class ForwardCallIndicatorsTest extends ParameterHarness { public ForwardCallIndicatorsTest() { super(); super.badBodies.add(getBadBody1()); super.badBodies.add(getBadBody2()); super.goodBodies.add(getBody1()); } private byte[] getBadBody1() { byte[] body = new byte[]{(byte) 0x81}; return body; } private byte[] getBadBody2() { byte[] body = new byte[]{(byte) 0x81,3,3}; return body; } private byte[] getBody1() { byte[] body = new byte[]{(byte) 0xAA,0x02}; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { ForwardCallIndicatorsImpl at = new ForwardCallIndicatorsImpl(getBody1()); String[] methodNames = { "isNationalCallIdentificator", "getEndToEndMethodIndicator", "isInterworkingIndicator", "isEndToEndInformationIndicator", "isIsdnUserPartIndicator", "getIsdnUserPartReferenceIndicator", "getSccpMethodIndicator", "isIsdnAccessIndicator" }; Object[] expectedValues = { false, 1,true,false,true,2, 1,false}; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.ForwardCallIndicatorsImpl(); } }```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:12:49:54 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface ForwardCallIndicators extends ISUPParameter { // FIXME: check this against Q, if it has everything. int _PARAMETER_CODE = 0x07; /** * See q.763 3.5 National/international call indicator (Note 1) : call to be treated as a national call */ boolean _NCI_NATIONAL_CALL = false; /** * See q.763 3.5 National/international call indicator (Note 1) : call to be treated as an international call */ boolean _NCI_INTERNATIONAL_CALL = true; /** * See q.763 3.5 End-to-end method indicator (Note 2) : no end-to-end method available (only link-by-link method available) */ int _ETEMI_NOMETHODAVAILABLE = 0; /** * See q.763 3.5 End-to-end method indicator (Note 2) : pass-along method available (national use) */ int _ETEMI_PASSALONG = 1; /** * See q.763 3.5 End-to-end method indicator (Note 2) : SCCP method available */ int _ETEMI_SCCP = 2; /** * See q.763 3.5 End-to-end method indicator (Note 2) : pass-along and SCCP methods available (national use) */ int _ETEMI_SCCP_AND_PASSALONG = 3; /** * See q.763 3.5 End-to-end information indicator (national use) (Note 2) : no end-to-end information available */ boolean _ETEII_NOT_AVAILABLE = false; /** * See q.763 3.5 End-to-end information indicator (national use) (Note 2) : end-to-end information available */ boolean _ETEII_AVAILABLE = true; /** * See q.763 3.5 Interworking indicator (Note 2) */ boolean _II_NOT_ENCOUTNERED = false; /** * See q.763 3.5 Interworking indicator (Note 2) */ boolean _II_ENCOUTNERED = true; /** * See q.763 3.5 ISDN access indicator : originating access non-ISDN */ boolean _ISDN_AI_OA_N_ISDN = false; /** * See q.763 3.5 ISDN access indicator : originating access ISDN */ boolean _ISDN_AI_OA_ISDN = true; /** * See q.763 3.5 SCCP method indicator (Note 2) : no indication */ int _SCCP_MI_NOINDICATION = 0; /** * See q.763 3.5 SCCP method indicator (Note 2) : connectionless method available (national use) */ int _SCCP_MI_CONNECTIONLESS = 1; /** * See q.763 3.5 SCCP method indicator (Note 2) : connection oriented method available */ int _SCCP_MI_CONNECTION_ORIENTED = 2; /** * See q.763 3.5 SCCP method indicator (Note 2) : connectionless and connection oriented methods available (national use) */ int _SCCP_MI_CL_AND_CO = 3; /** * See q.763 3.23 ISDN user part indicator (Note 2) : ISDN user part not used all the way */ boolean _ISDN_UPI_NOTUSED = false; /** * See q.763 3.23 ISDN user part indicator (Note 2) : ISDN user part used all the way */ boolean _ISDN_UPI_USED = true; /** * See q.763 3.23 ISDN user part preference indicator : ISDN user part preferred all the way */ int _ISDN_UPRI_PREFERED_ALL_THE_WAY = 0; /** * See q.763 3.23 ISDN user part preference indicator : ISDN user part not required all the way */ int _ISDN_UPRI_NRATW = 1; /** * See q.763 3.23 ISDN user part preference indicator : ISDN user part required all the way */ int _ISDN_UPRI_RATW = 2; boolean isNationalCallIdentificator(); void setNationalCallIdentificator(boolean nationalCallIdentificator); int getEndToEndMethodIndicator(); void setEndToEndMethodIndicator(int endToEndMethodIndicator); boolean isInterworkingIndicator(); void setInterworkingIndicator(boolean interworkingIndicator); boolean isEndToEndInformationIndicator(); void setEndToEndInformationIndicator(boolean endToEndInformationIndicator); boolean isIsdnUserPartIndicator(); void setIsdnUserPartIndicator(boolean isdnUserPartIndicator); int getIsdnUserPartReferenceIndicator(); void setIsdnUserPartReferenceIndicator(int isdnUserPartReferenceIndicator); int getSccpMethodIndicator(); void setSccpMethodIndicator(int sccpMethodIndicator); boolean isIsdnAccessIndicator(); void setIsdnAccessIndicator(boolean isdnAccessIndicator); } ```
```package org.restcomm.protocols.ss7.map.service.oam; import static org.testng.Assert.*; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.oam.PGWInterfaceListImpl; import org.testng.annotations.Test; /** * * @author sergey vetyutnev * */ public class PGWInterfaceListTest { private byte[] getEncodedData() { return new byte[] { 3, 2, 0, (byte) 173 }; } @Test(groups = { "functional.decode", "service.oam" }) public void testDecode() throws Exception { byte[] rawData = getEncodedData(); AsnInputStream asn = new AsnInputStream(rawData); int tag = asn.readTag(); PGWInterfaceListImpl asc = new PGWInterfaceListImpl(); asc.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(asc.getS2a()); assertFalse(asc.getS2b()); assertTrue(asc.getS2c()); assertFalse(asc.getS5()); assertTrue(asc.getS6b()); assertTrue(asc.getGx()); assertFalse(asc.getS8b()); assertTrue(asc.getSgi()); } @Test(groups = { "functional.encode", "service.oam" }) public void testEncode() throws Exception { PGWInterfaceListImpl asc = new PGWInterfaceListImpl(true, false, true, false, true, true, false, true); // boolean s2a, boolean s2b, boolean s2c, boolean s5, boolean s6b, // boolean gx, boolean s8b, boolean sgi AsnOutputStream asnOS = new AsnOutputStream(); asc.encodeAll(asnOS); byte[] encodedData = asnOS.toByteArray(); byte[] rawData = getEncodedData(); assertTrue(Arrays.equals(rawData, encodedData)); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.oam; import java.io.Serializable; /** * <code> PGW-InterfaceList ::= BIT STRING { s2a (0), s2b (1), s2c (2), s5 (3), s6b (4), gx (5), s8b (6), sgi (7) } (SIZE (8..16)) -- Other bits than listed above shall be discarded. </code> * * * @author sergey vetyutnev * */ public interface PGWInterfaceList extends Serializable { boolean getS2a(); boolean getS2b(); boolean getS2c(); boolean getS5(); boolean getS6b(); boolean getGx(); boolean getS8b(); boolean getSgi(); } ```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.AOCSubsequent; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.CAI_GSM0224; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.AOCSubsequentImpl; import org.restcomm.protocols.ss7.cap.service.circuitSwitchedCall.primitive.CAI_GSM0224Impl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.AOCGPRSImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class AOCGPRSTest { public byte[] getData() { return new byte[] { 48, 37, -96, 21, -128, 1, 1, -127, 1, 2, -126, 1, 3, -125, 1, 4, -124, 1, 5, -123, 1, 6, -122, 1, 7, -95, 12, -96, 6, -125, 1, 4, -124, 1, 5, -127, 2, 0, -34 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); AOCGPRSImpl prim = new AOCGPRSImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals((int) prim.getAOCInitial().getE1(), 1); assertEquals((int) prim.getAOCInitial().getE2(), 2); assertEquals((int) prim.getAOCInitial().getE3(), 3); assertEquals((int) prim.getAOCInitial().getE4(), 4); assertEquals((int) prim.getAOCInitial().getE5(), 5); assertEquals((int) prim.getAOCInitial().getE6(), 6); assertEquals((int) prim.getAOCInitial().getE7(), 7); assertNull(prim.getAOCSubsequent().getCAI_GSM0224().getE1()); assertNull(prim.getAOCSubsequent().getCAI_GSM0224().getE2()); assertNull(prim.getAOCSubsequent().getCAI_GSM0224().getE3()); assertEquals((int) prim.getAOCSubsequent().getCAI_GSM0224().getE4(), 4); assertEquals((int) prim.getAOCSubsequent().getCAI_GSM0224().getE5(), 5); assertNull(prim.getAOCSubsequent().getCAI_GSM0224().getE6()); assertNull(prim.getAOCSubsequent().getCAI_GSM0224().getE7()); assertEquals((int) prim.getAOCSubsequent().getTariffSwitchInterval(), 222); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { CAI_GSM0224 aocInitial = new CAI_GSM0224Impl(1, 2, 3, 4, 5, 6, 7); CAI_GSM0224Impl cai_GSM0224 = new CAI_GSM0224Impl(null, null, null, 4, 5, null, null); AOCSubsequent aocSubsequent = new AOCSubsequentImpl(cai_GSM0224, 222); AOCGPRSImpl prim = new AOCGPRSImpl(aocInitial, aocSubsequent); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.AOCSubsequent; import org.restcomm.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.CAI_GSM0224; /** * AOCGPRS ::= SEQUENCE { aOCInitial [0] CAI-GSM0224, aOCSubsequent [1] AOCSubsequent OPTIONAL } * * * * * @author sergey vetyutnev * */ public interface AOCGPRS extends Serializable { CAI_GSM0224 getAOCInitial(); AOCSubsequent getAOCSubsequent(); }```
```package org.restcomm.protocols.ss7.cap.service.gprs.primitive; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.PDPTypeNumberValue; import org.restcomm.protocols.ss7.cap.api.service.gprs.primitive.PDPTypeOrganizationValue; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.EndUserAddressImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.PDPAddressImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.PDPTypeNumberImpl; import org.restcomm.protocols.ss7.cap.service.gprs.primitive.PDPTypeOrganizationImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class EndUserAddressTest { public byte[] getData() { return new byte[] { 48, 11, -128, 1, -15, -127, 1, 1, -126, 3, 4, 7, 7 }; }; public byte[] getPDPAddressData() { return new byte[] { 4, 7, 7 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); EndUserAddressImpl prim = new EndUserAddressImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertEquals(prim.getPDPTypeNumber().getPDPTypeNumberValue(), PDPTypeNumberValue.PPP); assertEquals(prim.getPDPTypeOrganization().getPDPTypeOrganizationValue(), PDPTypeOrganizationValue.ETSI); assertTrue(Arrays.equals(prim.getPDPAddress().getData(), this.getPDPAddressData())); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { PDPAddressImpl pdpAddress = new PDPAddressImpl(getPDPAddressData()); PDPTypeNumberImpl pdpTypeNumber = new PDPTypeNumberImpl(PDPTypeNumberValue.PPP); PDPTypeOrganizationImpl pdpTypeOrganization = new PDPTypeOrganizationImpl(PDPTypeOrganizationValue.ETSI); EndUserAddressImpl prim = new EndUserAddressImpl(pdpTypeOrganization, pdpTypeNumber, pdpAddress); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.gprs.primitive; import java.io.Serializable; /** * EndUserAddress {PARAMETERS-BOUND: bound} ::= SEQUENCE { pDPTypeOrganization [0] PDPTypeOrganization, pDPTypeNumber [1] * PDPTypeNumber, pDPAddress [2] PDPAddress OPTIONAL } -- Indicates the EndUserAddress, refer to 3GPP TS 29.060 [12] for the * encoding. * * * @author sergey vetyutnev * */ public interface EndUserAddress extends Serializable { PDPTypeOrganization getPDPTypeOrganization(); PDPTypeNumber getPDPTypeNumber(); PDPAddress getPDPAddress(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.EchoControlInformationImpl; import org.testng.annotations.Test; /** * Start time:11:34:01 2009-04-24<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class EchoControlInformationTest extends ParameterHarness { public EchoControlInformationTest() { super(); super.goodBodies.add(new byte[] { 67 }); super.badBodies.add(new byte[2]); } private byte[] getBody(int _OUT_E_CDII, int _IN_E_CDII, int _IN_E_CDRI, int _OUT_E_CDRI) { byte[] b = new byte[1]; int v = _OUT_E_CDII; v |= _IN_E_CDII << 2; v |= _OUT_E_CDRI << 4; v |= _IN_E_CDRI << 6; b[0] = (byte) v; return b; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws ParameterException { EchoControlInformationImpl eci = new EchoControlInformationImpl(getBody( EchoControlInformationImpl._OUTGOING_ECHO_CDII_NINA, EchoControlInformationImpl._INCOMING_ECHO_CDII_INCLUDED, EchoControlInformationImpl._INCOMING_ECHO_CDRI_AR, EchoControlInformationImpl._OUTGOING_ECHO_CDRI_NOINFO)); String[] methodNames = { "getOutgoingEchoControlDeviceInformationIndicator", "getIncomingEchoControlDeviceInformationIndicator", "getIncomingEchoControlDeviceInformationRequestIndicator", "getOutgoingEchoControlDeviceInformationRequestIndicator" }; Object[] expectedValues = { EchoControlInformationImpl._OUTGOING_ECHO_CDII_NINA, EchoControlInformationImpl._INCOMING_ECHO_CDII_INCLUDED, EchoControlInformationImpl._INCOMING_ECHO_CDRI_AR, EchoControlInformationImpl._OUTGOING_ECHO_CDRI_NOINFO }; super.testValues(eci, methodNames, expectedValues); } /* * (non-Javadoc) * * @see org.mobicents.isup.messages.parameters.ParameterHarness#getTestedComponent () */ public AbstractISUPParameter getTestedComponent() throws ParameterException { return new EchoControlInformationImpl(new byte[1]); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:12:44:34 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface EchoControlInformation extends ISUPParameter { int _PARAMETER_CODE = 0x37; /** * See Q.763 3.19 Outgoing echo control device information indicator : no information */ int _OUTGOING_ECHO_CDII_NOINFO = 0; /** * See Q.763 3.19 Outgoing echo control device information indicator : outgoing echo control device not included and not * available */ int _OUTGOING_ECHO_CDII_NINA = 1; /** * See Q.763 3.19 Outgoing echo control device information indicator : outgoing echo control device included */ int _OUTGOING_ECHO_CDII_INCLUDED = 2; /** * See Q.763 3.19 Outgoing echo control device information indicator : outgoing echo control device not included but * available */ int _OUTGOING_ECHO_CDII_NIA = 3; /** * See Q.763 3.19 Incoming echo control device information indicator : no information */ int _INCOMING_ECHO_CDII_NOINFO = 0; /** * See Q.763 3.19 Incoming echo control device information indicator : incoming echo control device not included and not * available */ int _INCOMING_ECHO_CDII_NINA = 1; /** * See Q.763 3.19 Incoming echo control device information indicator : incoming echo control device included */ int _INCOMING_ECHO_CDII_INCLUDED = 2; /** * See Q.763 3.19 Incoming echo control device information indicator : incoming echo control device not included but * available */ int _INCOMING_ECHO_CDII_NIA = 3; /** * See Q.763 3.19 Incoming echo control device request indicator : no information */ int _INCOMING_ECHO_CDRI_NOINFO = 0; /** * See Q.763 3.19 Incoming echo control device request indicator : incoming echo control device activation request */ int _INCOMING_ECHO_CDRI_AR = 1; /** * See Q.763 3.19 Incoming echo control device request indicator : incoming echo control device deactivation request (Note * 2) */ int _INCOMING_ECHO_CDRI_DR = 2; /** * See Q.763 3.19 Outgoing echo control device request indicator : no information */ int _OUTGOING_ECHO_CDRI_NOINFO = 0; /** * See Q.763 3.19 Outgoing echo control device request indicator : outgoing echo control device activation request */ int _OUTGOING_ECHO_CDRI_AR = 1; /** * See Q.763 3.19 Outgoing echo control device request indicator : outgoing echo control device deactivation request (Note * 1) */ int _OUTGOING_ECHO_CDRI_DR = 2; int getOutgoingEchoControlDeviceInformationIndicator(); void setOutgoingEchoControlDeviceInformationIndicator(int outgoingEchoControlDeviceInformationIndicator); int getIncomingEchoControlDeviceInformationIndicator(); void setIncomingEchoControlDeviceInformationIndicator(int incomingEchoControlDeviceInformationIndicator); int getOutgoingEchoControlDeviceInformationRequestIndicator(); void setOutgoingEchoControlDeviceInformationRequestIndicator(int outgoingEchoControlDeviceInformationRequestIndicator); int getIncomingEchoControlDeviceInformationRequestIndicator(); void setIncomingEchoControlDeviceInformationRequestIndicator(int incomingEchoControlDeviceInformationRequestIndicator); } ```
```package org.restcomm.protocols.ss7.cap.service.sms; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.CalledPartyBCDNumber; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.SMSAddressString; import org.restcomm.protocols.ss7.cap.primitives.CAPExtensionsTest; import org.restcomm.protocols.ss7.cap.primitives.CalledPartyBCDNumberImpl; import org.restcomm.protocols.ss7.cap.service.sms.ConnectSMSRequestImpl; import org.restcomm.protocols.ss7.cap.service.sms.primitive.SMSAddressStringImpl; import org.restcomm.protocols.ss7.map.api.primitives.AddressNature; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; import org.restcomm.protocols.ss7.map.api.primitives.NumberingPlan; import org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class ConnectSMSRequestTest { public byte[] getData() { return new byte[] { 48, 48, -128, 9, -111, 33, 67, 101, -121, 25, 50, 84, 118, -127, 7, -111, 20, -121, 8, 80, 64, -9, -126, 6, -111, 34, 112, 87, 0, -128, -86, 18, 48, 5, 2, 1, 2, -127, 0, 48, 9, 2, 1, 3, 10, 1, 1, -127, 1, -1 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); ConnectSMSRequestImpl prim = new ConnectSMSRequestImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.SEQUENCE); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); CalledPartyBCDNumber destinationSubscriberNumber = prim.getDestinationSubscriberNumber(); SMSAddressString callingPartyNumber = prim.getCallingPartysNumber(); assertNotNull(destinationSubscriberNumber); assertTrue(destinationSubscriberNumber.getAddress().equals("41788005047")); assertNotNull(callingPartyNumber); assertTrue(callingPartyNumber.getAddress().equals("1234567891234567")); ISDNAddressString smscAddress = prim.getSMSCAddress(); assertNotNull(smscAddress); assertTrue(smscAddress.getAddress().equals("2207750008")); // extensions CAPExtensionsTest.checkTestCAPExtensions(prim.getExtensions()); } @Test(groups = { "functional.encode", "primitives" }) public void testEncode() throws Exception { SMSAddressString callingPartysNumber = new SMSAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "1234567891234567"); CalledPartyBCDNumber destinationSubscriberNumber = new CalledPartyBCDNumberImpl( AddressNature.international_number, NumberingPlan.ISDN, "41788005047"); ISDNAddressString smscAddress = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2207750008"); CAPExtensions extensions = CAPExtensionsTest.createTestCAPExtensions(); ConnectSMSRequestImpl prim = new ConnectSMSRequestImpl(callingPartysNumber, destinationSubscriberNumber, smscAddress, extensions); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.cap.api.service.sms; import org.restcomm.protocols.ss7.cap.api.primitives.CAPExtensions; import org.restcomm.protocols.ss7.cap.api.primitives.CalledPartyBCDNumber; import org.restcomm.protocols.ss7.cap.api.service.sms.primitive.SMSAddressString; import org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString; /** * connectSMS {PARAMETERS-BOUND : bound} OPERATION ::= { ARGUMENT ConnectSMSArg {bound} RETURN RESULT FALSE ERRORS {missingParameter | parameterOutOfRange | systemFailure | taskRefused | unexpectedComponentSequence | unexpectedDataValue | unexpectedParameter} CODE opcode-connectSMS} -- Direction: gsmSCF -> gsmSSF or gprsSSF, Timer: Tconsms -- This operation is used to request the smsSSF to perform the SMS processing -- actions to route or forward a short message to a specified destination. ConnectSMSArg {PARAMETERS-BOUND : bound} ::= SEQUENCE { callingPartysNumber [0] SMS-AddressString OPTIONAL, destinationSubscriberNumber [1] CalledPartyBCDNumber {bound} OPTIONAL, sMSCAddress [2] ISDN-AddressString OPTIONAL, extensions [10] Extensions {bound} OPTIONAL, ... } * * * * @author sergey vetyutnev * */ public interface ConnectSMSRequest extends SmsMessage { SMSAddressString getCallingPartysNumber(); CalledPartyBCDNumber getDestinationSubscriberNumber(); ISDNAddressString getSMSCAddress(); CAPExtensions getExtensions(); }```
```package org.restcomm.protocols.ss7.isup.impl.message.parameter; import java.lang.reflect.InvocationTargetException; import org.restcomm.protocols.ss7.isup.ParameterException; import org.restcomm.protocols.ss7.isup.impl.message.parameter.AbstractISUPParameter; import org.restcomm.protocols.ss7.isup.impl.message.parameter.CircuitStateIndicatorImpl; import org.restcomm.protocols.ss7.isup.message.parameter.CircuitGroupSuperVisionMessageType; import org.restcomm.protocols.ss7.isup.message.parameter.CircuitStateIndicator; import org.testng.annotations.Test; /** * Start time:12:21:06 2009-04-23<br> * Project: mobicents-isup-stack<br> * Class to test BCI * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public class CircuitStateIndicatorTest extends ParameterHarness { public CircuitStateIndicatorTest() { super(); super.goodBodies.add(getBody1()); } private byte[] getBody1() { byte[] body = new byte[]{0x0E}; return body; } @Test(groups = { "functional.encode", "functional.decode", "parameter" }) public void testBody1EncodedValues() throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, ParameterException { CircuitStateIndicatorImpl at = new CircuitStateIndicatorImpl(getBody1()); String[] methodNames = { "getCircuitState" }; Object[] expectedValues = { new byte[]{0x0E} }; super.testValues(at, methodNames, expectedValues); } public AbstractISUPParameter getTestedComponent() throws ParameterException { return new org.restcomm.protocols.ss7.isup.impl.message.parameter.CircuitStateIndicatorImpl(); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.isup.message.parameter; /** * Start time:12:22:51 2009-07-23<br> * Project: mobicents-isup-stack<br> * * @author <a href="mailto:baranowb@gmail.com">Bartosz Baranowski </a> */ public interface CircuitStateIndicator extends ISUPParameter { int _PARAMETER_CODE = 0x26; // FIXME: Q.763 3.14 - Oleg is this correct? /** * See Q.763 3.14 Maintenance blocking state - for call processing state "0" : transient */ int _MBS_NPS_TRANSIENT = 0; /** * See Q.763 3.14 Maintenance blocking state - for call processing state "0" : unequipped */ int _MBS_NPS_UNEQUIPED = 3; /** * See Q.763 3.14 Maintenance blocking state - for call processing state ~"0" : no blocking - active */ int _MBS_NO_BLOCKING = 0; /** * See Q.763 3.14 Maintenance blocking state - for call processing state ~"0" : localy blocked */ int _MBS_LOCALY_BLOCKED = 1; /** * See Q.763 3.14 Maintenance blocking state - for call processing state ~"0" : remotely blocked blocked */ int _MBS_REMOTELY_BLOCKED = 2; /** * See Q.763 3.14 Maintenance blocking state - for call processing state ~"0" : locally and remotely blocked */ int _MBS_LAR_BLOCKED = 3; /** * See Q.763 3.14 Call processing state : circuit incoming busy */ int _CPS_CIB = 1; /** * See Q.763 3.14 Call processing state : circuit outgoing busy */ int _CPS_COB = 2; /** * See Q.763 3.14 Call processing state : idle */ int _CPS_IDLE = 3; /** * See Q.763 3.14 Hardware blocking state (Note: if this does not equal "0" Call Processing State must be equal to "3") : no * blocking (active) */ int _HBS_NO_BLOCKING = 0; /** * See Q.763 3.14 Hardware blocking state (Note: if this does not equal "0" Call Processing State must be equal to "3") : * locally blocked */ int _HBS_LOCALY_BLOCKED = 1; /** * See Q.763 3.14 Hardware blocking state (Note: if this does not equal "0" Call Processing State must be equal to "3") : * remotely blocked */ int _HBS_REMOTELY_BLOCKED = 2; /** * See Q.763 3.14 Hardware blocking state (Note: if this does not equal "0" Call Processing State must be equal to "3") : * locally and remotely blocked */ int _HBS_LAR_BLOCKED = 3; byte[] getCircuitState(); void setCircuitState(byte[] circuitState) throws IllegalArgumentException; byte createCircuitState(int MBS, int CPS, int HBS); int getCallProcessingState(byte b); int getHardwareBlockingState(byte b); int getMaintenanceBlockingState(byte b); } ```
```package org.restcomm.protocols.ss7.map.service.mobility.locationManagement; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.util.Arrays; import org.mobicents.protocols.asn.AsnInputStream; import org.mobicents.protocols.asn.AsnOutputStream; import org.mobicents.protocols.asn.Tag; import org.restcomm.protocols.ss7.map.service.mobility.locationManagement.SupportedFeaturesImpl; import org.testng.annotations.Test; /** * * @author Lasith Waruna Perera * */ public class SupportedFeaturesTest { public byte[] getData() { return new byte[] { 3, 5, 6, 85, 85, 85, 64 }; }; public byte[] getData1() { return new byte[] { 3, 5, 6, -86, -86, -86, -128 }; }; @Test(groups = { "functional.decode", "primitives" }) public void testDecode() throws Exception { // test one byte[] data = this.getData(); AsnInputStream asn = new AsnInputStream(data); int tag = asn.readTag(); SupportedFeaturesImpl prim = new SupportedFeaturesImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(!prim.getOdbAllApn()); assertTrue(prim.getOdbHPLMNApn()); assertTrue(!prim.getOdbVPLMNApn()); assertTrue(prim.getOdbAllOg()); assertTrue(!prim.getOdbAllInternationalOg()); assertTrue(prim.getOdbAllIntOgNotToHPLMNCountry()); assertTrue(!prim.getOdbAllInterzonalOg()); assertTrue(prim.getOdbAllInterzonalOgNotToHPLMNCountry()); assertTrue(!prim.getOdbAllInterzonalOgandInternatOgNotToHPLMNCountry()); assertTrue(prim.getRegSub()); assertTrue(!prim.getTrace()); assertTrue(prim.getLcsAllPrivExcep()); assertTrue(!prim.getLcsUniversal()); assertTrue(prim.getLcsCallSessionRelated()); assertTrue(!prim.getLcsCallSessionUnrelated()); assertTrue(prim.getLcsPLMNOperator()); assertTrue(!prim.getLcsServiceType()); assertTrue(prim.getLcsAllMOLRSS()); assertTrue(!prim.getLcsBasicSelfLocation()); assertTrue(prim.getLcsAutonomousSelfLocation()); assertTrue(!prim.getLcsTransferToThirdParty()); assertTrue(prim.getSmMoPp()); assertTrue(!prim.getBarringOutgoingCalls()); assertTrue(prim.getBaoc()); assertTrue(!prim.getBoic()); assertTrue(prim.getBoicExHC()); // test two data = this.getData1(); asn = new AsnInputStream(data); tag = asn.readTag(); prim = new SupportedFeaturesImpl(); prim.decodeAll(asn); assertEquals(tag, Tag.STRING_BIT); assertEquals(asn.getTagClass(), Tag.CLASS_UNIVERSAL); assertTrue(prim.getOdbAllApn()); assertTrue(!prim.getOdbHPLMNApn()); assertTrue(prim.getOdbVPLMNApn()); assertTrue(!prim.getOdbAllOg()); assertTrue(prim.getOdbAllInternationalOg()); assertTrue(!prim.getOdbAllIntOgNotToHPLMNCountry()); assertTrue(prim.getOdbAllInterzonalOg()); assertTrue(!prim.getOdbAllInterzonalOgNotToHPLMNCountry()); assertTrue(prim.getOdbAllInterzonalOgandInternatOgNotToHPLMNCountry()); assertTrue(!prim.getRegSub()); assertTrue(prim.getTrace()); assertTrue(!prim.getLcsAllPrivExcep()); assertTrue(prim.getLcsUniversal()); assertTrue(!prim.getLcsCallSessionRelated()); assertTrue(prim.getLcsCallSessionUnrelated()); assertTrue(!prim.getLcsPLMNOperator()); assertTrue(prim.getLcsServiceType()); assertTrue(!prim.getLcsAllMOLRSS()); assertTrue(prim.getLcsBasicSelfLocation()); assertTrue(!prim.getLcsAutonomousSelfLocation()); assertTrue(prim.getLcsTransferToThirdParty()); assertTrue(!prim.getSmMoPp()); assertTrue(prim.getBarringOutgoingCalls()); assertTrue(!prim.getBaoc()); assertTrue(prim.getBoic()); assertTrue(!prim.getBoicExHC()); } @Test(groups = { "functional.decode", "primitives" }) public void testEncode() throws Exception { // Test one SupportedFeaturesImpl prim = new SupportedFeaturesImpl(false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true); AsnOutputStream asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData())); // Tes two prim = new SupportedFeaturesImpl(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false); asn = new AsnOutputStream(); prim.encodeAll(asn); assertTrue(Arrays.equals(asn.toByteArray(), this.getData1())); } } ```
Please help me generate a test for this class.
```package org.restcomm.protocols.ss7.map.api.service.mobility.locationManagement; import java.io.Serializable; /** * SupportedFeatures::= BIT STRING { odb-all-apn (0), odb-HPLMN-APN (1), odb-VPLMN-APN (2), odb-all-og (3), * odb-all-international-og (4), odb-all-int-og-not-to-HPLMN-country (5), odb-all-interzonal-og (6), * odb-all-interzonal-og-not-to-HPLMN-country (7), odb-all-interzonal-og-and-internat-og-not-to-HPLMN-country (8), regSub (9), * trace (10), lcs-all-PrivExcep (11), lcs-universal (12), lcs-CallSessionRelated (13), lcs-CallSessionUnrelated (14), * lcs-PLMN-operator (15), lcs-ServiceType (16), lcs-all-MOLR-SS (17), lcs-basicSelfLocation (18), lcs-autonomousSelfLocation * (19), lcs-transferToThirdParty (20), sm-mo-pp (21), barring-OutgoingCalls (22), baoc (23), boic (24), boicExHC (25)} (SIZE * (26..40)) * * * @author sergey vetyutnev * */ public interface SupportedFeatures extends Serializable { boolean getOdbAllApn(); boolean getOdbHPLMNApn(); boolean getOdbVPLMNApn(); boolean getOdbAllOg(); boolean getOdbAllInternationalOg(); boolean getOdbAllIntOgNotToHPLMNCountry(); boolean getOdbAllInterzonalOg(); boolean getOdbAllInterzonalOgNotToHPLMNCountry(); boolean getOdbAllInterzonalOgandInternatOgNotToHPLMNCountry(); boolean getRegSub(); boolean getTrace(); boolean getLcsAllPrivExcep(); boolean getLcsUniversal(); boolean getLcsCallSessionRelated(); boolean getLcsCallSessionUnrelated(); boolean getLcsPLMNOperator(); boolean getLcsServiceType(); boolean getLcsAllMOLRSS(); boolean getLcsBasicSelfLocation(); boolean getLcsAutonomousSelfLocation(); boolean getLcsTransferToThirdParty(); boolean getSmMoPp(); boolean getBarringOutgoingCalls(); boolean getBaoc(); boolean getBoic(); boolean getBoicExHC(); } ```