### Question:
RecentActivities extends ArrayList<RecentActivity> { public void update(Callbacks... callbacks) { MultiCallbacks multiCallbacks = new MultiCallbacks(callbacks); multiCallbacks.onStart(); apiGateway.makeRequest( new RecentActivityRequest(authenticationGateway.getToken()), new RecentActivityApiResponseCallbacks(multiCallbacks)); } RecentActivities(ApiGateway apiGateway, AuthenticationGateway authenticationGateway); void update(Callbacks... callbacks);  }### Answer:
@Test public void update_shouldMakeRequest() throws Exception { recentActivities.update(new TestCallbacks()); ApiRequest expectedRequest = new RecentActivityRequest("c93f12c"); assertThat(apiGateway.getLatestRequest(), equalTo(expectedRequest)); }
@Test public void update_shouldCreateRecentActivityObjectsFromResponse() throws Exception { recentActivities.update(new TestCallbacks()); apiGateway.simulateResponse(200, TestResponses.RECENT_ACTIVITY); assertThat(recentActivities.size(), equalTo(2)); RecentActivity recentActivity0 = recentActivities.get(0); assertThat(recentActivity0.getDescription(), equalTo("I changed the 'request' for squidward. \"Add 'Buyout'\"")); RecentActivity recentActivity1 = recentActivities.get(1); assertThat(recentActivity1.getDescription(), equalTo("Spongebob Square edited \"Application tracks listing clicks\"")); }
@Test public void update_shouldFireCallbacks_success() throws Exception { TestCallbacks callbacks = new TestCallbacks(); recentActivities.update(callbacks); assertThat(callbacks.startWasCalled, equalTo(true)); apiGateway.simulateResponse(200, TestResponses.RECENT_ACTIVITY); assertThat(callbacks.successWasCalled, equalTo(true)); assertThat(callbacks.failureWasCalled, equalTo(false)); assertThat(callbacks.completeWasCalled, equalTo(true)); }
@Test public void update_shouldFireCallbacks_failure() throws Exception { TestCallbacks callbacks = new TestCallbacks(); recentActivities.update(callbacks); assertThat(callbacks.startWasCalled, equalTo(true)); apiGateway.simulateResponse(500, "ERROR"); assertThat(callbacks.successWasCalled, equalTo(false)); assertThat(callbacks.failureWasCalled, equalTo(true)); assertThat(callbacks.completeWasCalled, equalTo(true)); }
@Test public void update_shouldClearExitingItems() throws Exception { recentActivities.update(new TestCallbacks()); apiGateway.simulateResponse(200, TestResponses.RECENT_ACTIVITY); assertThat(recentActivities.size(), equalTo(2)); recentActivities.update(new TestCallbacks()); apiGateway.simulateResponse(200, TestResponses.RECENT_ACTIVITY); assertThat(recentActivities.size(), equalTo(2)); }