// Path: generator/src/main/java/com/google/archivepatcher/generator/ByteArrayHolder.java
// public class ByteArrayHolder {
//   /**
//    * The backing byte array.
//    */
//   private final byte[] data;
// 
//   /**
//    * Construct a new wrapper around the specified bytes.
//    * @param data the byte array
//    */
//   public ByteArrayHolder(byte[] data) {
//     this.data = data;
//   }
// 
//   /**
//    * Returns the actual byte array that backs the text.
//    * @return the array
//    */
//   public byte[] getData() {
//     return data;
//   }
// 
//   @Override
//   public int hashCode() {
//     final int prime = 31;
//     int result = 1;
//     result = prime * result + Arrays.hashCode(data);
//     return result;
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (this == obj) return true;
//     if (obj == null) return false;
//     if (getClass() != obj.getClass()) return false;
//     ByteArrayHolder other = (ByteArrayHolder) obj;
//     if (!Arrays.equals(data, other.data)) return false;
//     return true;
//   }
// }


import com.google.archivepatcher.generator.ByteArrayHolder;
import com.google.archivepatcher.generator.RecommendationReason;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
  @Test
  public void testConstructor_Simple() {
    PatchExplanation patchExplanation = new PatchExplanation(ALL_EXPLANATIONS);
    Assert.assertEquals(EXPECTED_NEW_EXPLANATIONS, patchExplanation.getExplainedAsNew());
    Assert.assertEquals(EXPECTED_CHANGED_EXPLANATIONS, patchExplanation.getExplainedAsChanged());
    Assert.assertEquals(
        EXPECTED_UNCHANGED_OR_FREE_EXPLANATIONS, patchExplanation.getExplainedAsUnchangedOrFree());
    Assert.assertEquals(EXPECTED_NEW_SIZE, patchExplanation.getEstimatedNewSize());
    Assert.assertEquals(EXPECTED_CHANGED_SIZE, patchExplanation.getEstimatedChangedSize());
  }

  @Test
  public void testConstructor_Reversed() {
    List<EntryExplanation> reversed = new ArrayList<>(ALL_EXPLANATIONS);
    Collections.reverse(reversed);
    PatchExplanation patchExplanation = new PatchExplanation(reversed);
    // Order should remaining the same despite reversing the inputs.
    Assert.assertEquals(EXPECTED_NEW_EXPLANATIONS, patchExplanation.getExplainedAsNew());
    Assert.assertEquals(EXPECTED_CHANGED_EXPLANATIONS, patchExplanation.getExplainedAsChanged());
    Assert.assertEquals(
        EXPECTED_UNCHANGED_OR_FREE_EXPLANATIONS, patchExplanation.getExplainedAsUnchangedOrFree());
    Assert.assertEquals(EXPECTED_NEW_SIZE, patchExplanation.getEstimatedNewSize());
    Assert.assertEquals(EXPECTED_CHANGED_SIZE, patchExplanation.getEstimatedChangedSize());
  }

  @Test
  public void testToJson() throws IOException {
    // We lack a proper JSON parser in the vanilla JRE so short of string matching there's nothing
    // that can be done here other than to ensure the output is non-null and looks kind of sane.
    PatchExplanation patchExplanation = new PatchExplanation(ALL_EXPLANATIONS);
// Path: generator/src/main/java/com/google/archivepatcher/generator/ByteArrayHolder.java
// public class ByteArrayHolder {
//   /**
//    * The backing byte array.
//    */
//   private final byte[] data;
// 
//   /**
//    * Construct a new wrapper around the specified bytes.
//    * @param data the byte array
//    */
//   public ByteArrayHolder(byte[] data) {
//     this.data = data;
//   }
// 
//   /**
//    * Returns the actual byte array that backs the text.
//    * @return the array
//    */
//   public byte[] getData() {
//     return data;
//   }
// 
//   @Override
//   public int hashCode() {
//     final int prime = 31;
//     int result = 1;
//     result = prime * result + Arrays.hashCode(data);
//     return result;
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (this == obj) return true;
//     if (obj == null) return false;
//     if (getClass() != obj.getClass()) return false;
//     ByteArrayHolder other = (ByteArrayHolder) obj;
//     if (!Arrays.equals(data, other.data)) return false;
//     return true;
//   }
// }


// Path: explainer/src/test/java/com/google/archivepatcher/explainer/PatchExplanationTest.java
import com.google.archivepatcher.generator.ByteArrayHolder;
import com.google.archivepatcher.generator.RecommendationReason;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

  @Test
  public void testConstructor_Simple() {
    PatchExplanation patchExplanation = new PatchExplanation(ALL_EXPLANATIONS);
    Assert.assertEquals(EXPECTED_NEW_EXPLANATIONS, patchExplanation.getExplainedAsNew());
    Assert.assertEquals(EXPECTED_CHANGED_EXPLANATIONS, patchExplanation.getExplainedAsChanged());
    Assert.assertEquals(
        EXPECTED_UNCHANGED_OR_FREE_EXPLANATIONS, patchExplanation.getExplainedAsUnchangedOrFree());
    Assert.assertEquals(EXPECTED_NEW_SIZE, patchExplanation.getEstimatedNewSize());
    Assert.assertEquals(EXPECTED_CHANGED_SIZE, patchExplanation.getEstimatedChangedSize());
  }

  @Test
  public void testConstructor_Reversed() {
    List<EntryExplanation> reversed = new ArrayList<>(ALL_EXPLANATIONS);
    Collections.reverse(reversed);
    PatchExplanation patchExplanation = new PatchExplanation(reversed);
    // Order should remaining the same despite reversing the inputs.
    Assert.assertEquals(EXPECTED_NEW_EXPLANATIONS, patchExplanation.getExplainedAsNew());
    Assert.assertEquals(EXPECTED_CHANGED_EXPLANATIONS, patchExplanation.getExplainedAsChanged());
    Assert.assertEquals(
        EXPECTED_UNCHANGED_OR_FREE_EXPLANATIONS, patchExplanation.getExplainedAsUnchangedOrFree());
    Assert.assertEquals(EXPECTED_NEW_SIZE, patchExplanation.getEstimatedNewSize());
    Assert.assertEquals(EXPECTED_CHANGED_SIZE, patchExplanation.getEstimatedChangedSize());
  }

  @Test
  public void testToJson() throws IOException {
    // We lack a proper JSON parser in the vanilla JRE so short of string matching there's nothing
    // that can be done here other than to ensure the output is non-null and looks kind of sane.
    PatchExplanation patchExplanation = new PatchExplanation(ALL_EXPLANATIONS);
    try (ByteArrayOutputStream buffer = new ByteArrayOutputStream();