<commit_before>/*
 * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.wso2.identity.integration.test.user.mgt.uuid;

import org.apache.commons.io.filefilter.RegexFileFilter;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.common.utils.ISIntegrationTest;

import java.io.File;
import java.io.FileFilter;

public class UUIDUserManagerInitializerTestCase extends ISIntegrationTest {

    private File uuidServiceJar;

    @BeforeTest(alwaysRun = true)
    public void initTest() throws Exception {

        super.init();

        uuidServiceJar = getServiceJar();

        ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(isServer);
        serverConfigurationManager.copyToComponentDropins(uuidServiceJar);
        serverConfigurationManager.restartGracefully();
    }

    private File getServiceJar() throws Exception {

        File directory = new File(getISResourceLocation() + File.separator + "userMgt");

        String pattern = "^(\\w*\\W)*(test\\.integration\\.service)(\\w*\\W)*(jar)";
        FileFilter filter = new RegexFileFilter(pattern);
        File [] files = directory.listFiles(filter);

        if (files == null || files.length == 0) {
            throw new Exception("Cannot find the services JAR file.");
        }

        return files[0];
    }

    @AfterTest
    public void deInitTest() throws Exception {

        ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(isServer);
        serverConfigurationManager.removeFromComponentDropins(uuidServiceJar.getName());
    }
}<commit_msg>Add logs related to test initializing.<commit_after>/*
 * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 *  WSO2 Inc. licenses this file to you under the Apache License,
 *  Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.wso2.identity.integration.test.user.mgt.uuid;

import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.wso2.carbon.integration.common.utils.mgt.ServerConfigurationManager;
import org.wso2.identity.integration.common.utils.ISIntegrationTest;

import java.io.File;
import java.io.FileFilter;

public class UUIDUserManagerInitializerTestCase extends ISIntegrationTest {

    private static final Log log = LogFactory.getLog(UUIDUserManagerInitializerTestCase.class);
    private File uuidServiceJar;

    @BeforeTest(alwaysRun = true)
    public void initTest() throws Exception {

        log.info("Initializing UUID User manager initializer test case.");
        super.init();

        uuidServiceJar = getServiceJar();
        log.info("Copying the service jar to the dropins folder before restarting the server.");

        ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(isServer);
        serverConfigurationManager.copyToComponentDropins(uuidServiceJar);
        serverConfigurationManager.restartGracefully();
    }

    private File getServiceJar() throws Exception {

        File directory = new File(getISResourceLocation() + File.separator + "userMgt");

        String pattern = "^(\\w*\\W)*(test\\.integration\\.service)(\\w*\\W)*(jar)";
        FileFilter filter = new RegexFileFilter(pattern);
        File [] files = directory.listFiles(filter);

        if (files == null || files.length == 0) {
            log.error("Unable to find the services JAR file.");
            throw new Exception("Cannot find the services JAR file.");
        }

        return files[0];
    }

    @AfterTest
    public void deInitTest() throws Exception {

        ServerConfigurationManager serverConfigurationManager = new ServerConfigurationManager(isServer);
        serverConfigurationManager.removeFromComponentDropins(uuidServiceJar.getName());
    }
}
{'fraction_non_alphanumeric': 0.09433962264150944, 'fraction_numerical': 0.0061609549480169425, 'mean_word_length': 3.7660550458715596, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7327912', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1348, 'n_words': 403}