Search in sources :

Example 1 with TestPropertyKey

use of com.synopsys.integration.alert.test.common.TestPropertyKey in project hub-alert by blackducksoftware.

the class TestPropertiesFileGenerator method generatePropertiesFile.

@Test
@Disabled("This test is to generate the test.properties for new developers.")
public void generatePropertiesFile() throws IOException {
    Path propertiesFilePath = TestResourceUtils.createTestPropertiesCanonicalFilePath();
    System.out.println("Generating file: " + propertiesFilePath + "..");
    File testPropertiesFile = propertiesFilePath.toFile();
    if (!testPropertiesFile.exists()) {
        boolean successfullyCreated = testPropertiesFile.createNewFile();
        if (!successfullyCreated) {
            System.out.println("There was a problem creating the file '" + propertiesFilePath + "'.");
            return;
        }
        StringBuilder dataBuilder = new StringBuilder();
        for (TestPropertyKey propertyKey : TestPropertyKey.values()) {
            dataBuilder.append(propertyKey.getPropertyKey());
            dataBuilder.append('=');
            dataBuilder.append(System.lineSeparator());
        }
        FileUtils.write(testPropertiesFile, dataBuilder.toString(), Charset.defaultCharset(), false);
    } else {
        System.out.println("The file '" + propertiesFilePath + "' already exists, please rename or back it up.");
    }
}
Also used : Path(java.nio.file.Path) TestPropertyKey(com.synopsys.integration.alert.test.common.TestPropertyKey) File(java.io.File) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

TestPropertyKey (com.synopsys.integration.alert.test.common.TestPropertyKey)1 File (java.io.File)1 Path (java.nio.file.Path)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1