@Test public void testValidate() { AmazonDynamoDBErrorFault fault = new AmazonDynamoDBErrorFault(); Set<Violation> violations = fault.validate(); assertThat(violations.size(), is(1)); assertTrue(violations.iterator().next().toString().startsWith("Parameter 'statusCode' is any one of [")); fault = new AmazonDynamoDBErrorFault(); fault.setStatusCode(502); violations = fault.validate(); assertThat(violations.size(), is(1)); assertTrue(violations.iterator().next().toString().startsWith("Parameter 'statusCode' is any one of [")); fault = new AmazonDynamoDBErrorFault(); fault.setStatusCode(400); violations = fault.validate(); assertThat(violations.size(), is(1)); assertTrue(violations.iterator().next().toString().startsWith("Parameter 'errorCode' is any one of [")); fault = new AmazonDynamoDBErrorFault(); fault.setStatusCode(400); fault.setErrorCode("error-not-found"); violations = fault.validate(); assertThat(violations.size(), is(1)); assertTrue(violations.iterator().next().toString().startsWith("Parameter 'errorCode' is any one of [")); fault = new AmazonDynamoDBErrorFault(); fault.setStatusCode(503); violations = fault.validate(); assertTrue(violations.isEmpty()); fault = new AmazonDynamoDBErrorFault(); fault.setStatusCode(400); fault.setErrorCode("AccessDeniedException"); violations = fault.validate(); assertTrue(violations.isEmpty()); }
@Override public Set<Violation> validate() { final Set<Violation> violations = new HashSet<>(); if (statusCode == null || (statusCode != null && !EXCEPTIONS.containsKey(statusCode))) { violations.add(new Violation("Parameter 'statusCode' is any one of [" + EXCEPTIONS.keySet() + "]")); return violations; } final Map<String, Class<? extends AmazonServiceException>> map = EXCEPTIONS.get(statusCode); if ((errorCode == null && map.size() != 1) || (errorCode != null && !map.containsKey(errorCode))) { violations.add(new Violation("Parameter 'errorCode' is any one of [" + map.keySet() + "]")); } return violations; }
AmazonDynamoDBErrorFault extends Fault implements Validator, Interceptor { @Override public Set<Violation> validate() { final Set<Violation> violations = new HashSet<>(); if (statusCode == null || (statusCode != null && !EXCEPTIONS.containsKey(statusCode))) { violations.add(new Violation("Parameter 'statusCode' is any one of [" + EXCEPTIONS.keySet() + "]")); return violations; } final Map<String, Class<? extends AmazonServiceException>> map = EXCEPTIONS.get(statusCode); if ((errorCode == null && map.size() != 1) || (errorCode != null && !map.containsKey(errorCode))) { violations.add(new Violation("Parameter 'errorCode' is any one of [" + map.keySet() + "]")); } return violations; } }
AmazonDynamoDBErrorFault extends Fault implements Validator, Interceptor { @Override public Set<Violation> validate() { final Set<Violation> violations = new HashSet<>(); if (statusCode == null || (statusCode != null && !EXCEPTIONS.containsKey(statusCode))) { violations.add(new Violation("Parameter 'statusCode' is any one of [" + EXCEPTIONS.keySet() + "]")); return violations; } final Map<String, Class<? extends AmazonServiceException>> map = EXCEPTIONS.get(statusCode); if ((errorCode == null && map.size() != 1) || (errorCode != null && !map.containsKey(errorCode))) { violations.add(new Violation("Parameter 'errorCode' is any one of [" + map.keySet() + "]")); } return violations; }  }
AmazonDynamoDBErrorFault extends Fault implements Validator, Interceptor { @Override public Set<Violation> validate() { final Set<Violation> violations = new HashSet<>(); if (statusCode == null || (statusCode != null && !EXCEPTIONS.containsKey(statusCode))) { violations.add(new Violation("Parameter 'statusCode' is any one of [" + EXCEPTIONS.keySet() + "]")); return violations; } final Map<String, Class<? extends AmazonServiceException>> map = EXCEPTIONS.get(statusCode); if ((errorCode == null && map.size() != 1) || (errorCode != null && !map.containsKey(errorCode))) { violations.add(new Violation("Parameter 'errorCode' is any one of [" + map.keySet() + "]")); } return violations; }  @Override Set<Violation> validate(); Integer getStatusCode(); void setStatusCode(final Integer statusCode); String getErrorCode(); void setErrorCode(final String errorCode); @Override boolean apply(final Invocation invocation); }
AmazonDynamoDBErrorFault extends Fault implements Validator, Interceptor { @Override public Set<Violation> validate() { final Set<Violation> violations = new HashSet<>(); if (statusCode == null || (statusCode != null && !EXCEPTIONS.containsKey(statusCode))) { violations.add(new Violation("Parameter 'statusCode' is any one of [" + EXCEPTIONS.keySet() + "]")); return violations; } final Map<String, Class<? extends AmazonServiceException>> map = EXCEPTIONS.get(statusCode); if ((errorCode == null && map.size() != 1) || (errorCode != null && !map.containsKey(errorCode))) { violations.add(new Violation("Parameter 'errorCode' is any one of [" + map.keySet() + "]")); } return violations; }  @Override Set<Violation> validate(); Integer getStatusCode(); void setStatusCode(final Integer statusCode); String getErrorCode(); void setErrorCode(final String errorCode); @Override boolean apply(final Invocation invocation);  }