ScimUtils { public static ExpiringCode getExpiringCode( ExpiringCodeStore codeStore, String userId, String email, String clientId, String redirectUri, ExpiringCodeType intent, String currentZoneId) { Assert.notNull(codeStore, "codeStore must not be null"); Assert.notNull(userId, "userId must not be null"); Assert.notNull(email, "email must not be null"); Assert.notNull(intent, "intent must not be null"); Map<String, String> codeData = new HashMap<>(); codeData.put("user_id", userId); codeData.put("email", email); codeData.put("client_id", clientId); if (redirectUri != null) { codeData.put("redirect_uri", redirectUri); } String codeDataString = JsonUtils.writeValueAsString(codeData); Timestamp expiresAt = new Timestamp(System.currentTimeMillis() + (60 * 60 * 1000)); return codeStore.generateCode( codeDataString, expiresAt, intent.name(), currentZoneId); } private  ScimUtils(); static ExpiringCode getExpiringCode(
            ExpiringCodeStore codeStore,
            String userId,
            String email,
            String clientId,
            String redirectUri,
            ExpiringCodeType intent,
            String currentZoneId); static URL getVerificationURL(
            ExpiringCode expiringCode,
            IdentityZone currentIdentityZone); static void validate(final ScimUser user);  }
@Test void getExpiringCode() { ExpiringCodeStore mockExpiringCodeStore = mock(ExpiringCodeStore.class); String userId = "userId"; String email = "email"; String clientId = "clientId"; String redirectUri = "redirectUri"; String currentZoneId = "currentZoneId"; ExpiringCodeType expiringCodeType = ExpiringCodeType.REGISTRATION; Timestamp before = new Timestamp(System.currentTimeMillis() + (55 * 60 * 1000)); ScimUtils.getExpiringCode( mockExpiringCodeStore, userId, email, clientId, redirectUri, expiringCodeType, currentZoneId ); Timestamp after = new Timestamp(System.currentTimeMillis() + (65 * 60 * 1000)); ArgumentCaptor<Timestamp> timestampArgumentCaptor = ArgumentCaptor.forClass(Timestamp.class); verify(mockExpiringCodeStore).generateCode( eq("{\"user_id\":\"userId\",\"redirect_uri\":\"redirectUri\",\"email\":\"email\",\"client_id\":\"clientId\"}"), timestampArgumentCaptor.capture(), eq("REGISTRATION"), eq(currentZoneId)); assertThat(timestampArgumentCaptor.getValue().after(before), is(true)); assertThat(timestampArgumentCaptor.getValue().before(after), is(true)); }