@Test public void testDefaultProfileExistsForServerMatch() { when(request.getServerName()).thenReturn(matchingHost1); assertNotNull(serverProfileMapper.getProfileFname(person, request)); }
@Override public String getProfileFname(IPerson person, HttpServletRequest request) { Validate.notNull(person, "Cannot get profile fname for a null person."); Validate.notNull(request, "Cannot get profile fname for a null request."); String userName = person.getUserName(); final String userServerName = request.getServerName(); Matcher matcher = this.pattern.matcher(userServerName); if (matcher.matches()) { logger.debug( "User {} will be given {} profile because server {} matches regular expression {}", userName, this.profile, userServerName, this.serverRegex); return this.profile; } else { logger.debug( "User {} will not be given {} profile because server {} does not match regular expression {}", userName, this.profile, userServerName, this.serverRegex); return null; } }
ServerProfileMapperImpl implements IProfileMapper { @Override public String getProfileFname(IPerson person, HttpServletRequest request) { Validate.notNull(person, "Cannot get profile fname for a null person."); Validate.notNull(request, "Cannot get profile fname for a null request."); String userName = person.getUserName(); final String userServerName = request.getServerName(); Matcher matcher = this.pattern.matcher(userServerName); if (matcher.matches()) { logger.debug( "User {} will be given {} profile because server {} matches regular expression {}", userName, this.profile, userServerName, this.serverRegex); return this.profile; } else { logger.debug( "User {} will not be given {} profile because server {} does not match regular expression {}", userName, this.profile, userServerName, this.serverRegex); return null; } } }
ServerProfileMapperImpl implements IProfileMapper { @Override public String getProfileFname(IPerson person, HttpServletRequest request) { Validate.notNull(person, "Cannot get profile fname for a null person."); Validate.notNull(request, "Cannot get profile fname for a null request."); String userName = person.getUserName(); final String userServerName = request.getServerName(); Matcher matcher = this.pattern.matcher(userServerName); if (matcher.matches()) { logger.debug( "User {} will be given {} profile because server {} matches regular expression {}", userName, this.profile, userServerName, this.serverRegex); return this.profile; } else { logger.debug( "User {} will not be given {} profile because server {} does not match regular expression {}", userName, this.profile, userServerName, this.serverRegex); return null; } }  }
ServerProfileMapperImpl implements IProfileMapper { @Override public String getProfileFname(IPerson person, HttpServletRequest request) { Validate.notNull(person, "Cannot get profile fname for a null person."); Validate.notNull(request, "Cannot get profile fname for a null request."); String userName = person.getUserName(); final String userServerName = request.getServerName(); Matcher matcher = this.pattern.matcher(userServerName); if (matcher.matches()) { logger.debug( "User {} will be given {} profile because server {} matches regular expression {}", userName, this.profile, userServerName, this.serverRegex); return this.profile; } else { logger.debug( "User {} will not be given {} profile because server {} does not match regular expression {}", userName, this.profile, userServerName, this.serverRegex); return null; } }  @Required void setServerRegex(String serverRegex); void setProfile(String profile); @Override String getProfileFname(IPerson person, HttpServletRequest request); }
ServerProfileMapperImpl implements IProfileMapper { @Override public String getProfileFname(IPerson person, HttpServletRequest request) { Validate.notNull(person, "Cannot get profile fname for a null person."); Validate.notNull(request, "Cannot get profile fname for a null request."); String userName = person.getUserName(); final String userServerName = request.getServerName(); Matcher matcher = this.pattern.matcher(userServerName); if (matcher.matches()) { logger.debug( "User {} will be given {} profile because server {} matches regular expression {}", userName, this.profile, userServerName, this.serverRegex); return this.profile; } else { logger.debug( "User {} will not be given {} profile because server {} does not match regular expression {}", userName, this.profile, userServerName, this.serverRegex); return null; } }  @Required void setServerRegex(String serverRegex); void setProfile(String profile); @Override String getProfileFname(IPerson person, HttpServletRequest request);  }