PeerAdvertisementFactory { public static PeerProperties parsedAdvertisementToPeerProperties( BlePeerDiscoveryUtils.ParsedAdvertisement parsedAdvertisement) { PeerProperties peerProperties = null; if (parsedAdvertisement != null) { Log.d(TAG, "Parsed advertisment: " + parsedAdvertisement.toString()); if (parsedAdvertisement.bluetoothMacAddress != null) { peerProperties = new PeerProperties(parsedAdvertisement.bluetoothMacAddress, parsedAdvertisement.extraInformation); } else { Log.e(TAG, "parsedAdvertisementToPeerProperties: No Bluetooth MAC address"); } } return peerProperties; }  static AdvertiseData createAdvertiseDataToServiceData(
            UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress); static AdvertiseData createAdvertiseDataToServiceData(
            UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress,
            AdvertiseData.Builder builder); static AdvertiseData createAdvertiseDataToManufacturerData(
            int manufacturerId, int beaconAdLengthAndType, UUID serviceUuid,
            int beaconAdExtraInformation, String bluetoothMacAddress); static AdvertiseData createAdvertiseDataToManufacturerData(
            int manufacturerId, int beaconAdLengthAndType, UUID serviceUuid,
            int beaconAdExtraInformation, String bluetoothMacAddress,
            AdvertiseData.Builder builder, ByteArrayOutputStream byteArrayOutputStream,
            DataOutput dataOutputStream); static PeerProperties parsedAdvertisementToPeerProperties(
            BlePeerDiscoveryUtils.ParsedAdvertisement parsedAdvertisement); static PeerProperties manufacturerDataToPeerProperties(byte[] manufacturerData, UUID serviceUuid); static UUID createProvideBluetoothMacAddressUuid(UUID serviceUuid, String requestId); static UUID generateNewProvideBluetoothMacAddressRequestUuid(UUID serviceUuid); static String parseRequestIdFromUuid(UUID provideBluetoothMacAddressRequestUuid);  }
@Test public void testParsedAdvertisementToPeerProperties() throws Exception { mMockParsedAdvertisement.bluetoothMacAddress = "00:11:22:33:44:55"; mMockParsedAdvertisement.extraInformation = 1; PeerProperties pp = PeerAdvertisementFactory .parsedAdvertisementToPeerProperties(mMockParsedAdvertisement); assertThat("The PeerProperties is properly prepared", pp, is(notNullValue())); assertThat("The extraInformation is properly updated", pp.getExtraInformation(), is(mMockParsedAdvertisement.extraInformation)); assertThat("The bluetoothMacAddress is properly updated", pp.getBluetoothMacAddress(), is(mMockParsedAdvertisement.bluetoothMacAddress)); }
@Test public void testParsedAdvertisementToPeerProperties_noBTAddress() throws Exception { PeerProperties pp = PeerAdvertisementFactory .parsedAdvertisementToPeerProperties(mMockParsedAdvertisement); assertThat("The PeerProperties is null when no BT address provided", pp, is(nullValue())); }
@Test public void testParsedAdvertisementToPeerProperties_null() throws Exception { PeerProperties pp = PeerAdvertisementFactory .parsedAdvertisementToPeerProperties(null); assertThat("The PeerProperties is null when null parsedAdvertisement provided", pp, is(nullValue())); }