@Test public void identify() throws JSONException {
// 1. Prepare our mocks
MixpanelAPI.People people = Mockito.mock(MixpanelAPI.People.class);
MixpanelAdapter adapter = mockAdapter(people);
Analytics analytics = createAnalyticsWithMock(adapter);
// 2. Exercise the test
analytics.identify("elvis", new Traits()
.putFirstName("Elvis")
.putLastName("Presley")
.putEmail("
[email protected]"));
JSONObject expected = new JSONObject();
expected.put("userId", "elvis");
expected.put("$email", "
[email protected]");
expected.put("$first_name", "Elvis");
expected.put("$last_name", "Presley");
// 3. Verify that we saw what we expected
Mockito.verify(people).identify("elvis");
Mockito.verify(people).set(eq(expected));
}