AudioPlayerNotification { public Notification buildNotification(Episode episode) { Notification.MediaStyle mediaStyle = new Notification.MediaStyle(); return notificationBuilder .setSmallIcon(R.drawable.ic_av_play_circle_fill) .setContentTitle(episode.getFeed().getTitle()) .setContentText(episode.getTitle()) .setStyle(mediaStyle) .setVisibility(Notification.VISIBILITY_PUBLIC) .addAction(generateAction(episode, R.drawable.ic_fast_rewind, REWIND, ACTION_REWIND)) .addAction(generateAction(episode, R.drawable.ic_pause, PAUSE, ACTION_PAUSE)) .addAction(generateAction(episode, R.drawable.ic_stop_black, STOP, ACTION_STOP)) .addAction(generateAction(episode, R.drawable.ic_fast_forward, FAST_FORWARD, ACTION_FAST_FORWARD)) .build(); } @Inject  AudioPlayerNotification(Context context, Notification.Builder notificationBuilder); Notification buildNotification(Episode episode);  }
@Test public void itSetsNotificationSmallIcon() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.icon, is(R.drawable.ic_av_play_circle_fill)); }
@Test public void itSetsNotificationVisibility() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.visibility, is(Notification.VISIBILITY_PUBLIC)); }
@Test public void itSetsNotificationContentTitle() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TITLE), is("Foo Bar")); }
@Test public void itSetsNotificationContentText() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(notification.extras.getString(Notification.EXTRA_TEXT), is("Lorem ipsum dolor sit amet")); }
@TargetApi(Build.VERSION_CODES.M) @Test public void itReturnsNotificationWithMediaControlActions() { Notification notification = audioPlayerNotification.buildNotification(episode); assertThat(String.valueOf(notification.actions[0].title), is(REWIND)); assertThat( notification.actions[0].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_rewind).toString()) ); assertThat(String.valueOf(notification.actions[1].title), is(PAUSE)); assertThat( notification.actions[1].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_pause).toString()) ); assertThat(String.valueOf(notification.actions[2].title), is(STOP)); assertThat( notification.actions[2].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_stop_black).toString()) ); assertThat(String.valueOf(notification.actions[3].title), is(FAST_FORWARD)); assertThat( notification.actions[3].getIcon().toString(), is(Icon.createWithResource("", R.drawable.ic_fast_forward).toString()) ); }