@Override public void appendAll(List<Event> events) { if (events.isEmpty()) { return; } AggregateId aggregateId = getAggregateId(events); if (!store.containsKey(aggregateId)) { appendToEmptyHistory(aggregateId, events); } else { appendToExistingHistory(aggregateId, events); } }
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { return new EventSourcingDLPConfigurationStore(new InMemoryEventStore()); } }
private void appendToExistingHistory(AggregateId aggregateId, List<? extends Event> events) { History currentHistory = store.get(aggregateId); List<Event> updatedEvents = updatedEvents(currentHistory, events); History updatedHistory = History.of(updatedEvents); boolean isReplaced = store.replace(aggregateId, currentHistory, updatedHistory); if (!isReplaced) { throw new EventStoreFailedException("Concurrent update to the EventStore detected"); } }
@BeforeEach void setup() throws Exception { DNSService dnsService = mock(DNSService.class); Mockito.when(dnsService.getHostName(any())).thenReturn("localhost"); Mockito.when(dnsService.getLocalHost()).thenReturn(InetAddress.getByName("localhost")); MemoryDomainList domainList = new MemoryDomainList(dnsService); domainList.setAutoDetectIP(false); domainList.setAutoDetect(false); domainList.addDomain(SENDER_DOMAIN); domainList.addDomain(SENDER_DOMAIN_2); dlpStore = new EventSourcingDLPConfigurationStore(new InMemoryEventStore()); createServer(dlpStore, domainList); }
@Override public void beforeEach(ExtensionContext extensionContext) throws Exception { FilteringManagement filteringManagement = new EventSourcingFilteringManagement(new InMemoryEventStore()); MemoryUsersRepository usersRepository = MemoryUsersRepository.withoutVirtualHosting(); InMemoryMailboxManager mailboxManager = new InMemoryIntegrationResources().createMailboxManager(new SimpleGroupMembershipResolver()); ActionApplier.Factory actionApplierFactory = ActionApplier.factory(mailboxManager, new InMemoryId.Factory()); JMAPFiltering jmapFiltering = new JMAPFiltering(filteringManagement, usersRepository, actionApplierFactory); testSystem = new JMAPFilteringTestSystem(jmapFiltering, filteringManagement, mailboxManager); }