### Question:
RefactoringScriptService implements ScriptService { public Job convertToNestedDocument(DocumentReference documentReference) { String defaultDocName = this.defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT).getName(); if (!documentReference.getName().equals(defaultDocName)) { SpaceReference spaceReference = new SpaceReference(documentReference.getName(), documentReference.getParent()); return rename(documentReference, new DocumentReference(defaultDocName, spaceReference)); } return null; }  RequestFactory getRequestFactory(); Job move(MoveRequest request); Job move(Collection<EntityReference> sources, EntityReference destination); Job move(EntityReference source, EntityReference destination); Job rename(MoveRequest request); Job rename(EntityReference oldReference, EntityReference newReference); Job rename(EntityReference reference, String newName); Job convertToNestedDocument(DocumentReference documentReference); Job convertToTerminalDocument(DocumentReference documentReference); Job copy(CopyRequest request); Job copy(Collection<EntityReference> sources, EntityReference destination); Job copy(EntityReference source, EntityReference destination); Job copyAs(CopyRequest request); Job copyAs(EntityReference sourceReference, EntityReference copyReference); Job copyAs(EntityReference reference, String copyName); Job delete(EntityRequest request); Job delete(Collection<EntityReference> entityReferences); Job delete(EntityReference entityReference); Job create(CreateRequest request); Job create(Collection<EntityReference> entityReferences); Job create(EntityReference entityReference); Exception getLastError(); Job restore(RestoreRequest restoreRequest); Job restore(String batchId); Job restore(List<Long> deletedDocumentIds); Job permanentlyDelete(PermanentlyDeleteRequest request); Job permanentlyDelete(String batchId); Job permanentlyDelete(List<Long> deletedDocumentIds); @Unstable Job changeDocumentAuthor(DocumentReference oldAuthorReference, DocumentReference newAuthorReference); @Unstable Job replaceUser(ReplaceUserRequest request); @Unstable boolean isRecycleBinSkippingAllowed();  }### Answer:
@Test void convertToNestedDocumentAlreadyNested() { DocumentReference nestedDocumentReference = new DocumentReference("code", Arrays.asList("Model", "Entity"), "WebHome"); assertNull(this.refactoringScriptService.convertToNestedDocument(nestedDocumentReference)); }
@Test void convertToNestedDocument() throws Exception { DocumentReference terminalDocumentReference = new DocumentReference("code", "Model", "Entity"); DocumentReference nestedDocumentReference = new DocumentReference("code", Arrays.asList("Model", "Entity"), "WebHome"); MoveRequest moveRequest = new MoveRequest(); this.fillCopyOrMoveRequest(moveRequest); when(this.requestFactory.createRenameRequest(terminalDocumentReference, nestedDocumentReference)) .thenReturn(moveRequest); this.refactoringScriptService.convertToNestedDocument(terminalDocumentReference); verify(this.requestFactory).createRenameRequest(terminalDocumentReference, nestedDocumentReference); verify(this.jobExecutor).execute(RefactoringJobs.RENAME, moveRequest); }