@Test public void testMessagesAreSharedAtStartup() throws Exception { Transaction txn = new Transaction(null, true); Transaction txn1 = new Transaction(null, true); Transaction txn2 = new Transaction(null, true); Transaction txn3 = new Transaction(null, false); Transaction txn4 = new Transaction(null, false); context.checking(new Expectations() {{ oneOf(db).startTransaction(true); will(returnValue(txn)); oneOf(db).getMessagesToValidate(txn); will(returnValue(Collections.emptyList())); oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); oneOf(db).startTransaction(true); will(returnValue(txn1)); oneOf(db).getPendingMessages(txn1); will(returnValue(Collections.emptyList())); oneOf(db).commitTransaction(txn1); oneOf(db).endTransaction(txn1); oneOf(db).startTransaction(true); will(returnValue(txn2)); oneOf(db).getMessagesToShare(txn2); will(returnValue(Collections.singletonList(messageId))); oneOf(db).commitTransaction(txn2); oneOf(db).endTransaction(txn2); oneOf(db).startTransaction(false); will(returnValue(txn3)); oneOf(db).setMessageShared(txn3, messageId); oneOf(db).getMessageDependencies(txn3, messageId); will(returnValue(Collections.singletonMap(messageId2, DELIVERED))); oneOf(db).commitTransaction(txn3); oneOf(db).endTransaction(txn3); oneOf(db).startTransaction(false); will(returnValue(txn4)); oneOf(db).setMessageShared(txn4, messageId2); oneOf(db).getMessageDependencies(txn4, messageId2); will(returnValue(Collections.emptyMap())); oneOf(db).commitTransaction(txn4); oneOf(db).endTransaction(txn4); }}); vm.startService(); }
@Override public void startService() { if (used.getAndSet(true)) throw new IllegalStateException(); validateOutstandingMessagesAsync(); deliverOutstandingMessagesAsync(); shareOutstandingMessagesAsync(); }
ValidationManagerImpl implements ValidationManager, Service,
		EventListener { @Override public void startService() { if (used.getAndSet(true)) throw new IllegalStateException(); validateOutstandingMessagesAsync(); deliverOutstandingMessagesAsync(); shareOutstandingMessagesAsync(); } }
ValidationManagerImpl implements ValidationManager, Service,
		EventListener { @Override public void startService() { if (used.getAndSet(true)) throw new IllegalStateException(); validateOutstandingMessagesAsync(); deliverOutstandingMessagesAsync(); shareOutstandingMessagesAsync(); } @Inject  ValidationManagerImpl(DatabaseComponent db,
			@DatabaseExecutor Executor dbExecutor,
			@ValidationExecutor Executor validationExecutor,
			MessageFactory messageFactory); }
ValidationManagerImpl implements ValidationManager, Service,
		EventListener { @Override public void startService() { if (used.getAndSet(true)) throw new IllegalStateException(); validateOutstandingMessagesAsync(); deliverOutstandingMessagesAsync(); shareOutstandingMessagesAsync(); } @Inject  ValidationManagerImpl(DatabaseComponent db,
			@DatabaseExecutor Executor dbExecutor,
			@ValidationExecutor Executor validationExecutor,
			MessageFactory messageFactory); @Override void startService(); @Override void stopService(); @Override void registerMessageValidator(ClientId c, int majorVersion,
			MessageValidator v); @Override void registerIncomingMessageHook(ClientId c, int majorVersion,
			IncomingMessageHook hook); @Override void eventOccurred(Event e); }
ValidationManagerImpl implements ValidationManager, Service,
		EventListener { @Override public void startService() { if (used.getAndSet(true)) throw new IllegalStateException(); validateOutstandingMessagesAsync(); deliverOutstandingMessagesAsync(); shareOutstandingMessagesAsync(); } @Inject  ValidationManagerImpl(DatabaseComponent db,
			@DatabaseExecutor Executor dbExecutor,
			@ValidationExecutor Executor validationExecutor,
			MessageFactory messageFactory); @Override void startService(); @Override void stopService(); @Override void registerMessageValidator(ClientId c, int majorVersion,
			MessageValidator v); @Override void registerIncomingMessageHook(ClientId c, int majorVersion,
			IncomingMessageHook hook); @Override void eventOccurred(Event e);  }