@Test void testSnapshotCreatedNoTransaction() { SpringAggregateSnapshotter snapshotter = testSubject.getObject(); snapshotter.scheduleSnapshot(StubAggregate.class, aggregateIdentifier); verify(mockEventStore).storeSnapshot(eventSequence(1L)); verify(executor).execute(any()); }
@Override public SpringAggregateSnapshotter getObject() { if (transactionManager == null) { Map<String, PlatformTransactionManager> candidates = applicationContext.getBeansOfType(PlatformTransactionManager.class); if (candidates.size() == 1) { this.transactionManager = candidates.values().iterator().next(); } } if (eventStore == null) { eventStore = applicationContext.getBean(EventStore.class); } if (repositoryProvider == null) { repositoryProvider = applicationContext.getBean(Configuration.class)::repository; } if (parameterResolverFactory == null) { parameterResolverFactory = MultiParameterResolverFactory .ordered(ClasspathParameterResolverFactory.forClass(getObjectType()), new SpringBeanParameterResolverFactory(applicationContext)); } if (handlerDefinition == null) { HandlerDefinition definitions = new SpringHandlerDefinitionBean(applicationContext).getObject(); HandlerEnhancerDefinition enhancers = new SpringHandlerEnhancerDefinitionBean(applicationContext) .getObject(); handlerDefinition = MultiHandlerDefinition.ordered(enhancers, definitions); } TransactionManager txManager = transactionManager == null ? NoTransactionManager.INSTANCE : new SpringTransactionManager(transactionManager, transactionDefinition); SpringAggregateSnapshotter snapshotter = SpringAggregateSnapshotter.builder() .eventStore(eventStore) .executor(executor) .transactionManager(txManager) .repositoryProvider(repositoryProvider) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .build(); snapshotter.setApplicationContext(applicationContext); return snapshotter; }
SpringAggregateSnapshotterFactoryBean implements FactoryBean<SpringAggregateSnapshotter>, ApplicationContextAware { @Override public SpringAggregateSnapshotter getObject() { if (transactionManager == null) { Map<String, PlatformTransactionManager> candidates = applicationContext.getBeansOfType(PlatformTransactionManager.class); if (candidates.size() == 1) { this.transactionManager = candidates.values().iterator().next(); } } if (eventStore == null) { eventStore = applicationContext.getBean(EventStore.class); } if (repositoryProvider == null) { repositoryProvider = applicationContext.getBean(Configuration.class)::repository; } if (parameterResolverFactory == null) { parameterResolverFactory = MultiParameterResolverFactory .ordered(ClasspathParameterResolverFactory.forClass(getObjectType()), new SpringBeanParameterResolverFactory(applicationContext)); } if (handlerDefinition == null) { HandlerDefinition definitions = new SpringHandlerDefinitionBean(applicationContext).getObject(); HandlerEnhancerDefinition enhancers = new SpringHandlerEnhancerDefinitionBean(applicationContext) .getObject(); handlerDefinition = MultiHandlerDefinition.ordered(enhancers, definitions); } TransactionManager txManager = transactionManager == null ? NoTransactionManager.INSTANCE : new SpringTransactionManager(transactionManager, transactionDefinition); SpringAggregateSnapshotter snapshotter = SpringAggregateSnapshotter.builder() .eventStore(eventStore) .executor(executor) .transactionManager(txManager) .repositoryProvider(repositoryProvider) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .build(); snapshotter.setApplicationContext(applicationContext); return snapshotter; } }
SpringAggregateSnapshotterFactoryBean implements FactoryBean<SpringAggregateSnapshotter>, ApplicationContextAware { @Override public SpringAggregateSnapshotter getObject() { if (transactionManager == null) { Map<String, PlatformTransactionManager> candidates = applicationContext.getBeansOfType(PlatformTransactionManager.class); if (candidates.size() == 1) { this.transactionManager = candidates.values().iterator().next(); } } if (eventStore == null) { eventStore = applicationContext.getBean(EventStore.class); } if (repositoryProvider == null) { repositoryProvider = applicationContext.getBean(Configuration.class)::repository; } if (parameterResolverFactory == null) { parameterResolverFactory = MultiParameterResolverFactory .ordered(ClasspathParameterResolverFactory.forClass(getObjectType()), new SpringBeanParameterResolverFactory(applicationContext)); } if (handlerDefinition == null) { HandlerDefinition definitions = new SpringHandlerDefinitionBean(applicationContext).getObject(); HandlerEnhancerDefinition enhancers = new SpringHandlerEnhancerDefinitionBean(applicationContext) .getObject(); handlerDefinition = MultiHandlerDefinition.ordered(enhancers, definitions); } TransactionManager txManager = transactionManager == null ? NoTransactionManager.INSTANCE : new SpringTransactionManager(transactionManager, transactionDefinition); SpringAggregateSnapshotter snapshotter = SpringAggregateSnapshotter.builder() .eventStore(eventStore) .executor(executor) .transactionManager(txManager) .repositoryProvider(repositoryProvider) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .build(); snapshotter.setApplicationContext(applicationContext); return snapshotter; }  }
SpringAggregateSnapshotterFactoryBean implements FactoryBean<SpringAggregateSnapshotter>, ApplicationContextAware { @Override public SpringAggregateSnapshotter getObject() { if (transactionManager == null) { Map<String, PlatformTransactionManager> candidates = applicationContext.getBeansOfType(PlatformTransactionManager.class); if (candidates.size() == 1) { this.transactionManager = candidates.values().iterator().next(); } } if (eventStore == null) { eventStore = applicationContext.getBean(EventStore.class); } if (repositoryProvider == null) { repositoryProvider = applicationContext.getBean(Configuration.class)::repository; } if (parameterResolverFactory == null) { parameterResolverFactory = MultiParameterResolverFactory .ordered(ClasspathParameterResolverFactory.forClass(getObjectType()), new SpringBeanParameterResolverFactory(applicationContext)); } if (handlerDefinition == null) { HandlerDefinition definitions = new SpringHandlerDefinitionBean(applicationContext).getObject(); HandlerEnhancerDefinition enhancers = new SpringHandlerEnhancerDefinitionBean(applicationContext) .getObject(); handlerDefinition = MultiHandlerDefinition.ordered(enhancers, definitions); } TransactionManager txManager = transactionManager == null ? NoTransactionManager.INSTANCE : new SpringTransactionManager(transactionManager, transactionDefinition); SpringAggregateSnapshotter snapshotter = SpringAggregateSnapshotter.builder() .eventStore(eventStore) .executor(executor) .transactionManager(txManager) .repositoryProvider(repositoryProvider) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .build(); snapshotter.setApplicationContext(applicationContext); return snapshotter; }  @Override SpringAggregateSnapshotter getObject(); @Override Class<?> getObjectType(); @Override boolean isSingleton(); void setTransactionManager(PlatformTransactionManager transactionManager); void setTransactionDefinition(TransactionDefinition transactionDefinition); void setEventStore(EventStore eventStore); void setRepositoryProvider(RepositoryProvider repositoryProvider); void setHandlerDefinition(HandlerDefinition handlerDefinition); @Override void setApplicationContext(ApplicationContext applicationContext); void setExecutor(Executor executor); }
SpringAggregateSnapshotterFactoryBean implements FactoryBean<SpringAggregateSnapshotter>, ApplicationContextAware { @Override public SpringAggregateSnapshotter getObject() { if (transactionManager == null) { Map<String, PlatformTransactionManager> candidates = applicationContext.getBeansOfType(PlatformTransactionManager.class); if (candidates.size() == 1) { this.transactionManager = candidates.values().iterator().next(); } } if (eventStore == null) { eventStore = applicationContext.getBean(EventStore.class); } if (repositoryProvider == null) { repositoryProvider = applicationContext.getBean(Configuration.class)::repository; } if (parameterResolverFactory == null) { parameterResolverFactory = MultiParameterResolverFactory .ordered(ClasspathParameterResolverFactory.forClass(getObjectType()), new SpringBeanParameterResolverFactory(applicationContext)); } if (handlerDefinition == null) { HandlerDefinition definitions = new SpringHandlerDefinitionBean(applicationContext).getObject(); HandlerEnhancerDefinition enhancers = new SpringHandlerEnhancerDefinitionBean(applicationContext) .getObject(); handlerDefinition = MultiHandlerDefinition.ordered(enhancers, definitions); } TransactionManager txManager = transactionManager == null ? NoTransactionManager.INSTANCE : new SpringTransactionManager(transactionManager, transactionDefinition); SpringAggregateSnapshotter snapshotter = SpringAggregateSnapshotter.builder() .eventStore(eventStore) .executor(executor) .transactionManager(txManager) .repositoryProvider(repositoryProvider) .parameterResolverFactory(parameterResolverFactory) .handlerDefinition(handlerDefinition) .build(); snapshotter.setApplicationContext(applicationContext); return snapshotter; }  @Override SpringAggregateSnapshotter getObject(); @Override Class<?> getObjectType(); @Override boolean isSingleton(); void setTransactionManager(PlatformTransactionManager transactionManager); void setTransactionDefinition(TransactionDefinition transactionDefinition); void setEventStore(EventStore eventStore); void setRepositoryProvider(RepositoryProvider repositoryProvider); void setHandlerDefinition(HandlerDefinition handlerDefinition); @Override void setApplicationContext(ApplicationContext applicationContext); void setExecutor(Executor executor);  }