### Question:
BaseValidator { public List<ValidationMessage> generateValidationMessages(List<InvalidValue> invalidValues) { List<ValidationMessage> messages = new ArrayList<ValidationMessage>(); for (InvalidValue invalidValue : invalidValues) { ValidationMessage message = messageProducer.getMessage(invalidValue); messages.add(message); } return messages; } BaseValidator();  BaseValidator(MessageProducer messageProducer); List<ValidationMessage> generateValidationMessages(List<InvalidValue> invalidValues); void assertValid(List<InvalidValue> invalidValues);  }### Answer:
@Test public void testGetValidationMessagesT() { Mockery mockery = new Mockery(); final MessageProducer messageProducer = mockery.mock(MessageProducer.class); final InvalidValue invalidValue = mockery.mock(InvalidValue.class); final ValidationMessage validationMessage = mockery.mock(ValidationMessage.class); mockery.checking(new Expectations() { { exactly(1).of(messageProducer).getMessage(invalidValue); will(returnValue(validationMessage)); } }); BaseValidator validator = new BaseValidator(messageProducer); List<InvalidValue> invalidValues = Arrays.asList(invalidValue); List<ValidationMessage> actual = validator.generateValidationMessages(invalidValues); List<ValidationMessage> expected = new ArrayList<ValidationMessage>(); expected.add(validationMessage); assertEquals(expected, actual); mockery.assertIsSatisfied(); }