### Question:
SiteMapUrlBuilderImpl implements SiteMapUrlBuilder { @Override public int getIndex(final SlingHttpServletRequest request) { final String[] selectors = request.getRequestPathInfo().getSelectors(); if (isNull(selectors) || selectors.length <= 1) { return 0; } final String selector = selectors[1]; if (isBlank(selector)) { return 0; } if (isNumeric(selector)) { return Integer.parseInt(selector); } return -1; }  @Override String buildSiteMapUrl(final Resource root, final int index); @Override int getIndex(final SlingHttpServletRequest request);  }### Answer:
@Test public void getIndex() { when(requestPathInfo.getExtension()).thenReturn(SiteMapConstants.XML); setSelectors((String[])null); assertEquals(0, model.getIndex(request)); setSelectorsString("sitemap"); assertEquals(0, model.getIndex(request)); setSelectorsString("sitemap.0"); assertEquals(0, model.getIndex(request)); setSelectorsString("sitemap.1"); assertEquals(1, model.getIndex(request)); setSelectorsString("sitemap.x"); assertEquals(-1, model.getIndex(request)); setSelectorsString("sitemap..x"); assertEquals(0, model.getIndex(request)); }