### Question:
Shamir { @Nonnull public BigInteger recoverSecret(@Nonnull final Set<Share> shares, @Nonnull final RecoveryScheme recoveryScheme) { return rxShamir.recoverSecret(shares, recoveryScheme).blockingGet(); } Shamir(@Nonnull final SecureRandom random); @Nonnull static Shamir create(@Nonnull final SecureRandom random); @Nonnull Set<Share> createShares(@Nonnull final BigInteger secret, @Nonnull final CreationScheme creationScheme); @Nonnull BigInteger recoverSecret(@Nonnull final Set<Share> shares, @Nonnull final RecoveryScheme recoveryScheme);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testRecoverSecret_nullShares() { final RecoveryScheme recoveryScheme = RecoveryScheme .builder() .setRequiredShareCount(2) .setPrime(7) .build(); shamir.recoverSecret(null, recoveryScheme); }
@Test(expected = IllegalArgumentException.class) public void testRecoverSecret_nullRecoveryScheme() { final Set<Share> shares = ImmutableSet .<Share>builder() .add(Share.builder().setIndex(1).setValue(1).build()) .add(Share.builder().setIndex(1).setValue(2).build()) .build(); shamir.recoverSecret(shares, null); }
@Test(expected = IllegalArgumentException.class) public void testRecoverSecret_sharesContainsNull() { final Set<Share> shares = new HashSet<>(); shares.add(Share.builder().setIndex(1).setValue(1).build()); shares.add(null); final RecoveryScheme recoveryScheme = RecoveryScheme .builder() .setRequiredShareCount(2) .setPrime(7) .build(); shamir.recoverSecret(shares, recoveryScheme); }
@Test(expected = IllegalStateException.class) public void testRecoverSecret_duplicateShareIndex() { final Set<Share> shares = ImmutableSet .<Share>builder() .add(Share.builder().setIndex(1).setValue(1).build()) .add(Share.builder().setIndex(1).setValue(2).build()) .build(); final RecoveryScheme recoveryScheme = RecoveryScheme .builder() .setRequiredShareCount(2) .setPrime(7) .build(); shamir.recoverSecret(shares, recoveryScheme); }