@Test(expected = IllegalArgumentException.class) public void processThrowsExceptionIfInvalidEmail() throws Exception { new GuestDataProcessor().processItem("foo bar, invalidemail.de"); }
@Override public Object processItem(Object o) throws Exception { LOGGER.info(() -> "Processing item " + o); String[] split = ((String) o).split(","); if (split.length != 3) { throw new IllegalArgumentException("Unexpected format in " + o); } String publicId = split[0].trim(); String name = split[1].trim(); String email = split[2].trim(); if (!email.matches("\\p{Alnum}+@\\p{Alnum}+.\\p{Alnum}+")) { throw new IllegalArgumentException("Unexpected email '" + email + "'"); } return new Guest(publicId, name, email); }
GuestDataProcessor implements ItemProcessor { @Override public Object processItem(Object o) throws Exception { LOGGER.info(() -> "Processing item " + o); String[] split = ((String) o).split(","); if (split.length != 3) { throw new IllegalArgumentException("Unexpected format in " + o); } String publicId = split[0].trim(); String name = split[1].trim(); String email = split[2].trim(); if (!email.matches("\\p{Alnum}+@\\p{Alnum}+.\\p{Alnum}+")) { throw new IllegalArgumentException("Unexpected email '" + email + "'"); } return new Guest(publicId, name, email); } }
GuestDataProcessor implements ItemProcessor { @Override public Object processItem(Object o) throws Exception { LOGGER.info(() -> "Processing item " + o); String[] split = ((String) o).split(","); if (split.length != 3) { throw new IllegalArgumentException("Unexpected format in " + o); } String publicId = split[0].trim(); String name = split[1].trim(); String email = split[2].trim(); if (!email.matches("\\p{Alnum}+@\\p{Alnum}+.\\p{Alnum}+")) { throw new IllegalArgumentException("Unexpected email '" + email + "'"); } return new Guest(publicId, name, email); } GuestDataProcessor(); @Inject  GuestDataProcessor(JobContext jobContext); }
GuestDataProcessor implements ItemProcessor { @Override public Object processItem(Object o) throws Exception { LOGGER.info(() -> "Processing item " + o); String[] split = ((String) o).split(","); if (split.length != 3) { throw new IllegalArgumentException("Unexpected format in " + o); } String publicId = split[0].trim(); String name = split[1].trim(); String email = split[2].trim(); if (!email.matches("\\p{Alnum}+@\\p{Alnum}+.\\p{Alnum}+")) { throw new IllegalArgumentException("Unexpected email '" + email + "'"); } return new Guest(publicId, name, email); } GuestDataProcessor(); @Inject  GuestDataProcessor(JobContext jobContext); @Override Object processItem(Object o); }
GuestDataProcessor implements ItemProcessor { @Override public Object processItem(Object o) throws Exception { LOGGER.info(() -> "Processing item " + o); String[] split = ((String) o).split(","); if (split.length != 3) { throw new IllegalArgumentException("Unexpected format in " + o); } String publicId = split[0].trim(); String name = split[1].trim(); String email = split[2].trim(); if (!email.matches("\\p{Alnum}+@\\p{Alnum}+.\\p{Alnum}+")) { throw new IllegalArgumentException("Unexpected email '" + email + "'"); } return new Guest(publicId, name, email); } GuestDataProcessor(); @Inject  GuestDataProcessor(JobContext jobContext); @Override Object processItem(Object o);  }