### Question:
SolrIndexScriptService implements ScriptService { public void index(EntityReference reference) { clearException(); try { checkAccessToWikiIndex(reference); this.solrIndexer.index(reference, true); } catch (Exception e) { error(e); } }  void index(EntityReference reference); void index(List<EntityReference> references); void delete(EntityReference reference); void delete(List<EntityReference> references); int getQueueSize(); DocumentReference resolveDocument(SolrDocument document, Object... parameters); EntityReference resolve(SolrDocument document, Object... parameters); EntityReference resolve(SolrDocument document, EntityType type, Object... parameters); static final String CONTEXT_LASTEXCEPTION; }### Answer:
@Test public void indexSingleReferenceChecksRights() throws Exception { EntityReference wikiReference = new WikiReference("someWiki"); this.service.index(wikiReference); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference); verify(this.mockAuthorization).checkAccess(Right.PROGRAM, this.contentAuthorReference, null); }
@Test public void indexMultipleReferencesChecksRights() throws Exception { EntityReference wikiReference = new WikiReference("someWiki"); this.service.index(Arrays.asList(wikiReference)); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference); verify(this.mockAuthorization).checkAccess(Right.PROGRAM, this.contentAuthorReference, null); }
@Test public void operationsChecksRightsWithOtherReferences() throws Exception { EntityReference documentReference = new DocumentReference("someWiki", "space", "document"); this.service.index(documentReference); EntityReference wikiReference = documentReference.extractReference(EntityType.WIKI); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference); verify(this.mockAuthorization).checkAccess(Right.PROGRAM, this.contentAuthorReference, null); }
@Test public void openrationsOnMultipleReferencesOnTheSameWikiChecksRightsOnlyOnceForThatWiki() throws Exception { WikiReference wikiReference = new WikiReference("wiki"); SpaceReference spaceReference = new SpaceReference("space", wikiReference); DocumentReference documentReference = new DocumentReference("wiki", "space", "name"); DocumentReference documentReference2 = new DocumentReference("wiki", "space", "name2"); this.service.index(Arrays.asList(wikiReference, spaceReference, documentReference, documentReference2)); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference); verify(this.mockAuthorization).checkAccess(Right.PROGRAM, this.contentAuthorReference, null); }
@Test public void openrationsOnMultipleReferencesOnDifferentWikisChecksRightsOnEachWiki() throws Exception { WikiReference wikiReference1 = new WikiReference("wiki"); SpaceReference spaceReference = new SpaceReference("space", wikiReference1); WikiReference wikiReference2 = new WikiReference("wiki2"); DocumentReference documentReference = new DocumentReference("wiki2", "space", "name"); WikiReference wikiReference3 = new WikiReference("wiki3"); DocumentReference documentReference2 = new DocumentReference("wiki3", "space", "name2"); this.service.index( Arrays.asList(wikiReference1, spaceReference, wikiReference2, documentReference, documentReference2)); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference1); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference2); verify(this.mockAuthorization).checkAccess(Right.ADMIN, this.userReference, wikiReference3); verify(this.mockAuthorization, times(3)).checkAccess(Right.PROGRAM, this.contentAuthorReference, null); }