### Question:
JsonRecoverySchemeSerialiser implements RecoverySchemeSerialiser { @Override @Nonnull public Single<String> serialise(@Nonnull final RecoveryScheme scheme) { checkNotNull(scheme, "\'scheme\' must not be null."); return Single.fromCallable(() -> { final String primeBase64Encoded = Base64.getEncoder().encodeToString(scheme.getPrime().toByteArray()); final JsonObject json = new JsonObject(); json.addProperty("requiredShareCount", scheme.getRequiredShareCount()); json.addProperty("prime", primeBase64Encoded); return json.toString(); }); }  @Override @Nonnull Single<String> serialise(@Nonnull final RecoveryScheme scheme); @Override @Nonnull Single<RecoveryScheme> deserialise(@Nonnull final String serialisedScheme); @Override @Nonnull Single<Boolean> isValidSerialisation(@Nonnull final String serialisedScheme);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void testSerialise_nullRecoveryScheme() { serialiser.serialise(null); }
@Test public void testSerialiseAndDeserialise() { final RecoveryScheme recoveryScheme = RecoveryScheme .builder() .setRequiredShareCount(2) .setPrime(7) .build(); serialiser .serialise(recoveryScheme) .flatMap(serialiser::deserialise) .test() .awaitDone(200, MILLISECONDS) .assertNoErrors() .assertValue(recoveryScheme); }
@Test public void testIsValidSerialisation_wellFormedInput() { final RecoveryScheme recoveryScheme = RecoveryScheme .builder() .setRequiredShareCount(2) .setPrime(7) .build(); serialiser .serialise(recoveryScheme) .flatMap(serialiser::isValidSerialisation) .test() .awaitDone(200, MILLISECONDS) .assertNoErrors() .assertValue(true); }