コード例 #1
0
  @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);
  }
コード例 #2
0
  @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);
  }