@Test public void testItemValidation() { final JobSupport jobSupport = new JobSupport(); try { jobSupport.validateJobItem(new JobItem("levitate", new User()), Lists.newArrayList("post")); fail("item with an unknown method"); } catch (InvalidException e) { assertTrue(e.getFirstError() != null); } }
public void validateJobItem(JobItem item, List<String> methods) { if (!methods.contains(item.getMethod())) { final String message = String.format( "job method [%s] not allowed, must be one of " + Joiner.on(", ").join(methods), item.getMethod() ); throw new InvalidException( new ErrorCollection( Lists.newArrayList( new Error("invalid", message)))); } }
JobSupport { public void validateJobItem(JobItem item, List<String> methods) { if (!methods.contains(item.getMethod())) { final String message = String.format( "job method [%s] not allowed, must be one of " + Joiner.on(", ").join(methods), item.getMethod() ); throw new InvalidException( new ErrorCollection( Lists.newArrayList( new Error("invalid", message)))); } } }
JobSupport { public void validateJobItem(JobItem item, List<String> methods) { if (!methods.contains(item.getMethod())) { final String message = String.format( "job method [%s] not allowed, must be one of " + Joiner.on(", ").join(methods), item.getMethod() ); throw new InvalidException( new ErrorCollection( Lists.newArrayList( new Error("invalid", message)))); } }  }
JobSupport { public void validateJobItem(JobItem item, List<String> methods) { if (!methods.contains(item.getMethod())) { final String message = String.format( "job method [%s] not allowed, must be one of " + Joiner.on(", ").join(methods), item.getMethod() ); throw new InvalidException( new ErrorCollection( Lists.newArrayList( new Error("invalid", message)))); } }  void validateJobItem(JobItem item, List<String> methods); }
JobSupport { public void validateJobItem(JobItem item, List<String> methods) { if (!methods.contains(item.getMethod())) { final String message = String.format( "job method [%s] not allowed, must be one of " + Joiner.on(", ").join(methods), item.getMethod() ); throw new InvalidException( new ErrorCollection( Lists.newArrayList( new Error("invalid", message)))); } }  void validateJobItem(JobItem item, List<String> methods);  }