@Test public void givenAndroidVersionMarshmallowOrHigher_whenCreatingANewCaptionManager_thenMarshmallowClosedCaptionManagerReturned() { when(mockAndroidVersion.isMarshmallowOrHigher()).thenReturn(true); CaptionManager captionManager = closedCaptionManagerFactory.createCaptionManager(mockContext); assertThat(captionManager).isInstanceOf(ClosedCaptionManagerMarshmallow.class); }
public CaptionManager createCaptionManager(Context context) { if (androidVersion.isMarshmallowOrHigher()) { return ClosedCaptionManagerMarshmallow.newInstance(context); } else if (androidVersion.isKitKatOrHigher()) { return ClosedCaptionManagerKitKat.newInstance(context); } else { return new DummyClosedCaptionManager(); } }
ClosedCaptionManagerFactory { public CaptionManager createCaptionManager(Context context) { if (androidVersion.isMarshmallowOrHigher()) { return ClosedCaptionManagerMarshmallow.newInstance(context); } else if (androidVersion.isKitKatOrHigher()) { return ClosedCaptionManagerKitKat.newInstance(context); } else { return new DummyClosedCaptionManager(); } } }
ClosedCaptionManagerFactory { public CaptionManager createCaptionManager(Context context) { if (androidVersion.isMarshmallowOrHigher()) { return ClosedCaptionManagerMarshmallow.newInstance(context); } else if (androidVersion.isKitKatOrHigher()) { return ClosedCaptionManagerKitKat.newInstance(context); } else { return new DummyClosedCaptionManager(); } } ClosedCaptionManagerFactory(AndroidVersion androidVersion); }
ClosedCaptionManagerFactory { public CaptionManager createCaptionManager(Context context) { if (androidVersion.isMarshmallowOrHigher()) { return ClosedCaptionManagerMarshmallow.newInstance(context); } else if (androidVersion.isKitKatOrHigher()) { return ClosedCaptionManagerKitKat.newInstance(context); } else { return new DummyClosedCaptionManager(); } } ClosedCaptionManagerFactory(AndroidVersion androidVersion); static ClosedCaptionManagerFactory newInstance(); CaptionManager createCaptionManager(Context context); }
ClosedCaptionManagerFactory { public CaptionManager createCaptionManager(Context context) { if (androidVersion.isMarshmallowOrHigher()) { return ClosedCaptionManagerMarshmallow.newInstance(context); } else if (androidVersion.isKitKatOrHigher()) { return ClosedCaptionManagerKitKat.newInstance(context); } else { return new DummyClosedCaptionManager(); } } ClosedCaptionManagerFactory(AndroidVersion androidVersion); static ClosedCaptionManagerFactory newInstance(); CaptionManager createCaptionManager(Context context);  }