AdnRecord adn;
//
// Typical record
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C07918150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("+18056377243", adn.getNumber());
assertFalse(adn.isEmpty());
//
// Empty records, empty strings
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"));
assertEquals("", adn.getAlphaTag());
assertEquals("", adn.getNumber());
assertTrue(adn.isEmpty());
//
// Record too short
//
adn = new AdnRecord(SimUtils.hexStringToBytes( "FF"));
assertEquals("", adn.getAlphaTag());
assertEquals("", adn.getNumber());
assertTrue(adn.isEmpty());
//
// TOA = 0xff ("control string")
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C07FF8150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("18056377243", adn.getNumber());
assertFalse(adn.isEmpty());
//
// TOA = 0x81 (unknown)
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C07818150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("18056377243", adn.getNumber());
assertFalse(adn.isEmpty());
//
// Number Length is too long
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C0F918150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("", adn.getNumber());
assertFalse(adn.isEmpty());
//
// Number Length is zero (invalid)
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C00918150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("", adn.getNumber());
assertFalse(adn.isEmpty());
//
// Number Length is 2, first number byte is FF, TOA is international
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C0291FF50367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("", adn.getNumber());
assertFalse(adn.isEmpty());
//
// Number Length is 2, first number digit is valid, TOA is international
//
adn = new AdnRecord(
SimUtils.hexStringToBytes("566F696365204D61696C0291F150367742F3FFFFFFFFFFFF"));
assertEquals("Voice Mail", adn.getAlphaTag());
assertEquals("+1", adn.getNumber());
assertFalse(adn.isEmpty());
//
// An extended record
//
adn = new AdnRecord(
SimUtils.hexStringToBytes(
"4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678", adn.getNumber());
assertFalse(adn.isEmpty());
assertTrue(adn.hasExtendedRecord());
adn.appendExtRecord(SimUtils.hexStringToBytes("0206092143658709ffffffffff"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678901234567890", adn.getNumber());
assertFalse(adn.isEmpty());
//
// An extended record with an invalid extension
//
adn = new AdnRecord(
SimUtils.hexStringToBytes(
"4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678", adn.getNumber());
assertFalse(adn.isEmpty());
assertTrue(adn.hasExtendedRecord());
adn.appendExtRecord(SimUtils.hexStringToBytes("0106092143658709ffffffffff"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678", adn.getNumber());
assertFalse(adn.isEmpty());
//
// An extended record with an invalid extension
//
adn = new AdnRecord(
SimUtils.hexStringToBytes(
"4164676A6DFFFFFFFFFFFFFFFFFFFFFF0B918188551512C221436587FF01"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678", adn.getNumber());
assertFalse(adn.isEmpty());
assertTrue(adn.hasExtendedRecord());
adn.appendExtRecord(SimUtils.hexStringToBytes("020B092143658709ffffffffff"));
assertEquals("Adgjm", adn.getAlphaTag());
assertEquals("+18885551212,12345678", adn.getNumber());
assertFalse(adn.isEmpty());