@Test public final void testHandleContactDeletedEvent() { AggregateIdentifier id = new UUIDAggregateIdentifier(); ContactRemovedEvent event = new ContactRemovedEvent(id); when(mockContactRepository.findOne(id.asString())).thenReturn(mockContactEntry); contactListener.handle(event); verify(mockContactRepository).delete(mockContactEntry); }
@Test public final void testHandlePhoneNumberAddedEvent() { AggregateIdentifier id = new UUIDAggregateIdentifier(); PhoneNumberAddedEvent event = new PhoneNumberAddedEvent(id, mockPhoneNumber); when(mockContactRepository.findOne(id.asString())).thenReturn(mockContactEntry); contactListener.handle(event); List<PhoneNumberEntry> phoneNumbers = new ArrayList<PhoneNumberEntry>(); phoneNumbers.add(mockPhoneNumber); verify(mockContactEntry).setPhoneNumbers(phoneNumbers); verify(mockContactRepository).save(mockContactEntry); }