### Question:
AttributionDialogManager implements View.OnClickListener, DialogInterface.OnClickListener { @NonNull String buildMapFeedbackMapUrl(@Nullable String accessToken) { Uri.Builder builder = Uri.parse(MAP_FEEDBACK_URL).buildUpon(); CameraPosition cameraPosition = mapboxMap.getCameraPosition(); if (cameraPosition != null) { builder.encodedFragment(String.format(Locale.getDefault(), MAP_FEEDBACK_URL_LOCATION_FRAGMENT_FORMAT, cameraPosition.target.getLongitude(), cameraPosition.target.getLatitude(), cameraPosition.zoom, cameraPosition.bearing, (int) cameraPosition.tilt)); } String packageName = context.getApplicationContext().getPackageName(); if (packageName != null) { builder.appendQueryParameter("referrer", packageName); } if (accessToken != null) { builder.appendQueryParameter("access_token", accessToken); } Style style = mapboxMap.getStyle(); if (style != null) { String styleUri = style.getUri(); Pattern pattern = Pattern.compile(MAP_FEEDBACK_STYLE_URI_REGEX); Matcher matcher = pattern.matcher(styleUri); if (matcher.find()) { String styleOwner = matcher.group(2); String styleId = matcher.group(3); builder.appendQueryParameter("owner", styleOwner) .appendQueryParameter("id", styleId); } } return builder.build().toString(); } AttributionDialogManager(@NonNull Context context, @NonNull MapboxMap mapboxMap); @Override void onClick(@NonNull View view); @Override void onClick(DialogInterface dialog, int which); void onStop();  }### Answer:
@Test public void testBuildMapFeedbackMapUrl() { when(context.getApplicationContext()).thenReturn(context); when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME); when(style.getUri()).thenReturn(ASSERT_MAPBOX_STYLE_URI); when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition); when(mapboxMap.getStyle()).thenReturn(style); Assert.assertEquals(ASSERT_MAPBOX_FEEDBACK_FINAL_URL, attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN)); }
@Test public void testBuildMapFeedbackMapUrlWithLocalStyleJson() { when(context.getApplicationContext()).thenReturn(context); when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME); when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI); when(mapboxMap.getCameraPosition()).thenReturn(cameraPosition); when(mapboxMap.getStyle()).thenReturn(style); Assert.assertEquals(ASSERT_MAPBOX_FEEDHACK_FINAL_URL_LOCAL_STYLE, attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN)); }
@Test public void testBuildMapFeedbackMapUrlWithNullCameraPosition() { when(context.getApplicationContext()).thenReturn(context); when(context.getPackageName()).thenReturn(ASSERT_MAPBOX_PACKAGE_NAME); when(style.getUri()).thenReturn(ASSERT_MAPBOX_LOCAL_STYLE_URI); when(mapboxMap.getCameraPosition()).thenReturn(null); when(mapboxMap.getStyle()).thenReturn(style); Assert.assertEquals(ASSERT_MAPBOX_FEEDBACL_FINAL_URL_NULL_CAMERA_POSITION, attributionDialogManager.buildMapFeedbackMapUrl(ASSERT_MAPBOX_TOKEN)); }