Mixpanel extends ServiceImpl implements EventTrackingService { protected String eventObjToBase64(MixpanelEvent event) { Gson gson = new Gson(); String json = gson.toJson(event); return toBase64(json.getBytes()); } Mixpanel(Context context); @Override void enable(String projectToken); @Override boolean isEnabled(); @Override ServiceType getServiceType(); @Override void logEvent(Context context, String eventName);  }
@Test public void testEventObjToBase64() { Mixpanel mixpanel = new Mixpanel(null){ @Override protected String toBase64(byte[] data) { return new String(data); } }; Mixpanel.MixpanelEvent mixpanelEvent = mixpanel.new MixpanelEvent(); mixpanelEvent.event = "test_event"; Map<String, String> properties = new HashMap<>(); properties.put("unit", "testing"); properties.put("testtest", "test2"); mixpanelEvent.properties = properties; String eventObjToBase64 = mixpanel.eventObjToBase64(mixpanelEvent); assertEquals("{\"event\":\"test_event\",\"properties\":{\"unit\":\"testing\",\"testtest\":\"test2\"}}", eventObjToBase64); }