### Question:
HashUnit { public static int scale(int value, int min, int max) { return (int) (((long) value - min) * ((long) Integer.MAX_VALUE + 1 - Integer.MIN_VALUE) / ((long) max + 1 - min) + Integer.MIN_VALUE); } @JsonCreator  HashUnit(@JsonProperty("from") int from, @JsonProperty("to") int to); static int scale(int value, int min, int max); @JsonProperty("from") int from(); @JsonProperty("to") int to(); @JsonProperty("id") String id(); @Override String toString(); static Stream<HashUnit> covering(int n); @JsonIgnore boolean covers(int hash); @Override boolean equals(Object o); @Override int hashCode(); boolean isEmpty(); static final HashUnit EMPTY; }### Answer:
@Test public void testScale() { assertEquals(Integer.MIN_VALUE, HashUnit.scale(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)); assertEquals(Integer.MAX_VALUE, HashUnit.scale(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE)); assertEquals(Integer.MIN_VALUE, HashUnit.scale(0, 0, 0)); assertEquals(Integer.MAX_VALUE, HashUnit.scale(1, 0, 0) - 1); }