### Question:
BytesValues { public static int extractInt(BytesValue value) { int size = value.size(); checkArgument(size <= 4, "Cannot extract an int from a value of size %s > 4", size); if (size == 0) return 0; int res = 0; int shift = 0; for (int i = 0; i < size; i++) { res |= ((int) value.get(size - i - 1) & 0xFF) << shift; shift += 8; } return res; } private  BytesValues(); static int countZeros(BytesValue value); static BytesValue trimLeadingZeros(BytesValue value); static BytesValue toMinimalBytes(long l); static BytesValue ofUnsignedByte(int v); static BytesValue ofUnsignedShort(int v); static BytesValue ofUnsignedInt(long v); static BytesValue ofUnsignedIntLittleEndian(long v); static int extractInt(BytesValue value); static int extractIntLittleEndian(BytesValue value); static long extractLong(BytesValue value); static BytesValue concatenate(BytesValue... values); static BigInteger asUnsignedBigInteger(BytesValue bytes); static String asString(BytesValue bytes); static BigInteger asSignedBigInteger(BytesValue bytes); static BytesValue and(BytesValue b1, BytesValue b2); static BytesValue or(BytesValue b1, BytesValue b2);  }### Answer:
@Test public void hexToInteger() { assertEquals(0, extractInt(h("0x"))); assertEquals(0, extractInt(h("0x00"))); assertEquals(0, extractInt(h("0x00000000"))); assertEquals(1, extractInt(h("0x01"))); assertEquals(1, extractInt(h("0x0001"))); assertEquals(1, extractInt(h("0x000001"))); assertEquals(1, extractInt(h("0x00000001"))); assertEquals(256, extractInt(h("0x0100"))); assertEquals(256, extractInt(h("0x000100"))); assertEquals(256, extractInt(h("0x00000100"))); assertEquals(-1, extractInt(h("0xFFFFFFFF"))); }
@Test public void hexToIntegerInvalid() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("Cannot extract an int"); extractInt(h("0x0100000000")); }