@Test public void test() { List<Message> messages; assertEquals(0, validator.getMessages().size()); validator.validate(ClassAvailable.class.getCanonicalName()); assertEquals(0, validator.getMessages().size()); validator.validate("java.lang.String"); assertEquals(0, validator.getMessages().size()); validator.validate("net.jarcec.super.private.project.Main"); assertEquals(1, validator.getMessages().size()); messages = validator.getMessages(); assertEquals(Status.ERROR, messages.get(0).getStatus()); validator.validate(null); assertEquals(2, validator.getMessages().size()); messages = validator.getMessages(); assertEquals(Status.ERROR, messages.get(1).getStatus()); }
@Override public void validate(String klass) { if (klass == null) { addMessage(new Message(Status.ERROR, "Class cannot be null")); } else { try { Class.forName(klass); } catch (ClassNotFoundException e) { addMessage(new Message(Status.ERROR, "Class not found")); } } }
ClassAvailable extends AbstractValidator<String> { @Override public void validate(String klass) { if (klass == null) { addMessage(new Message(Status.ERROR, "Class cannot be null")); } else { try { Class.forName(klass); } catch (ClassNotFoundException e) { addMessage(new Message(Status.ERROR, "Class not found")); } } } }
ClassAvailable extends AbstractValidator<String> { @Override public void validate(String klass) { if (klass == null) { addMessage(new Message(Status.ERROR, "Class cannot be null")); } else { try { Class.forName(klass); } catch (ClassNotFoundException e) { addMessage(new Message(Status.ERROR, "Class not found")); } } }  }
ClassAvailable extends AbstractValidator<String> { @Override public void validate(String klass) { if (klass == null) { addMessage(new Message(Status.ERROR, "Class cannot be null")); } else { try { Class.forName(klass); } catch (ClassNotFoundException e) { addMessage(new Message(Status.ERROR, "Class not found")); } } }  @Override void validate(String klass); }
ClassAvailable extends AbstractValidator<String> { @Override public void validate(String klass) { if (klass == null) { addMessage(new Message(Status.ERROR, "Class cannot be null")); } else { try { Class.forName(klass); } catch (ClassNotFoundException e) { addMessage(new Message(Status.ERROR, "Class not found")); } } }  @Override void validate(String klass);  }