### Question:
IndexingManager { public synchronized void restartIndexing() { stopIndexing(); try { registry.delete(getLastAccessTimeLocation()); } catch (RegistryException e) { log.error("Could not delete last activity time to restart indexing", e); } startIndexing(); } private  IndexingManager(); static IndexingManager getInstance(); synchronized void startIndexing(); synchronized void restartIndexing(); synchronized void stopIndexing(); long getStartingDelayInSecs(); boolean canIndex(String path); long getIndexingFreqInSecs(); String getLastAccessTimeLocation(); long getBatchSize(); int getIndexerPoolSize(); boolean isCacheSkipped(); void deleteFromIndex(String oldPath, int tenantId); void submitFileForIndexing(int tenantID, String tenantDomain, String path,
            String sourceURL); Indexer getIndexerForMediaType(String mimeType); UserRegistry getRegistry(int tenantId); Date getLastAccessTime(int tenantId); void setLastAccessTime(int tenantId, Date lastAccessTime);  }### Answer:
@Test public void testRestartIndexing() throws RegistryException { UserRegistry userRegistry = mock(UserRegistry.class); Long lastAccessTime = Calendar.getInstance().getTimeInMillis(); ResourceImpl resource = new ResourceImpl(); resource.setPath(lastAccessPath); resource.setCreatedTime(Calendar.getInstance().getTime()); resource.setProperty("1", String.valueOf(lastAccessTime)); resource.setProperty("-1234", String.valueOf(lastAccessTime)); resource.setProperty("2", String.valueOf(lastAccessTime)); when(userRegistry.get(lastAccessPath)).thenReturn(resource); doNothing().when(userRegistry).delete(lastAccessPath); when(userRegistry.newResource()).thenReturn(resource); RegistryService registryService = mock(RegistryService.class); when(userRegistry.resourceExists(lastAccessPath)).thenReturn(true); when(registryService.getRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME)).thenReturn(userRegistry); Utils.setRegistryService(registryService); final Resource[] finalResources = new Resource[1]; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocationOnMock) throws Throwable { Object[] args = invocationOnMock.getArguments(); finalResources[0] = (Resource)args[1]; return null; } }).when(userRegistry).put(anyString(), (Resource)anyObject()); IndexingManager manager = IndexingManager.getInstance(); Date currentDate = Calendar.getInstance().getTime(); manager.setLastAccessTime(100, currentDate); manager.restartIndexing(); assertEquals(1, finalResources.length); assertEquals(currentDate.getTime(), Long.parseLong(finalResources[0].getProperty("100"))); }