class RegistrationService {

	public boolean register(User user) throws IllegalArgumentException {
		String email = user.getEmail();
		if (getByEMail(email) != null) {
			log.info(String.format("User with email=%s already registered",
					email));
			return false;
		}
		if (!validEMailAdress(email)) {
			log.info(String.format("email=%s invalid", email));
			throw new IllegalArgumentException("Invalid EMail Adress!");
		}
		jdbcTemplate.update(
				"INSERT INTO T_USER(firstname, name, email) VALUES (?, ?, ?)",
				user.getFirstname(), user.getName(), email);
		log.info(String.format("Registered firstname=%s name=%s email=%s",
				user.getFirstname(), user.getName(), email));
		return true;
	}

}

class RegistrationServiceTest {

	@Autowired
	private RegistrationService registrationService;

	@Test(expected=IllegalArgumentException.class)
	public void avoidInvalidEMail() {

		User user = new User("Eberhard","Wolff","HURZ!");
		registrationService.register(user);
	}

}