Source:
<code><START> public void testSnapshotHidden() throws IOException { <END> String testRepository = "test"; String testSnapshot = "snapshot_1"; String testIndex = "test_index"; String restoredIndex = testIndex + "_restored"; AcknowledgedResponse putRepositoryResponse = createTestRepository(testRepository, FsRepository.TYPE, "{\"location\": \".\"}"); assertTrue(putRepositoryResponse.isAcknowledged()); createIndex(testIndex, Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1,3)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetadata.SETTING_INDEX_HIDDEN, true) .build()); assertTrue("index [" + testIndex + "] should have been created", indexExists(testIndex)); CreateSnapshotRequest createSnapshotRequest = new CreateSnapshotRequest(testRepository, testSnapshot); createSnapshotRequest.indices("*"); createSnapshotRequest.waitForCompletion(true); if (randomBoolean()) { createSnapshotRequest.userMetadata(randomUserMetadata()); } CreateSnapshotResponse createSnapshotResponse = createTestSnapshot(createSnapshotRequest); assertEquals(RestStatus.OK, createSnapshotResponse.status()); deleteIndex(testIndex); assertFalse("index [" + testIndex + "] should have been deleted", indexExists(testIndex)); RestoreSnapshotRequest request = new RestoreSnapshotRequest(testRepository, testSnapshot); request.waitForCompletion(true); request.renamePattern(testIndex); request.renameReplacement(restoredIndex); RestoreSnapshotResponse response = execute(request, highLevelClient().snapshot()::restore, highLevelClient().snapshot()::restoreAsync); RestoreInfo restoreInfo = response.getRestoreInfo(); assertThat(restoreInfo.name(), equalTo(testSnapshot)); assertThat(restoreInfo.indices(), equalTo(Collections.singletonList(restoredIndex))); assertThat(restoreInfo.successfulShards(), greaterThan(0)); assertThat(restoreInfo.failedShards(), equalTo(0)); }</code><technical_language>This test failed .security index restored (either deleted part of test auto re-created)</technical_language>

Target:
public void testSnapshotHidden() throws IOException { String testRepository = "test"; String testSnapshot = "snapshot_1"; String testIndex = "test_index"; AcknowledgedResponse putRepositoryResponse = createTestRepository(testRepository, FsRepository.TYPE, "{\"location\": \".\"}"); assertTrue(putRepositoryResponse.isAcknowledged()); createIndex(testIndex, Settings.builder() .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(1,3)) .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) .put(IndexMetadata.SETTING_INDEX_HIDDEN, true) .build()); assertTrue("index [" + testIndex + "] should have been created", indexExists(testIndex)); CreateSnapshotRequest createSnapshotRequest = new CreateSnapshotRequest(testRepository, testSnapshot); createSnapshotRequest.indices("*"); createSnapshotRequest.waitForCompletion(true); if (randomBoolean()) { createSnapshotRequest.userMetadata(randomUserMetadata()); } CreateSnapshotResponse createSnapshotResponse = createTestSnapshot(createSnapshotRequest); assertEquals(RestStatus.OK, createSnapshotResponse.status()); deleteIndex(testIndex); assertFalse("index [" + testIndex + "] should have been deleted", indexExists(testIndex)); RestoreSnapshotRequest request = new RestoreSnapshotRequest(testRepository, testSnapshot); request.waitForCompletion(true); request.indices(randomFrom(testIndex, "test_*")); request.renamePattern(testIndex); RestoreSnapshotResponse response = execute(request, highLevelClient().snapshot()::restore, highLevelClient().snapshot()::restoreAsync); RestoreInfo restoreInfo = response.getRestoreInfo(); assertThat(restoreInfo.name(), equalTo(testSnapshot)); assertThat(restoreInfo.indices(), equalTo(Collections.singletonList(testIndex))); assertThat(restoreInfo.successfulShards(), greaterThan(0)); assertThat(restoreInfo.failedShards(), equalTo(0)); }