@Test public void testCreateAdvertiseDataToServiceData_failedToAddManufacturerData() throws Exception { int mostSigBits = 1; int leastSigBits = 2; UUID uuid = new UUID(mostSigBits, leastSigBits); int beaconAdExtraInformation = DiscoveryManagerSettings.DEFAULT_BEACON_AD_EXTRA_INFORMATION; String correctBluetoothMacAddress = "00:11:22:33:44:55"; when(mMockBuilder.build()).thenReturn(mMockAdvertiseData); doThrow(IllegalArgumentException.class).when(mMockBuilder) .addServiceData(any(ParcelUuid.class), any(byte[].class)); AdvertiseData advertiseData = PeerAdvertisementFactory.createAdvertiseDataToServiceData( uuid, beaconAdExtraInformation, correctBluetoothMacAddress, mMockBuilder); assertThat("A null is returned in case of a failure to add the manufacturer data", advertiseData, is(nullValue())); }
public static AdvertiseData createAdvertiseDataToServiceData( UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress) { AdvertiseData.Builder builder = new AdvertiseData.Builder(); return PeerAdvertisementFactory.createAdvertiseDataToServiceData( serviceUuid, beaconAdExtraInformation, bluetoothMacAddress, builder); }
PeerAdvertisementFactory { public static AdvertiseData createAdvertiseDataToServiceData( UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress) { AdvertiseData.Builder builder = new AdvertiseData.Builder(); return PeerAdvertisementFactory.createAdvertiseDataToServiceData( serviceUuid, beaconAdExtraInformation, bluetoothMacAddress, builder); } }
PeerAdvertisementFactory { public static AdvertiseData createAdvertiseDataToServiceData( UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress) { AdvertiseData.Builder builder = new AdvertiseData.Builder(); return PeerAdvertisementFactory.createAdvertiseDataToServiceData( serviceUuid, beaconAdExtraInformation, bluetoothMacAddress, builder); }  }
PeerAdvertisementFactory { public static AdvertiseData createAdvertiseDataToServiceData( UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress) { AdvertiseData.Builder builder = new AdvertiseData.Builder(); return PeerAdvertisementFactory.createAdvertiseDataToServiceData( serviceUuid, beaconAdExtraInformation, bluetoothMacAddress, builder); }  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); }
PeerAdvertisementFactory { public static AdvertiseData createAdvertiseDataToServiceData( UUID serviceUuid, int beaconAdExtraInformation, String bluetoothMacAddress) { AdvertiseData.Builder builder = new AdvertiseData.Builder(); return PeerAdvertisementFactory.createAdvertiseDataToServiceData( serviceUuid, beaconAdExtraInformation, bluetoothMacAddress, builder); }  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);  }