use of io.gravitee.am.model.scim.Attribute in project gravitee-access-management by gravitee-io.
the class UserFactorUpdaterTest method shouldNotUpdateEmail_TooMuchDiff.
@Test
public void shouldNotUpdateEmail_TooMuchDiff() {
User existingUser = new User();
existingUser.setEmail("email@domain.org");
Attribute email1 = new Attribute();
email1.setValue(existingUser.getEmail());
Attribute email2 = new Attribute();
email2.setValue("email2@domain.org");
Attribute email3 = new Attribute();
email3.setValue("email3@domain.org");
existingUser.setEmails(Arrays.asList(email1, email2, email3));
EnrolledFactor factor = new EnrolledFactor();
factor.setChannel(new EnrolledFactorChannel(EnrolledFactorChannel.Type.EMAIL, email3.getValue()));
User updatedUser = new User();
updatedUser.setEmail(null);
Attribute uemail1 = new Attribute();
// value is the same
uemail1.setValue(email1.getValue());
Attribute uemail2 = new Attribute();
uemail2.setValue("uemail2@domain.org");
Attribute uemail3 = new Attribute();
uemail3.setValue("uemail3@domain.org");
updatedUser.setEmails(Arrays.asList(uemail1, uemail2, uemail3));
UserFactorUpdater.updateFactors(singletonList(factor), existingUser, updatedUser);
assertEquals("Email should not be updated", email3.getValue(), factor.getChannel().getTarget());
}
Aggregations