EPNValidator { protected static boolean validateNotifications(Network epn, Node node, EPNValidationListener l) { boolean ret=true; for (Notification no : node.getNotifications()) { if (no.getSubject() == null) { l.error(epn, no, MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-11"), "Notification", "subject", node.getName())); ret = false; } if (no.getType() == null) { l.error(epn, no, MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-11"), "Notification", "type", node.getName())); ret = false; } } return (ret); } private  EPNValidator(); static boolean validate(Network epn, EPNValidationListener l);  }
@Test public void testValidateEmptyNotification() { Network epn=new Network(); Node node=new Node(); epn.getNodes().add(node); Notification not=new Notification(); node.getNotifications().add(not); TestListener l=new TestListener(); if (EPNValidator.validateNotifications(epn, node, l)) { fail("Should be invalid"); } String[] expected=new String[] { MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-11"), "Notification", "subject", node.getName()), MessageFormat.format(java.util.PropertyResourceBundle.getBundle( "epn-core.Messages").getString("EPN-CORE-11"), "Notification", "type", node.getName()) }; validateIssues(expected, l.getIssues()); }
@Test public void testValidateNotification() { Network epn=new Network(); Node node=new Node(); epn.getNodes().add(node); Notification not=new Notification(); not.setType(NotificationType.Processed); not.setSubject("sub"); node.getNotifications().add(not); TestListener l=new TestListener(); if (!EPNValidator.validateNotifications(epn, node, l)) { fail("Should be valid"); } String[] expected=new String[] { }; validateIssues(expected, l.getIssues()); }