Flurry extends ServiceImpl implements EventTrackingService { public boolean checkForJar() { try { checkForClass("com.flurry.android.FlurryAgent"); return true; } catch (ClassNotFoundException ex) { utils.logIssue("\n\n\nFoam: You must add the FlurryAnalytics-x.x.x.jar file " + "to your application to enable flurry analytics. This can be found at " + "https: "-> Manage -> 'Download SDK'.\n\n\n", ex); return false; } } Flurry(Context context); @Override void enable(String applicationKey); @Override boolean isEnabled(); @Override ServiceType getServiceType(); @Override void logEvent(Context context, String event); boolean checkForJar();  }
@Test public void testCheckForJarSuccess() throws ClassNotFoundException { PowerMockito.mockStatic(Class.class); Flurry flurry = new Flurry(null); assertTrue(flurry.checkForJar()); }
@Test public void testCheckForJarFailure() throws ClassNotFoundException { final ClassNotFoundException exceptionToThrow = new ClassNotFoundException("Unit Testing"); Flurry flurry = new Flurry(null){ @Override void checkForClass(String clazz) throws ClassNotFoundException { throw exceptionToThrow; } }; Utils mockUtils = UnitTestUtils.mockUtils(); flurry.utils = mockUtils; assertFalse(flurry.checkForJar()); verify(mockUtils).logIssue(contains("You must add the FlurryAnalytics-x.x.x.jar file"), eq(exceptionToThrow)); }