MutableComponentModelImpl implements MutableComponentModel { public String getFieldPersistenceStrategy(String fieldName) { String result = InternalUtils.get(persistentFields, fieldName); if (result == null && parentModel != null) result = parentModel.getFieldPersistenceStrategy(fieldName); if (result == null) throw new IllegalArgumentException(String.format("No field persistence strategy has been defined for field '%s'.", fieldName)); return result; } MutableComponentModelImpl(String componentClassName, Logger logger, Resource baseResource,
                                     ComponentModel parentModel, boolean pageClass, String libraryName); String getLibraryName(); @Override String toString(); Logger getLogger(); Resource getBaseResource(); String getComponentClassName(); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix,
                             boolean cached); void addParameter(String name, boolean required, boolean allowNull, String defaultBindingPrefix); ParameterModel getParameterModel(String parameterName); boolean isFormalParameter(String parameterName); List<String> getParameterNames(); List<String> getDeclaredParameterNames(); MutableEmbeddedComponentModel addEmbeddedComponent(String id, String type, String componentClassName,
                                                              boolean inheritInformalParameters, Location location); List<String> getEmbeddedComponentIds(); EmbeddedComponentModel getEmbeddedComponentModel(String componentId); String getFieldPersistenceStrategy(String fieldName); List<String> getPersistentFieldNames(); String setFieldPersistenceStrategy(String fieldName, String strategy); boolean isRootClass(); void addMixinClassName(String mixinClassName, String... order); List<String> getMixinClassNames(); void enableSupportsInformalParameters(); boolean getSupportsInformalParameters(); ComponentModel getParentModel(); boolean isMixinAfter(); void setMixinAfter(boolean mixinAfter); void setMeta(String key, String value); void addRenderPhase(Class renderPhase); void addEventHandler(String eventType); String getMeta(String key); Set<Class> getHandledRenderPhases(); boolean handlesEvent(String eventType); String[] getOrderForMixin(String mixinClassName); boolean isPage(); void doHandleActivationEventContext(); boolean handleActivationEventContext();  }
@Test public void no_persistence_defined_for_field() { Resource r = mockResource(); Logger logger = mockLogger(); replay(); MutableComponentModel model = new MutableComponentModelImpl(CLASS_NAME, logger, r, null, false, null); try { model.getFieldPersistenceStrategy("someField"); unreachable(); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage(), "No field persistence strategy has been defined for field \'someField\'."); } verify(); }