@Test public void synchronizeStudentMapping_MappingByMartikelNumber() { when(userMappingDaoMock.existsMappingForSapUserId(studentMock.getId())).thenReturn(false); when(studentMappingByMartikelNumberMock.tryToMap(studentMock)).thenReturn(identityMock); MappingResult result = studentMapperTestObject.synchronizeStudentMapping(studentMock); assertEquals("", MappingResult.NEW_MAPPING_BY_MATRIKEL_NR, result); }
@Transactional(propagation = Propagation.REQUIRES_NEW) public MappingResult synchronizeStudentMapping(Student student) { if (!userMappingDao.existsMappingForSapUserId(student.getId())) { Identity mappedIdentity = studentMappingByMartikelNumber.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_MATRIKEL_NR; } mappedIdentity = mappingByEmail.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_EMAIL; } mappedIdentity = mappingByFirstNameAndLastName.tryToMap(student.getFirstName(), student.getLastName()); if (mappedIdentity != null) { return MappingResult.COULD_BE_MAPPED_MANUALLY; } else { return MappingResult.COULD_NOT_MAP; } } return MappingResult.MAPPING_ALREADY_EXIST; }
StudentMapper { @Transactional(propagation = Propagation.REQUIRES_NEW) public MappingResult synchronizeStudentMapping(Student student) { if (!userMappingDao.existsMappingForSapUserId(student.getId())) { Identity mappedIdentity = studentMappingByMartikelNumber.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_MATRIKEL_NR; } mappedIdentity = mappingByEmail.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_EMAIL; } mappedIdentity = mappingByFirstNameAndLastName.tryToMap(student.getFirstName(), student.getLastName()); if (mappedIdentity != null) { return MappingResult.COULD_BE_MAPPED_MANUALLY; } else { return MappingResult.COULD_NOT_MAP; } } return MappingResult.MAPPING_ALREADY_EXIST; } }
StudentMapper { @Transactional(propagation = Propagation.REQUIRES_NEW) public MappingResult synchronizeStudentMapping(Student student) { if (!userMappingDao.existsMappingForSapUserId(student.getId())) { Identity mappedIdentity = studentMappingByMartikelNumber.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_MATRIKEL_NR; } mappedIdentity = mappingByEmail.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_EMAIL; } mappedIdentity = mappingByFirstNameAndLastName.tryToMap(student.getFirstName(), student.getLastName()); if (mappedIdentity != null) { return MappingResult.COULD_BE_MAPPED_MANUALLY; } else { return MappingResult.COULD_NOT_MAP; } } return MappingResult.MAPPING_ALREADY_EXIST; }  }
StudentMapper { @Transactional(propagation = Propagation.REQUIRES_NEW) public MappingResult synchronizeStudentMapping(Student student) { if (!userMappingDao.existsMappingForSapUserId(student.getId())) { Identity mappedIdentity = studentMappingByMartikelNumber.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_MATRIKEL_NR; } mappedIdentity = mappingByEmail.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_EMAIL; } mappedIdentity = mappingByFirstNameAndLastName.tryToMap(student.getFirstName(), student.getLastName()); if (mappedIdentity != null) { return MappingResult.COULD_BE_MAPPED_MANUALLY; } else { return MappingResult.COULD_NOT_MAP; } } return MappingResult.MAPPING_ALREADY_EXIST; }  @Transactional(propagation = Propagation.REQUIRES_NEW) MappingResult synchronizeStudentMapping(Student student); }
StudentMapper { @Transactional(propagation = Propagation.REQUIRES_NEW) public MappingResult synchronizeStudentMapping(Student student) { if (!userMappingDao.existsMappingForSapUserId(student.getId())) { Identity mappedIdentity = studentMappingByMartikelNumber.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_MATRIKEL_NR; } mappedIdentity = mappingByEmail.tryToMap(student); if (mappedIdentity != null) { userMappingDao.saveMapping(student, mappedIdentity); return MappingResult.NEW_MAPPING_BY_EMAIL; } mappedIdentity = mappingByFirstNameAndLastName.tryToMap(student.getFirstName(), student.getLastName()); if (mappedIdentity != null) { return MappingResult.COULD_BE_MAPPED_MANUALLY; } else { return MappingResult.COULD_NOT_MAP; } } return MappingResult.MAPPING_ALREADY_EXIST; }  @Transactional(propagation = Propagation.REQUIRES_NEW) MappingResult synchronizeStudentMapping(Student student);  }