### Question:
AggregateRootHistory implements Serializable { public void add(final UnitOfWork transaction) { checkNotNull(transaction); unitsOfWork.add(transaction); } AggregateRootHistory(); List<Event> getAllEvents(); List<Event> getEventsAfterUntil(long afterVersion, long untilVersion); List<Event> getEventsUntil(long version); Long getLastVersion(); void add(final UnitOfWork transaction); UnitOfWork getLastUnitOfWork(); List<UnitOfWork> getPendingOfPersistence(); void markAsPersisted(UnitOfWork uow);  }### Answer:
@Test(expected = NullPointerException.class) public void nullEvent() { UUID id = UUID.randomUUID(); AggregateRootHistory transactions = new AggregateRootHistory(); Command command = new CommandJustForTest(UUID.randomUUID(), id, 1L); Event event1 = (Event) null; transactions.add(UnitOfWork.create(UUID.randomUUID(), command, Arrays.asList(event1))); }
@Test(expected = NullPointerException.class) public void nullCommand() { AggregateRootHistory transactions = new AggregateRootHistory(); transactions.add(UnitOfWork.create(UUID.randomUUID(), null, Arrays.asList(Mockito.mock(Event.class)))); }
@Test(expected = NullPointerException.class) public void nullEventsList() { AggregateRootHistory transactions = new AggregateRootHistory(); transactions.add(UnitOfWork.create(UUID.randomUUID(), Mockito.mock(Command.class), null)); }
@Test(expected = IllegalArgumentException.class) public void invalidVersion() { AggregateRootHistory transactions = new AggregateRootHistory(); Command command = Mockito.mock(Command.class); when(command.getTargetVersion()).thenReturn(-1L); transactions.add(UnitOfWork.create(UUID.randomUUID(), command, Arrays.asList(Mockito.mock(Event.class)))); }