public static String serialize(AWSCredentialsProvider awsCredentialsProvider) {
    ObjectMapper om = new ObjectMapper();
    om.registerModule(new AwsModule());
    try {
      return om.writeValueAsString(awsCredentialsProvider);
    } catch (JsonProcessingException e) {
      throw new IllegalArgumentException("AwsCredentialsProvider can not be serialized to Json", e);
    }
  }
@Test(expected = IllegalArgumentException.class)
  public void testFailOnAWSCredentialsProviderSerialization() {
    AWSCredentialsProvider credentialsProvider = new UnknownAwsCredentialsProvider();
    serialize(credentialsProvider);
  }