@Test public void known_group_three_states_to_update_update_latest_handle_gap_with_changes() { DecryptedGroup currentState = state(0); ServerGroupLogEntry log1 = serverLogEntry(1); DecryptedGroup state3a = DecryptedGroup.newBuilder() .setRevision(3) .setTitle("Group Revision " + 3) .build(); DecryptedGroup state3 = DecryptedGroup.newBuilder() .setRevision(3) .setTitle("Group Revision " + 3) .setAvatar("Lost Avatar Update") .build(); ServerGroupLogEntry log3 = new ServerGroupLogEntry(state3, change(3)); DecryptedGroup state4 = DecryptedGroup.newBuilder() .setRevision(4) .setTitle("Group Revision " + 4) .setAvatar("Lost Avatar Update") .build(); ServerGroupLogEntry log4 = new ServerGroupLogEntry(state4, change(4)); AdvanceGroupStateResult advanceGroupStateResult = GroupStateMapper.partiallyAdvanceGroupState(new GlobalGroupState(currentState, asList(log1, log3, log4)), LATEST); assertThat(advanceGroupStateResult.getProcessedLogEntries(), is(asList(asLocal(log1), new LocalGroupLogEntry(state3a, log3.getChange()), new LocalGroupLogEntry(state3, DecryptedGroupChange.newBuilder() .setRevision(3) .setNewAvatar(DecryptedString.newBuilder().setValue("Lost Avatar Update")) .build()), asLocal(log4)))); assertNewState(new GlobalGroupState(log4.getGroup(), emptyList()), advanceGroupStateResult.getNewGlobalGroupState()); assertEquals(log4.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();   }