assertEquals(mockService.getVersion(), apiResult.getService().getVersion());
}
/** Test that method names and descriptions get indexed correctly. */
public void testMethods() {
ApiMethod mockMethod = EasyMock.createMock(ApiMethod.class);
EasyMock.expect(mockMethod.getDescription()).andReturn("method description").anyTimes();
EasyMock.expect(mockMethod.getId()).andReturn("collection.methodName").anyTimes();
EasyMock.expect(mockMethod.getParameters()).andReturn(null).anyTimes();
ApiMethod mockMethod2 = EasyMock.createMock(ApiMethod.class);
EasyMock.expect(mockMethod2.getDescription()).andReturn("anotherMethod description").anyTimes();
EasyMock.expect(mockMethod2.getId()).andReturn("collection.anotherMethod").anyTimes();
EasyMock.expect(mockMethod2.getParameters()).andReturn(null).anyTimes();
EasyMock.expect(mockService.allMethods()).andReturn(ImmutableMap.of(
"collection.methodName", mockMethod, "collection.anotherMethod", mockMethod2));
EasyMock.replay(mockService, mockMethod, mockMethod2);
List<SearchEntry> entries = ImmutableList.copyOf(discoveryStrategy.index(mockService));
EasyMock.verify(mockService, mockMethod, mockMethod2);
assertEquals(3, entries.size());
// Extract the entries.
SearchEntry method1Entry = null;
SearchEntry method2Entry = null;
SearchEntry serviceEntry = null;
for (SearchEntry entry : entries) {
SearchResult result = entry.getSearchResult();
if (result.getKind() == Kind.SERVICE) {
serviceEntry = entry;
} else if (result.getKind() == Kind.METHOD) {
if (mockMethod.equals(result.getMethodBundle().getMethod())) {
method1Entry = entry;
} else if (mockMethod2.equals(result.getMethodBundle().getMethod())) {
method2Entry = entry;
} else {
fail("Unexpected method result: " + result.getMethodBundle().getMethod());
}
} else {