@Test public void updates_with_a_server_mismatch_inserts_additional_update() { DecryptedGroup currentState = state(6); ServerGroupLogEntry log7 = serverLogEntry(7); DecryptedMember newMember = DecryptedMember.newBuilder() .setUuid(UuidUtil.toByteString(UUID.randomUUID())) .build(); DecryptedGroup state7b = DecryptedGroup.newBuilder() .setRevision(8) .setTitle("Group Revision " + 8) .build(); DecryptedGroup state8 = DecryptedGroup.newBuilder() .setRevision(8) .setTitle("Group Revision " + 8) .addMembers(newMember) .build(); ServerGroupLogEntry log8 = new ServerGroupLogEntry(state8, change(8) ); ServerGroupLogEntry log9 = new ServerGroupLogEntry(DecryptedGroup.newBuilder() .setRevision(9) .addMembers(newMember) .setTitle("Group Revision " + 9) .build(), change(9) ); AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log7, log8, log9)), LATEST); assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log7), new LocalGroupLogEntry(state7b, log8.getChange()), new LocalGroupLogEntry(state8, DecryptedGroupChange.newBuilder() .setRevision(8) .addNewMembers(newMember) .build()), asLocal(log9)))); assertNewState(new GlobalGroupState(log9.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState()); assertEquals(log9.getGroup(), advanceGroupStateResult.getNewGlobalGroupState().getLocalState()); }
static @NonNull AdvanceGroupStateResult partiallyAdvanceGroupState(@NonNull GlobalGroupState inputState, int maximumRevisionToApply) { AdvanceGroupStateResult groupStateResult = processChanges(inputState, maximumRevisionToApply); return cleanDuplicatedChanges(groupStateResult, inputState.getLocalState()); }
GroupStateMapper { static @NonNull AdvanceGroupStateResult partiallyAdvanceGroupState(@NonNull GlobalGroupState inputState, int maximumRevisionToApply) { AdvanceGroupStateResult groupStateResult = processChanges(inputState, maximumRevisionToApply); return cleanDuplicatedChanges(groupStateResult, inputState.getLocalState()); } }
GroupStateMapper { static @NonNull AdvanceGroupStateResult partiallyAdvanceGroupState(@NonNull GlobalGroupState inputState, int maximumRevisionToApply) { AdvanceGroupStateResult groupStateResult = processChanges(inputState, maximumRevisionToApply); return cleanDuplicatedChanges(groupStateResult, inputState.getLocalState()); } private  GroupStateMapper(); }
GroupStateMapper { static @NonNull AdvanceGroupStateResult partiallyAdvanceGroupState(@NonNull GlobalGroupState inputState, int maximumRevisionToApply) { AdvanceGroupStateResult groupStateResult = processChanges(inputState, maximumRevisionToApply); return cleanDuplicatedChanges(groupStateResult, inputState.getLocalState()); } private  GroupStateMapper();  }
GroupStateMapper { static @NonNull AdvanceGroupStateResult partiallyAdvanceGroupState(@NonNull GlobalGroupState inputState, int maximumRevisionToApply) { AdvanceGroupStateResult groupStateResult = processChanges(inputState, maximumRevisionToApply); return cleanDuplicatedChanges(groupStateResult, inputState.getLocalState()); } private  GroupStateMapper();   }