### Question:
BodyBuilder extends UpdateBuilder { public String build() { String body = ""; if(validNotificationsResponse() && validInboxResponse() && notificationResponse.count > 0 && inboxResponse.count > 0) { Date notificationDate = notificationResponse.getNotificationDate(); Date messageDate = inboxResponse.time; body = notificationDate.getTime() > messageDate.getTime() ? notificationResponse.getNotificationText() : inboxResponse.getText(); } else if(validNotificationsResponse() && notificationResponse.count > 0) { body = notificationResponse.getNotificationText(); } else if(validInboxResponse()) { body = inboxResponse.getText(); } return body; } BodyBuilder(NotificationsResponse notificationsResponse, InboxResponse inboxResponse); String build();  }### Answer:
@Test public void should_build_chris_message() { String body = "Chris Akins: Have you been flying solo for like 4 days? What in the world have you done with yourself? That sounds pretty sweet."; NotificationsResponse notificationsResponse = createNotificationResponseWithNotification(1397703661); InboxResponse inboxResponse = createInboxWithMessage(1397703662); BodyBuilder builder = new BodyBuilder(notificationsResponse, inboxResponse); assertEquals(body, builder.build()); builder = new BodyBuilder(createInvalidNotificationResponse(), inboxResponse); assertEquals(body, builder.build()); builder = new BodyBuilder(null, inboxResponse); assertEquals(body, builder.build()); }
@Test public void should_build_blank() { String body = ""; BodyBuilder bodyBuilder = new BodyBuilder(createInvalidNotificationResponse(), createInvalidInboxResponse()); assertEquals(body, bodyBuilder.build()); }
@Test public void should_build_katie_commented() { String body = "Katie commented on Steven Lemire's post"; NotificationsResponse notificationsResponse = createNotificationResponseWithNotification(1397703662); InboxResponse inboxResponse = createInboxResponse(0); BodyBuilder builder = new BodyBuilder(notificationsResponse, inboxResponse); assertEquals(body, builder.build()); builder = new BodyBuilder(notificationsResponse, createInvalidInboxResponse()); assertEquals(body, builder.build()); builder = new BodyBuilder(notificationsResponse, null); assertEquals(body, builder.build()); inboxResponse = createInboxWithMessage(1397703661); builder = new BodyBuilder(notificationsResponse, inboxResponse); assertEquals(body, builder.build()); }