@Test public void testNone(){ Profile p = new Profile(); p.setName("None"); p.setLastname("None"); p.setUsername("None"); p.setEmail("None"); p.setSource("None"); p.setSourceId("None"); Profile generate = service.generate(p); Assert.assertNull(generate.getName()); Assert.assertNull(generate.getLastname()); Assert.assertNull(generate.getUsername()); Assert.assertNull(generate.getEmail()); }
public Profile generate(Profile dirty){ String name = StringUtils.trimToEmpty(dirty.getName()); String email = StringUtils.trimToEmpty(dirty.getEmail()); Profile profile = new Profile(); profile.setUsername(dirty.getUsername()); profile.setEmail(email); profile.setSourceId(dirty.getSourceId()); Pattern p = Pattern.compile("([\\p{L}\\w\\?-]+) *([\\p{L}\\w\\?\\.\\d=\\\\ -]+)?"); Matcher matcher = p.matcher(name); logger.trace("Profile generate() {} ",name,email); if(matcher.matches()){ logger.trace("Profile generate() ************* MATCHES ***************"); profile.setName(matcher.group(1)); profile.setLastname(matcher.group(2)); }else{ logger.trace("Profile generate() ---------------- NOT MATCHED"); profile.setName(null); profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getName()).toLowerCase().equals("none")){ profile.setName(null); } if(StringUtils.trimToEmpty(profile.getLastname()).toLowerCase().equals("none")){ profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getUsername()).toLowerCase().equals("none")){ profile.setUsername(null); } if(StringUtils.trimToEmpty(profile.getEmail()).toLowerCase().equals("none")){ profile.setEmail(null); } logger.trace("Profile generate() Returning {} ",profile); return profile; }
ProfileFromItsKdeWhoService { public Profile generate(Profile dirty){ String name = StringUtils.trimToEmpty(dirty.getName()); String email = StringUtils.trimToEmpty(dirty.getEmail()); Profile profile = new Profile(); profile.setUsername(dirty.getUsername()); profile.setEmail(email); profile.setSourceId(dirty.getSourceId()); Pattern p = Pattern.compile("([\\p{L}\\w\\?-]+) *([\\p{L}\\w\\?\\.\\d=\\\\ -]+)?"); Matcher matcher = p.matcher(name); logger.trace("Profile generate() {} ",name,email); if(matcher.matches()){ logger.trace("Profile generate() ************* MATCHES ***************"); profile.setName(matcher.group(1)); profile.setLastname(matcher.group(2)); }else{ logger.trace("Profile generate() ---------------- NOT MATCHED"); profile.setName(null); profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getName()).toLowerCase().equals("none")){ profile.setName(null); } if(StringUtils.trimToEmpty(profile.getLastname()).toLowerCase().equals("none")){ profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getUsername()).toLowerCase().equals("none")){ profile.setUsername(null); } if(StringUtils.trimToEmpty(profile.getEmail()).toLowerCase().equals("none")){ profile.setEmail(null); } logger.trace("Profile generate() Returning {} ",profile); return profile; } }
ProfileFromItsKdeWhoService { public Profile generate(Profile dirty){ String name = StringUtils.trimToEmpty(dirty.getName()); String email = StringUtils.trimToEmpty(dirty.getEmail()); Profile profile = new Profile(); profile.setUsername(dirty.getUsername()); profile.setEmail(email); profile.setSourceId(dirty.getSourceId()); Pattern p = Pattern.compile("([\\p{L}\\w\\?-]+) *([\\p{L}\\w\\?\\.\\d=\\\\ -]+)?"); Matcher matcher = p.matcher(name); logger.trace("Profile generate() {} ",name,email); if(matcher.matches()){ logger.trace("Profile generate() ************* MATCHES ***************"); profile.setName(matcher.group(1)); profile.setLastname(matcher.group(2)); }else{ logger.trace("Profile generate() ---------------- NOT MATCHED"); profile.setName(null); profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getName()).toLowerCase().equals("none")){ profile.setName(null); } if(StringUtils.trimToEmpty(profile.getLastname()).toLowerCase().equals("none")){ profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getUsername()).toLowerCase().equals("none")){ profile.setUsername(null); } if(StringUtils.trimToEmpty(profile.getEmail()).toLowerCase().equals("none")){ profile.setEmail(null); } logger.trace("Profile generate() Returning {} ",profile); return profile; }  }
ProfileFromItsKdeWhoService { public Profile generate(Profile dirty){ String name = StringUtils.trimToEmpty(dirty.getName()); String email = StringUtils.trimToEmpty(dirty.getEmail()); Profile profile = new Profile(); profile.setUsername(dirty.getUsername()); profile.setEmail(email); profile.setSourceId(dirty.getSourceId()); Pattern p = Pattern.compile("([\\p{L}\\w\\?-]+) *([\\p{L}\\w\\?\\.\\d=\\\\ -]+)?"); Matcher matcher = p.matcher(name); logger.trace("Profile generate() {} ",name,email); if(matcher.matches()){ logger.trace("Profile generate() ************* MATCHES ***************"); profile.setName(matcher.group(1)); profile.setLastname(matcher.group(2)); }else{ logger.trace("Profile generate() ---------------- NOT MATCHED"); profile.setName(null); profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getName()).toLowerCase().equals("none")){ profile.setName(null); } if(StringUtils.trimToEmpty(profile.getLastname()).toLowerCase().equals("none")){ profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getUsername()).toLowerCase().equals("none")){ profile.setUsername(null); } if(StringUtils.trimToEmpty(profile.getEmail()).toLowerCase().equals("none")){ profile.setEmail(null); } logger.trace("Profile generate() Returning {} ",profile); return profile; }  Profile generate(Profile dirty); }
ProfileFromItsKdeWhoService { public Profile generate(Profile dirty){ String name = StringUtils.trimToEmpty(dirty.getName()); String email = StringUtils.trimToEmpty(dirty.getEmail()); Profile profile = new Profile(); profile.setUsername(dirty.getUsername()); profile.setEmail(email); profile.setSourceId(dirty.getSourceId()); Pattern p = Pattern.compile("([\\p{L}\\w\\?-]+) *([\\p{L}\\w\\?\\.\\d=\\\\ -]+)?"); Matcher matcher = p.matcher(name); logger.trace("Profile generate() {} ",name,email); if(matcher.matches()){ logger.trace("Profile generate() ************* MATCHES ***************"); profile.setName(matcher.group(1)); profile.setLastname(matcher.group(2)); }else{ logger.trace("Profile generate() ---------------- NOT MATCHED"); profile.setName(null); profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getName()).toLowerCase().equals("none")){ profile.setName(null); } if(StringUtils.trimToEmpty(profile.getLastname()).toLowerCase().equals("none")){ profile.setLastname(null); } if(StringUtils.trimToEmpty(profile.getUsername()).toLowerCase().equals("none")){ profile.setUsername(null); } if(StringUtils.trimToEmpty(profile.getEmail()).toLowerCase().equals("none")){ profile.setEmail(null); } logger.trace("Profile generate() Returning {} ",profile); return profile; }  Profile generate(Profile dirty);  }