Skip to content

Commit

Permalink
Merge pull request #1044 from oncokb/fix-check-duplicate-users
Browse files Browse the repository at this point in the history
Fix check duplicate users
  • Loading branch information
bprize15 authored Nov 2, 2023
2 parents 19ce8dc + 877266e commit 3e4ad5e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ public List<UserDTO> searchAccountsForPotentialDuplicateUser(UserDTO user, List<
List<UserDTO> potentialDuplicateUsers = new ArrayList<>();
for (UserDTO potentialDuplicate : allUsers) {
String potentialDuplicateFullName = StringUtil.getFullName(potentialDuplicate.getFirstName(), potentialDuplicate.getLastName());
if (user.getId() != potentialDuplicate.getId() && jw.apply(userFullName, potentialDuplicateFullName) > .7) {
if (!user.getId().equals(potentialDuplicate.getId()) && jw.apply(userFullName, potentialDuplicateFullName) > .85) {
potentialDuplicateUsers.add(potentialDuplicate);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.mskcc.cbio.oncokb.service.mapper.UserMapper;

import io.github.jhipster.security.RandomUtil;

import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -381,7 +380,7 @@ public void assertThatUserTokenStatusIsExpected() {
//UNIT TESTS
@Test
public void assertThatDuplicateUsersAreCaught() {
long id = -1;
Long id = 6000L;

UserDTO user = new UserDTO();
user.setFirstName("Jon");
Expand Down Expand Up @@ -427,6 +426,12 @@ public void assertThatDuplicateUsersAreCaught() {

allUsers.add(newUser);
}

UserDTO testSameIdUser = new UserDTO(); //need this to ensure comparison of IDs is done correctly, Longs are compared by reference
testSameIdUser.setFirstName(user.getFirstName());
testSameIdUser.setLastName(user.getLastName());
testSameIdUser.setId(new Long(user.getId()));
allUsers.add(testSameIdUser);

List<UserDTO> duplicateUsers = userService.searchAccountsForPotentialDuplicateUser(user, allUsers);
assertThat(duplicateUsers).containsExactlyInAnyOrder(similarUsers.toArray(new UserDTO[similarUsers.size()]));
Expand Down

0 comments on commit 3e4ad5e

Please sign in to comment.