@Test public void tryToMap_foundMoreThanOneMapping() { List<Identity> twoIdentities = new ArrayList<Identity>(); twoIdentities.add(identityMockOne); twoIdentities.add(identityMockTwo); when( baseSecurityMock.getVisibleIdentitiesByPowerSearch(anyString(), anyMap(), anyBoolean(), any(SecurityGroup[].class), any(PermissionOnResourceable[].class), any(String[].class), any(Date.class), any(Date.class))).thenReturn(twoIdentities); Identity mappedIdentity = lecturerMappingByPersonalNumberTestObject.tryToMap(lecturerMock.getPersonalNr()); assertNull("Must return null, when more than one mapping exists", mappedIdentity); }
public Identity tryToMap(Long personalNr) { Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString()); if (mappedIdentity != null) { String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER); try { Long personalNumberAsLong = Long.valueOf(personalNumber); if (personalNumberAsLong.equals(personalNr)) { return mappedIdentity; } log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr); } catch (NumberFormatException ex) { log.warn("Could not convert personal-number to Long"); } } return null; }
LecturerMappingByPersonalNumber extends AbstractMappingByInstitutionalIdentifier { public Identity tryToMap(Long personalNr) { Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString()); if (mappedIdentity != null) { String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER); try { Long personalNumberAsLong = Long.valueOf(personalNumber); if (personalNumberAsLong.equals(personalNr)) { return mappedIdentity; } log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr); } catch (NumberFormatException ex) { log.warn("Could not convert personal-number to Long"); } } return null; } }
LecturerMappingByPersonalNumber extends AbstractMappingByInstitutionalIdentifier { public Identity tryToMap(Long personalNr) { Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString()); if (mappedIdentity != null) { String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER); try { Long personalNumberAsLong = Long.valueOf(personalNumber); if (personalNumberAsLong.equals(personalNr)) { return mappedIdentity; } log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr); } catch (NumberFormatException ex) { log.warn("Could not convert personal-number to Long"); } } return null; }  }
LecturerMappingByPersonalNumber extends AbstractMappingByInstitutionalIdentifier { public Identity tryToMap(Long personalNr) { Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString()); if (mappedIdentity != null) { String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER); try { Long personalNumberAsLong = Long.valueOf(personalNumber); if (personalNumberAsLong.equals(personalNr)) { return mappedIdentity; } log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr); } catch (NumberFormatException ex) { log.warn("Could not convert personal-number to Long"); } } return null; }  Identity tryToMap(Long personalNr); }
LecturerMappingByPersonalNumber extends AbstractMappingByInstitutionalIdentifier { public Identity tryToMap(Long personalNr) { Identity mappedIdentity = tryToMap(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER, "%" + personalNr.toString()); if (mappedIdentity != null) { String personalNumber = mappedIdentity.getUser().getRawUserProperty(UserConstants.INSTITUTIONAL_EMPLOYEE_NUMBER); try { Long personalNumberAsLong = Long.valueOf(personalNumber); if (personalNumberAsLong.equals(personalNr)) { return mappedIdentity; } log.warn("User-Property as Long (" + personalNumberAsLong + ") has not the same value as lecturer personal-number=" + personalNr); } catch (NumberFormatException ex) { log.warn("Could not convert personal-number to Long"); } } return null; }  Identity tryToMap(Long personalNr);  }