@Test public void validateOperation() throws Throwable { class ArticleModel extends AbstractPM { @Property TextPM name = new TextPM(); @Property IntegerPM number = new IntegerPM(); @Property OperationPM addToCart = new OperationPM(); public ArticleModel() { number.setInteger(1); PMManager.setup(this); } @Operation public void addToCart() { number.setInteger(number.getInteger() - 1); } @Validation(path = "addToCart", message = "no items in stock") public boolean hasItemsInStock() { return number != null && number.getInteger() > 0; } } ArticleModel pModel = new ArticleModel(); assertEquals("pModel.addToCart.isEnabled()", true, pModel.addToCart.isEnabled()); pModel.addToCart.execute(); assertEquals("pModel.addToCart.isEnabled()", false, pModel.addToCart.isEnabled()); }
public void setup(Method method) { if (map.containsKey(method) == false) { ValidationMethodSupport support = support(model, method, resourceBundle); map.put(method, support); } }
ValidationSupport implements Support { public void setup(Method method) { if (map.containsKey(method) == false) { ValidationMethodSupport support = support(model, method, resourceBundle); map.put(method, support); } } }
ValidationSupport implements Support { public void setup(Method method) { if (map.containsKey(method) == false) { ValidationMethodSupport support = support(model, method, resourceBundle); map.put(method, support); } } private  ValidationSupport(PresentationModel model); }
ValidationSupport implements Support { public void setup(Method method) { if (map.containsKey(method) == false) { ValidationMethodSupport support = support(model, method, resourceBundle); map.put(method, support); } } private  ValidationSupport(PresentationModel model); static ValidationSupport get(PresentationModel model); void setup(Method method); }
ValidationSupport implements Support { public void setup(Method method) { if (map.containsKey(method) == false) { ValidationMethodSupport support = support(model, method, resourceBundle); map.put(method, support); } } private  ValidationSupport(PresentationModel model); static ValidationSupport get(PresentationModel model); void setup(Method method);  }