@Test void internalCalculateEnvironmentUserSyncStateLastSyncCompletedSuccessInSync() { UserSyncStatus userSyncStatus = new UserSyncStatus(); Operation lastSync = new Operation(); lastSync.setOperationId(UUID.randomUUID().toString()); lastSync.setStatus(OperationState.COMPLETED); lastSync.setSuccessList(List.of(new SuccessDetails(ENVIRONMENT_CRN))); userSyncStatus.setLastStartedFullSync(lastSync); UmsEventGenerationIds current = new UmsEventGenerationIds(); when(umsEventGenerationIdsProvider.getEventGenerationIds(eq(ACCOUNT_ID), any())).thenReturn(current); when(eventGenerationIdsChecker.isInSync(userSyncStatus, current)).thenReturn(true); EnvironmentUserSyncState result = underTest.internalCalculateEnvironmentUserSyncState(ACCOUNT_ID, ENVIRONMENT_CRN, userSyncStatus); assertEquals(UserSyncState.UP_TO_DATE, result.getState()); assertEquals(lastSync.getOperationId(), result.getLastUserSyncOperationId()); }
@VisibleForTesting EnvironmentUserSyncState internalCalculateEnvironmentUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) { EnvironmentUserSyncState environmentUserSyncState = new EnvironmentUserSyncState(); if (null == userSyncStatus || null == userSyncStatus.getLastStartedFullSync()) { environmentUserSyncState.setState(UserSyncState.STALE); } else { environmentUserSyncState.setLastUserSyncOperationId(userSyncStatus.getLastStartedFullSync().getOperationId()); environmentUserSyncState.setState(calculateUserSyncState(accountId, envCrnString, userSyncStatus)); } return environmentUserSyncState; }
EnvironmentUserSyncStateCalculator { @VisibleForTesting EnvironmentUserSyncState internalCalculateEnvironmentUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) { EnvironmentUserSyncState environmentUserSyncState = new EnvironmentUserSyncState(); if (null == userSyncStatus || null == userSyncStatus.getLastStartedFullSync()) { environmentUserSyncState.setState(UserSyncState.STALE); } else { environmentUserSyncState.setLastUserSyncOperationId(userSyncStatus.getLastStartedFullSync().getOperationId()); environmentUserSyncState.setState(calculateUserSyncState(accountId, envCrnString, userSyncStatus)); } return environmentUserSyncState; } }
EnvironmentUserSyncStateCalculator { @VisibleForTesting EnvironmentUserSyncState internalCalculateEnvironmentUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) { EnvironmentUserSyncState environmentUserSyncState = new EnvironmentUserSyncState(); if (null == userSyncStatus || null == userSyncStatus.getLastStartedFullSync()) { environmentUserSyncState.setState(UserSyncState.STALE); } else { environmentUserSyncState.setLastUserSyncOperationId(userSyncStatus.getLastStartedFullSync().getOperationId()); environmentUserSyncState.setState(calculateUserSyncState(accountId, envCrnString, userSyncStatus)); } return environmentUserSyncState; }  }
EnvironmentUserSyncStateCalculator { @VisibleForTesting EnvironmentUserSyncState internalCalculateEnvironmentUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) { EnvironmentUserSyncState environmentUserSyncState = new EnvironmentUserSyncState(); if (null == userSyncStatus || null == userSyncStatus.getLastStartedFullSync()) { environmentUserSyncState.setState(UserSyncState.STALE); } else { environmentUserSyncState.setLastUserSyncOperationId(userSyncStatus.getLastStartedFullSync().getOperationId()); environmentUserSyncState.setState(calculateUserSyncState(accountId, envCrnString, userSyncStatus)); } return environmentUserSyncState; }  EnvironmentUserSyncState calculateEnvironmentUserSyncState(String accountId, Crn environmentCrn); }
EnvironmentUserSyncStateCalculator { @VisibleForTesting EnvironmentUserSyncState internalCalculateEnvironmentUserSyncState(String accountId, String envCrnString, UserSyncStatus userSyncStatus) { EnvironmentUserSyncState environmentUserSyncState = new EnvironmentUserSyncState(); if (null == userSyncStatus || null == userSyncStatus.getLastStartedFullSync()) { environmentUserSyncState.setState(UserSyncState.STALE); } else { environmentUserSyncState.setLastUserSyncOperationId(userSyncStatus.getLastStartedFullSync().getOperationId()); environmentUserSyncState.setState(calculateUserSyncState(accountId, envCrnString, userSyncStatus)); } return environmentUserSyncState; }  EnvironmentUserSyncState calculateEnvironmentUserSyncState(String accountId, Crn environmentCrn);  }