### Question:
ToCalendarEventModelTransformer implements BiFunction<Map<String, Object>, TransformerContext, CalendarEventModel> { @Override @SuppressWarnings("unchecked") public CalendarEventModel apply(Map<String, Object> event, TransformerContext context) { if (!"singleInstance" .equals(event.get("type"))) { return null; } String calendarId = context.getProperty(CALENDAR_ID); String title = (String) event.getOrDefault("subject", ""); String location = TransformerHelper.getOrDefault("location", "displayName", event, ""); String notes = TransformerHelper.getOrDefault("body", "content", event, ""); List<Map<String, Object>> rawAttendees = (List<Map<String, Object>>) event.getOrDefault("attendees", emptyList()); List<CalendarAttendeeModel> attendees = new ArrayList<>(); for (Object rawAttendee : rawAttendees) { CalendarAttendeeModel attendee = context.transform(CalendarAttendeeModel.class, rawAttendee); if (attendee != null) { attendees.add(attendee); } } CalendarEventModel.CalendarEventTime startTime = context.transform(CalendarEventModel.CalendarEventTime.class, event.get("start")); if (startTime == null) { context.problem("Could not parse start time. Skipping event."); return null; } CalendarEventModel.CalendarEventTime endTime = context.transform(CalendarEventModel.CalendarEventTime.class, event.get("end")); if (endTime == null) { context.problem("Could not parse end time. Skipping event."); return null; } return new CalendarEventModel( calendarId, title, notes, attendees, location, startTime, endTime, null); }  @Override @SuppressWarnings("unchecked") CalendarEventModel apply(Map<String, Object> event, TransformerContext context);  }### Answer:
@SuppressWarnings("unchecked") @Test public void testTransform() throws IOException { context.setProperty(CALENDAR_ID, "123"); Map<String, Object> rawEvent = mapper.readValue(SAMPLE_CALENDAR_EVENT, Map.class); CalendarEventModel event = transformer.apply(rawEvent, context); Assert.assertEquals("123", event.getCalendarId()); Assert.assertEquals("Some Place", event.getLocation()); Assert.assertEquals("Test Appointment 1", event.getTitle()); Assert.assertTrue(event.getNotes().length() > 5); Assert.assertEquals(1, event.getAttendees().size()); CalendarAttendeeModel attendee = event.getAttendees().get(0); Assert.assertEquals("Test Test1", attendee.getDisplayName()); Assert.assertEquals("foo@foo.com", attendee.getEmail()); Assert.assertFalse(attendee.getOptional()); Assert.assertEquals(18, event.getStartTime().getDateTime().getHour()); Assert.assertEquals(0, event.getStartTime().getDateTime().getMinute()); Assert.assertEquals(18, event.getEndTime().getDateTime().getHour()); Assert.assertEquals(30, event.getEndTime().getDateTime().getMinute()); }