### Question:
PageIndexNamingCriterion implements NamingCriterion { @Override public String getDocumentName(XDOM newDoc) { int newIndex = ++index; String newDocumentName = baseDocumentName + INDEX_SEPERATOR + newIndex; int localIndex = 0; while (docBridge.exists(newDocumentName)) { newDocumentName = baseDocumentName + INDEX_SEPERATOR + newIndex + INDEX_SEPERATOR + (++localIndex); } return newDocumentName; } PageIndexNamingCriterion(String baseDocumentName, DocumentAccessBridge docBridge); @Override String getDocumentName(XDOM newDoc);  }### Answer:
@Test public void testDocumentNamesGeneration() throws Exception { XDOM xdom = xwikiParser.parse(new StringReader("=Test=")); NamingCriterion namingCriterion = new PageIndexNamingCriterion("Main.Test", docBridge); for (int i = 1; i < 10; i++) { Assert.assertEquals("Main.Test-" + i, namingCriterion.getDocumentName(xdom)); } }