BusinessFlowManagerValidator { @PostConstruct public void init() { trxBFMValidator.forEach(validator->validator.validate(trxBoundaries)); trxBoundaries.stream().filter(x->!x.isValidated()).forEach(x->{ throw new BusinessFlowManagerValidatorException("the Business Transaction with class "+x.getClazz().getName()+" not attached "+ " to any Global or Local Business transaction " ); }); }  @PostConstruct void init(); void setTrxBFMValidator(List<TransactionBFMValidator> trxBFMValidator);  }
@Test public void testInit(){ List<GlobalTransactionWorker<? extends BaseGlobalTransactionEvent, ? extends BaseGlobalTransactionEvent>> gtxWorkers = new ArrayList<>(); gtxWorkers.add(new OrderPizzaStateWorkerDummy()); globalTrxBFMValidatorUnderTest.setGtxWorkers(gtxWorkers); List<LocalTransactionWorker<? extends BaseTransactionEvent, ? extends BaseTransactionEvent, ? extends ErrorOccured>> ltxWorkers = new ArrayList<>(); ltxWorkers.add(new ChefCookingServiceWorkerDummy()); localTrxBFMValidatorUnderTest.setLtxWorkers(ltxWorkers); List<TransactionBFMValidator> trxBFMValidator=new ArrayList<>(); trxBFMValidator.add(globalTrxBFMValidatorUnderTest); trxBFMValidator.add(localTrxBFMValidatorUnderTest); businessFlowManagerValidatorUnderTest.setTrxBFMValidator(trxBFMValidator); ; assertThatExceptionOfType(BusinessFlowManagerValidatorException.class).isThrownBy(() -> { businessFlowManagerValidatorUnderTest.init(); }).withMessageContaining("the Business Transaction with class"); }