@Test public void testOnJoinActionFromInvited() throws Exception { JoinMessage properJoinMessage = new JoinMessage(messageId, contactGroupId, privateGroupId, messageTimestamp, lastRemoteMessageId); long timestamp = 0L; GroupMessage joinGroupMessage = new GroupMessage(message, null, localAuthor); BdfDictionary meta = new BdfDictionary(); expectMarkMessageAvailableToAnswer(lastRemoteMessageId, false); context.checking(new Expectations() {{ oneOf(messageEncoder).setInvitationAccepted(meta, true); oneOf(clientHelper) .mergeMessageMetadata(txn, lastRemoteMessageId, meta); }}); expectSendJoinMessage(properJoinMessage, true); context.checking(new Expectations() {{ oneOf(messageTracker).trackOutgoingMessage(txn, message); oneOf(messageParser).getInviteMessage(txn, lastRemoteMessageId); will(returnValue(inviteMessage)); oneOf(privateGroupFactory) .createPrivateGroup(inviteMessage.getGroupName(), inviteMessage.getCreator(), inviteMessage.getSalt()); will(returnValue(privateGroup)); oneOf(clock).currentTimeMillis(); will((returnValue(timestamp))); oneOf(identityManager).getLocalAuthor(txn); will(returnValue(localAuthor)); oneOf(groupMessageFactory).createJoinMessage(privateGroupId, inviteMessage.getTimestamp() + 1, localAuthor, inviteMessage.getTimestamp(), inviteMessage.getSignature()); will(returnValue(joinGroupMessage)); oneOf(privateGroupManager) .addPrivateGroup(txn, privateGroup, joinGroupMessage, false); }}); expectSetPrivateGroupVisibility(VISIBLE); InviteeSession session = getDefaultSession(INVITED); InviteeSession newSession = engine.onJoinAction(txn, session); assertEquals(ACCEPTED, newSession.getState()); assertSessionRecordedSentMessage(newSession); assertSessionConstantsUnchanged(session, newSession); }
@Override public InviteeSession onJoinAction(Transaction txn, InviteeSession s) throws DbException { switch (s.getState()) { case START: case ACCEPTED: case JOINED: case LEFT: case DISSOLVED: case ERROR: throw new ProtocolStateException(); case INVITED: return onLocalAccept(txn, s); default: throw new AssertionError(); } }
InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> { @Override public InviteeSession onJoinAction(Transaction txn, InviteeSession s) throws DbException { switch (s.getState()) { case START: case ACCEPTED: case JOINED: case LEFT: case DISSOLVED: case ERROR: throw new ProtocolStateException(); case INVITED: return onLocalAccept(txn, s); default: throw new AssertionError(); } } }
InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> { @Override public InviteeSession onJoinAction(Transaction txn, InviteeSession s) throws DbException { switch (s.getState()) { case START: case ACCEPTED: case JOINED: case LEFT: case DISSOLVED: case ERROR: throw new ProtocolStateException(); case INVITED: return onLocalAccept(txn, s); default: throw new AssertionError(); } } InviteeProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); }
InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> { @Override public InviteeSession onJoinAction(Transaction txn, InviteeSession s) throws DbException { switch (s.getState()) { case START: case ACCEPTED: case JOINED: case LEFT: case DISSOLVED: case ERROR: throw new ProtocolStateException(); case INVITED: return onLocalAccept(txn, s); default: throw new AssertionError(); } } InviteeProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); @Override InviteeSession onInviteAction(Transaction txn, InviteeSession s,
			@Nullable String message, long timestamp, byte[] signature); @Override InviteeSession onJoinAction(Transaction txn, InviteeSession s); @Override InviteeSession onLeaveAction(Transaction txn, InviteeSession s); @Override InviteeSession onMemberAddedAction(Transaction txn, InviteeSession s); @Override InviteeSession onInviteMessage(Transaction txn, InviteeSession s,
			InviteMessage m); @Override InviteeSession onJoinMessage(Transaction txn, InviteeSession s,
			JoinMessage m); @Override InviteeSession onLeaveMessage(Transaction txn, InviteeSession s,
			LeaveMessage m); @Override InviteeSession onAbortMessage(Transaction txn, InviteeSession s,
			AbortMessage m); }
InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> { @Override public InviteeSession onJoinAction(Transaction txn, InviteeSession s) throws DbException { switch (s.getState()) { case START: case ACCEPTED: case JOINED: case LEFT: case DISSOLVED: case ERROR: throw new ProtocolStateException(); case INVITED: return onLocalAccept(txn, s); default: throw new AssertionError(); } } InviteeProtocolEngine(DatabaseComponent db, ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			PrivateGroupManager privateGroupManager,
			PrivateGroupFactory privateGroupFactory,
			GroupMessageFactory groupMessageFactory,
			IdentityManager identityManager, MessageParser messageParser,
			MessageEncoder messageEncoder, MessageTracker messageTracker,
			Clock clock); @Override InviteeSession onInviteAction(Transaction txn, InviteeSession s,
			@Nullable String message, long timestamp, byte[] signature); @Override InviteeSession onJoinAction(Transaction txn, InviteeSession s); @Override InviteeSession onLeaveAction(Transaction txn, InviteeSession s); @Override InviteeSession onMemberAddedAction(Transaction txn, InviteeSession s); @Override InviteeSession onInviteMessage(Transaction txn, InviteeSession s,
			InviteMessage m); @Override InviteeSession onJoinMessage(Transaction txn, InviteeSession s,
			JoinMessage m); @Override InviteeSession onLeaveMessage(Transaction txn, InviteeSession s,
			LeaveMessage m); @Override InviteeSession onAbortMessage(Transaction txn, InviteeSession s,
			AbortMessage m);  }