### Question:
ConstraintValidatorContextDecorator implements ConstraintValidatorContext { @SuppressWarnings("unchecked") public static List<Object> getArguments(ConstraintViolation violation) { List<Object> arguments = null; if (violation instanceof ConstraintViolationImpl) { Map<String, Object> variables = ((ConstraintViolationImpl<?>) violation).getExpressionVariables(); if (variables != null) { arguments = (List<Object>) variables.get(ARGUMENTS); } } return arguments; } ConstraintValidatorContextDecorator(ConstraintValidatorContext context); @SuppressWarnings("unchecked") static List<Object> getArguments(ConstraintViolation violation); @SuppressWarnings("unchecked") static Object[] getArgumentsArray(ConstraintViolation violation); ConstraintValidatorContextDecorator setArguments(Object... arguments); ConstraintValidatorContextDecorator setArguments(List<Object> arguments); @Override void disableDefaultConstraintViolation(); @Override String getDefaultConstraintMessageTemplate(); @Override ConstraintViolationBuilder buildConstraintViolationWithTemplate(String messageTemplate); @Override T unwrap(Class<T> type); static final String ARGUMENTS; }### Answer:
@Test public void getArguments_violationIsNull_success() { assertNull(ConstraintValidatorContextDecorator.getArguments(null)); }
@Test public void getArguments_violationHasWrongImplementation_success() { assertNull(ConstraintValidatorContextDecorator.getArguments(mock(ConstraintViolation.class))); }
@Test public void getArguments_violationHasNullVariables_success() { assertNull(ConstraintValidatorContextDecorator.getArguments(createViolation(null))); }
@Test public void getArguments_violationHasEmptyVariables_success() { assertNull(ConstraintValidatorContextDecorator.getArguments(createViolation( Collections.<String, Object>emptyMap() ))); }
@Test public void getArguments_violationHasSomeVariables_success() { Map<String, Object> variables = new HashMap<String, Object>() {{ put(ARGUMENTS, LIST_ARGS); }}; assertEquals( ConstraintValidatorContextDecorator.getArguments(createViolation(variables)), LIST_ARGS ); }