RestRequestParamsPropertyHolder implements RestParamsPropertyHolder, TestPropertyListener { public String[] getPropertyNames() { return sortedPropertyNames.toArray(new String[sortedPropertyNames.size()]); } RestRequestParamsPropertyHolder(RestParamsPropertyHolder methodParams, RestRequest restRequest,
                                           StringToStringMap values); void reset(RestParamsPropertyHolder methodParams, StringToStringMap values); RestParamProperty addProperty(String name); void addParameter(RestParamProperty prop); @Override void setParameterLocation(RestParamProperty parameter, NewRestResourceActionBase.ParamLocation newLocation); void addTestPropertyListener(TestPropertyListener listener); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); Set<Entry<String, TestProperty>> entrySet(); RestParamProperty get(Object key); ModelItem getModelItem(); Map<String, TestProperty> getProperties(); String getPropertiesLabel(); RestParamProperty getProperty(String name); RestParamProperty getPropertyAt(int index); int getPropertyCount(); PropertyExpansion[] getPropertyExpansions(); int getPropertyIndex(String name); String[] getPropertyNames(); String getPropertyValue(String name); boolean hasProperty(String name); boolean isEmpty(); Set<String> keySet(); void moveProperty(String propertyName, int targetIndex); TestProperty put(String key, TestProperty value); void putAll(Map<? extends String, ? extends TestProperty> m); TestProperty remove(Object key); RestParamProperty removeProperty(String propertyName); void removeTestPropertyListener(TestPropertyListener listener); boolean renameProperty(String name, String newName); void resetValues(); void release(); void saveTo(Properties props); void setPropertiesLabel(String propertiesLabel); void setPropertyValue(String name, String value); int size(); Collection<TestProperty> values(); void propertyAdded(String name); void propertyMoved(String name, int oldIndex, int newIndex); void propertyRemoved(String name); void propertyRenamed(String oldName, String newName); void propertyValueChanged(String name, String oldValue, String newValue); List<TestProperty> getPropertyList();  }
@Test public void usesParameterOrderFromRestRequestConfiguration() throws Exception { RestRequestConfig requestConfig = buildRestRequestConfigWithParameters("first", "second", "third"); RestMethod method = buildRestMethodWithParameters("third", "second", "first"); RestRequest restRequest = new RestRequest(method, requestConfig, false); List<String> parameterNameList = Arrays.asList(restRequest.getPropertyNames()); assertThat(parameterNameList, is(Arrays.asList("first", "second", "third"))); }
@Test public void removesNonExistentParameterFromOrderedList() throws Exception { RestRequestConfig requestConfig = buildRestRequestConfigWithParameters("first", "second", "third"); RestMethod method = buildRestMethodWithParameters("third", "first"); RestRequest restRequest = new RestRequest(method, requestConfig, false); List<String> parameterNameList = Arrays.asList(restRequest.getPropertyNames()); assertThat(parameterNameList, is(Arrays.asList("first", "third"))); }
@Test public void addsNewParameterToOrderedList() throws Exception { RestRequestConfig requestConfig = buildRestRequestConfigWithParameters("first", "second", "third"); RestMethod method = buildRestMethodWithParameters("third", "second", "newOne", "first"); RestRequest restRequest = new RestRequest(method, requestConfig, false); List<String> parameterNameList = Arrays.asList(restRequest.getPropertyNames()); assertThat(parameterNameList, is(Arrays.asList("first", "second", "third", "newOne"))); }