* The algorithm in ParameterComparator assures that parameters will be
* ordered as defined in the parameterOrder list, then alphabetically, even
* when the parameter map returns the keys in an incorrect order.
*/
public void testParameterComparator() {
ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
Schema a = EasyMock.createControl().createMock(Schema.class);
Schema b = EasyMock.createControl().createMock(Schema.class);
Schema reqA = EasyMock.createControl().createMock(Schema.class);
Schema reqB = EasyMock.createControl().createMock(Schema.class);
// Using a SortedMap so that the keys can be guaranteed to be returned in a
// known unsorted order.
EasyMock.expect(method.getParameters()).andReturn(
ImmutableSortedMap.of("b", b, "req-a", reqA, "a", a, "req-b", reqB));
EasyMock.expect(method.getParameterOrder()).andReturn(ImmutableList.of("req-b", "req-a"));
EasyMock.replay(method);
assertEquals(ImmutableSortedSet.of("req-b", "req-a", "a", "b"), ImmutableSortedMap.copyOf(
method.getParameters(), new ParameterComparator(method.getParameterOrder())).keySet());
EasyMock.verify(method);
}