### Question:
DocumentBuilderEvents { public List<DocumentBuilderEvent> getEvents() { return events; } DocumentBuilderEvents(List<DocumentBuilderEvent> events); List<DocumentBuilderEvent> getEvents(); void applyTo(DocumentBuilder builder); @Override String toString();  }### Answer:
@Test public void createsWithProvidedEvents() { BeginDocumentEvent event = new BeginDocumentEvent(); List<DocumentBuilderEvent> allEvents = Lists.<DocumentBuilderEvent> newArrayList(event); DocumentBuilderEvents events = new DocumentBuilderEvents(allEvents); assertEquals(allEvents, events.getEvents()); }
@Test public void getEventsImmutable() { DocumentBuilderEvents events = new DocumentBuilderEvents(Lists.<DocumentBuilderEvent> newArrayList()); assertThrows(UnsupportedOperationException.class, () -> events.getEvents().clear()); }
@Test public void getEventsImmutable() { DocumentBuilderEvents events = new DocumentBuilderEvents(Lists.<DocumentBuilderEvent> newArrayList()); thrown.expect(UnsupportedOperationException.class); events.getEvents().clear(); }