// Path: java/core/src/main/java/eu/mais_h/mathsync/digest/Digester.java
// public interface Digester {
// 
//   /**
//    * Digests an item serialized as an array of bytes.
//    *
//    * <p>Any byte array value must be accepted and have a non <code>null</code> return value: for any <code>a</code>,
//    * <code>digest(a) != null</code>.</p>
//    *
//    * <p>All valid inputs should produce in output an array of the same size:for any <code>a1</code> and
//    * <code>a2</code>, <code>digest(a1).length == digest(a2).length</code>.</p>
//    *
//    * <p>The output must be consistent, an identical output should be returned if called twice on the same array: for
//    * any <code>a1</code> and <code>a2</code>, <code>Arrays.equals(a1, a2)</code> implies
//    * <code>Arrays.equals(digest(a1), digest(a2))</code>.</p>
//    *
//    * <p>In addition to those constrains, it is recommended that it has the properties of a
//    * <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function">cryptographic hash function</a>.</p>
//    *
//    * @param source the item serialized as an array of bytes.
//    * @return the message digest of the item.
//    * @throws IllegalArgumentException if the input array is <code>null</code>.
//    */
//   byte[] digest(byte[] source);
// }


import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
import java.util.Arrays;
import java.util.HashSet;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
import eu.mais_h.mathsync.digest.Digester;
    }
  }

  @Test
  public void returns_indexes_taken_from_padded_hash() {
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)10
    }))).thenReturn(new byte[] {
      (byte)0, (byte)0, (byte)0, (byte)2,
      (byte)0, (byte)0, (byte)0, (byte)3,
      (byte)0, (byte)0, (byte)0, (byte)4,
      (byte)0, (byte)0, (byte)0, (byte)5
    });

    int[] selected = selector.selectBuckets(10, new byte[] { (byte)5 });

    assertSelectedEquals(selected, 2, 3, 4);
  }

  @Test
  public void increments_on_pad_until_enough_bytes_are_generated() {
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)10
    }))).thenReturn(new byte[] {
      (byte)0, (byte)0, (byte)0, (byte)2,
      (byte)0, (byte)0, (byte)0, (byte)3
    });
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)11
    }))).thenReturn(new byte[] {
// Path: java/core/src/main/java/eu/mais_h/mathsync/digest/Digester.java
// public interface Digester {
// 
//   /**
//    * Digests an item serialized as an array of bytes.
//    *
//    * <p>Any byte array value must be accepted and have a non <code>null</code> return value: for any <code>a</code>,
//    * <code>digest(a) != null</code>.</p>
//    *
//    * <p>All valid inputs should produce in output an array of the same size:for any <code>a1</code> and
//    * <code>a2</code>, <code>digest(a1).length == digest(a2).length</code>.</p>
//    *
//    * <p>The output must be consistent, an identical output should be returned if called twice on the same array: for
//    * any <code>a1</code> and <code>a2</code>, <code>Arrays.equals(a1, a2)</code> implies
//    * <code>Arrays.equals(digest(a1), digest(a2))</code>.</p>
//    *
//    * <p>In addition to those constrains, it is recommended that it has the properties of a
//    * <a href="http://en.wikipedia.org/wiki/Cryptographic_hash_function">cryptographic hash function</a>.</p>
//    *
//    * @param source the item serialized as an array of bytes.
//    * @return the message digest of the item.
//    * @throws IllegalArgumentException if the input array is <code>null</code>.
//    */
//   byte[] digest(byte[] source);
// }


// Path: java/core/src/test/java/eu/mais_h/mathsync/PadAndHashBucketSelectorTest.java
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
import java.util.Arrays;
import java.util.HashSet;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
import eu.mais_h.mathsync.digest.Digester;

    }
  }

  @Test
  public void returns_indexes_taken_from_padded_hash() {
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)10
    }))).thenReturn(new byte[] {
      (byte)0, (byte)0, (byte)0, (byte)2,
      (byte)0, (byte)0, (byte)0, (byte)3,
      (byte)0, (byte)0, (byte)0, (byte)4,
      (byte)0, (byte)0, (byte)0, (byte)5
    });

    int[] selected = selector.selectBuckets(10, new byte[] { (byte)5 });

    assertSelectedEquals(selected, 2, 3, 4);
  }

  @Test
  public void increments_on_pad_until_enough_bytes_are_generated() {
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)10
    }))).thenReturn(new byte[] {
      (byte)0, (byte)0, (byte)0, (byte)2,
      (byte)0, (byte)0, (byte)0, (byte)3
    });
    Mockito.when(digester.digest(Matchers.eq(new byte[] {
      (byte)5, (byte)0, (byte)0, (byte)0, (byte)11
    }))).thenReturn(new byte[] {
      (byte)0, (byte)0, (byte)0, (byte)4,