package jetbrains.buildserver.sonarplugin;

import com.intellij.util.ThrowableConsumer;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

public final class TestTools {
    private TestTools() {
    }

    public static Path prepareZip(@NotNull final Path parent,
                                  @NotNull final String name,
                                  @NotNull final ThrowableConsumer<FileSystem, IOException> consumer) throws IOException {
        Path zip = parent.resolve(name);

        Files.createDirectories(parent);
        Files.deleteIfExists(zip);
        Files.createFile(zip);
        // write empty zip file
        Files.write(zip, new byte[]{0x50, 0x4B, 0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});

        try (final FileSystem zipFs = FileSystems.newFileSystem(zip, null)) {
            consumer.consume(zipFs);
        }
        return zip;
    }
}

@@ -273,16 +273,41 @@
 le.Path;
+%0Aimport java.util.Arrays;
 %0A%0Apublic
@@ -1113,11 +1113,409 @@
 p;%0A    %7D
+%0A%0A    public static Path createFile(@NotNull final Path file) throws IOException %7B%0A        Files.createDirectories(file.getParent());%0A        return Files.createFile(file);%0A    %7D%0A%0A    public static Path fromZipString(@NotNull final FileSystem fs, @NotNull final String path) %7B%0A        final String%5B%5D split = path.split(%22/%22);%0A        return fs.getPath(%22/%22, Arrays.copyOf(split, split.length));%0A    %7D
 %0A%7D%0A

Add tools