@Test public void fireEvents() { Locale.setDefault(Locale.ENGLISH); final AgentsModel pm = new AgentsModel(); ModelProvider prov = new ModelProvider(); prov.setPresentationModel(pm); final BnModelObserver ob = new BnModelObserver(); ob.setPath(new Path("this")); ob.setModelProvider(prov); final int[] count = new int[1]; final boolean[] isValid = new boolean[] { true }; ob.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if ("presentationModel".equals(evt.getPropertyName())) { count[0]++; isValid[0] = ob.getPresentationModel().isValid(); } } }); pm.getContext().addService(UIService.class, new UIService() { public String[] getServerProjects() { return new String[] { "testproject" }; } }); assertEquals("pm.selectedProject.getText()", "testproject", pm.selectedProject.getText()); assertTrue("pm.selectedProject.isValid()", pm.selectedProject.isValid()); assertEquals("validation message", "This value is mandatory", getFirstNonCompositeState(pm.getValidationState()).getMessage()); assertFalse("pm.isValid()", pm.isValid()); assertEquals("count[0]", 9, count[0]); assertFalse("isValid[0]", isValid[0]); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!super.equals(o)) { return false; } if (o == null) { return false; } if (o.getClass() != getClass()) { return false; } CompositeValidationState castedObj = (CompositeValidationState)o; return ((this.children == null ? castedObj.children == null : this.children.equals(castedObj.children))); }
CompositeValidationState extends ValidationState { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!super.equals(o)) { return false; } if (o == null) { return false; } if (o.getClass() != getClass()) { return false; } CompositeValidationState castedObj = (CompositeValidationState)o; return ((this.children == null ? castedObj.children == null : this.children.equals(castedObj.children))); } }
CompositeValidationState extends ValidationState { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!super.equals(o)) { return false; } if (o == null) { return false; } if (o.getClass() != getClass()) { return false; } CompositeValidationState castedObj = (CompositeValidationState)o; return ((this.children == null ? castedObj.children == null : this.children.equals(castedObj.children))); } CompositeValidationState(String message, ValidationState... states);  CompositeValidationState(String message, Collection<ValidationState> states); }
CompositeValidationState extends ValidationState { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!super.equals(o)) { return false; } if (o == null) { return false; } if (o.getClass() != getClass()) { return false; } CompositeValidationState castedObj = (CompositeValidationState)o; return ((this.children == null ? castedObj.children == null : this.children.equals(castedObj.children))); } CompositeValidationState(String message, ValidationState... states);  CompositeValidationState(String message, Collection<ValidationState> states); List<ValidationState> getChildren(); @Override boolean equals(Object o); @Override int hashCode(); static CompositeValidationState create(String messagePrefix, ValidationState... states); }
CompositeValidationState extends ValidationState { @Override public boolean equals(Object o) { if (this == o) { return true; } if (!super.equals(o)) { return false; } if (o == null) { return false; } if (o.getClass() != getClass()) { return false; } CompositeValidationState castedObj = (CompositeValidationState)o; return ((this.children == null ? castedObj.children == null : this.children.equals(castedObj.children))); } CompositeValidationState(String message, ValidationState... states);  CompositeValidationState(String message, Collection<ValidationState> states); List<ValidationState> getChildren(); @Override boolean equals(Object o); @Override int hashCode(); static CompositeValidationState create(String messagePrefix, ValidationState... states);  }