GoogleAnalytics extends ServiceImpl implements EventTrackingService { GoogleAnalyticsService createService() { if(googleAnalyticsService == null) { RestAdapter restAdapter = new RestAdapter.Builder() .setEndpoint("https: .setConverter(new StringConverter()) .build(); googleAnalyticsService = restAdapter.create(GoogleAnalyticsService.class); } return googleAnalyticsService; } GoogleAnalytics(Context context); @Override void enable(String trackingId); @Override boolean isEnabled(); @Override ServiceType getServiceType(); void logEvent(Context context, String event);  }
@Test public void testCreateService() { GoogleAnalytics googleAnalytics = new GoogleAnalytics(null); assertNull(googleAnalytics.googleAnalyticsService); googleAnalytics.createService(); assertNotNull(googleAnalytics.getServiceType()); GoogleAnalytics.GoogleAnalyticsService service = googleAnalytics.googleAnalyticsService; googleAnalytics.createService(); assertSame(service, googleAnalytics.googleAnalyticsService); }