@Override
    public void upgrade() {
        final MigrationCompleted migrationCompleted = configService.get(MigrationCompleted.class);

        if (migrationCompleted != null) {
            log.debug("Migration already completed.");
            return;
        }

        UrlWhitelist whitelist = createWhitelist();
        whitelistService.saveWhitelist(whitelist);
        configService.write(MigrationCompleted.create(whitelist.toString()));
    }
@Test
    public void createQuotedRegexEntry() {
        final HTTPJSONPathDataAdapter.Config config = mock(HTTPJSONPathDataAdapter.Config.class);
        when(config.url()).thenReturn("https://www.graylog.com/${key}/test.json/${key}");
        final DataAdapterDto dataAdapterDto = mock(DataAdapterDto.class);
        when(dataAdapterDto.config()).thenReturn(config);
        when(dataAdapterService.findAll()).thenReturn(Collections.singleton(dataAdapterDto));

        migration.upgrade();

        final ArgumentCaptor<UrlWhitelist> captor = ArgumentCaptor.forClass(UrlWhitelist.class);
        verify(whitelistService).saveWhitelist(captor.capture());

        final UrlWhitelist whitelist = captor.getValue();

        final String whitelisted = "https://www.graylog.com/message/test.json/message";
        final String notWhitelisted = "https://wwwXgraylogXcom/message/testXjson/messsage";

        assertThat(whitelist.isWhitelisted(whitelisted)).withFailMessage(
                "Whitelist " + whitelist + " is expected to consider url <" + whitelisted + "> whitelisted.")
                .isTrue();
        assertThat(whitelist.isWhitelisted(notWhitelisted)).withFailMessage(
                "Whitelist " + whitelist + " is expected to consider url <" + notWhitelisted + "> not whitelisted.")
                .isFalse();
        assertThat(whitelist.entries()
                .size()).isEqualTo(1);
        assertThat(whitelist.entries()
                .get(0)
                .value()).isEqualTo("^\\Qhttps://www.graylog.com/\\E.*?\\Q/test.json/\\E.*?$");
    }