<commit_before>package org.smoothbuild.testing.common;

import static okio.Okio.sink;
import static org.smoothbuild.eval.artifact.FileStruct.fileContent;
import static org.smoothbuild.eval.artifact.FileStruct.filePath;

import java.io.IOException;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;

import org.smoothbuild.bytecode.obj.val.BlobB;
import org.smoothbuild.bytecode.obj.val.TupleB;
import org.smoothbuild.testing.TestingContext;

import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;

public class JarTester {
  public static BlobB jar(TupleB... files) throws IOException {
    return new TestingContext().blobB(jarByteString(files));
  }

  public static ByteString jarByteString(TupleB... files) throws IOException {
    Buffer buffer = new Buffer();
    try (JarOutputStream jarOutputStream = new JarOutputStream(buffer.outputStream())) {
      for (TupleB file : files) {
        addEntry(jarOutputStream, file);
      }
    }

    ByteString bytes = buffer.readByteString();
    return bytes;
  }

  private static void addEntry(JarOutputStream jarOutputStream, TupleB file) throws IOException {
    JarEntry entry = new JarEntry(filePath(file).toJ());
    jarOutputStream.putNextEntry(entry);
    try (BufferedSource source = fileContent(file).source()) {
      source.readAll(sink(jarOutputStream));
    }
    jarOutputStream.closeEntry();
  }
}<commit_msg>refactored JarTester<commit_after>package org.smoothbuild.testing.common;

import static okio.Okio.sink;
import static org.smoothbuild.eval.artifact.FileStruct.fileContent;
import static org.smoothbuild.eval.artifact.FileStruct.filePath;

import java.io.IOException;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;

import org.smoothbuild.bytecode.obj.val.BlobB;
import org.smoothbuild.bytecode.obj.val.TupleB;
import org.smoothbuild.testing.TestingContext;

import okio.Buffer;
import okio.BufferedSource;
import okio.ByteString;

public class JarTester {
  public static BlobB jar(TupleB... files) throws IOException {
    return new TestingContext().blobB(jarByteString(files));
  }

  public static ByteString jarByteString(TupleB... files) throws IOException {
    Buffer buffer = new Buffer();
    try (JarOutputStream jarOutputStream = new JarOutputStream(buffer.outputStream())) {
      for (TupleB file : files) {
        addEntry(jarOutputStream, file);
      }
    }

    return buffer.readByteString();
  }

  private static void addEntry(JarOutputStream jarOutputStream, TupleB file) throws IOException {
    JarEntry entry = new JarEntry(filePath(file).toJ());
    jarOutputStream.putNextEntry(entry);
    try (BufferedSource source = fileContent(file).source()) {
      source.readAll(sink(jarOutputStream));
    }
    jarOutputStream.closeEntry();
  }
}
{'fraction_non_alphanumeric': 0.10346057795219407, 'fraction_numerical': 0.0, 'mean_word_length': 4.653225806451613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4370436', 'n_tokens_mistral': 834, 'n_tokens_neox': 810, 'n_words': 176}