### Question:
NumberGenerator { public BigInteger generate(BigInteger min, BigInteger max){ if (min.compareTo(max) == 1) { throw new IllegalArgumentException("Max must be greater than min"); } BigInteger range = max.subtract(min); BigInteger num = new BigInteger(range.bitLength(), new SecureRandom()); if (num.compareTo(range) == 1) { num = num.mod(range); } num = num.add(min); return num; }  BigInteger generate(BigInteger min, BigInteger max); BigInteger generate(String min, String max); BigInteger generate(int digits);  }### Answer:
@Test public void testNumberGenerator(){ NumberGenerator numberGenerator = new NumberGenerator(); BigInteger number; for (int i = 0;i<500;i++) { number = numberGenerator.generate(10); Assert.assertNotNull(number); int comp = number.compareTo(new BigInteger("999999999")); int comp2 = number.compareTo(new BigInteger("10000000001")); Assert.assertTrue(comp == 1); Assert.assertTrue(comp2 == -1); } }
@Test public void testException(){ NumberGenerator gen = new NumberGenerator(); try{ gen.generate("4000","500"); }catch(IllegalArgumentException e) { return; } Assert.fail("Illegal Argument Exception was not thrown"); }