@Test public void not_empty_list_invalid_value() { String value = "hi"; List<String> toAddressBlock = asList(value); Mockito.when(request.getTo()).thenReturn(toAddressBlock); Mockito.when( requiredFieldRule.validateAtLeastOne(toAddressBlock, ToAddressStrategy.FIELD, context)) .thenReturn(true); Mockito.when(requiredFieldRule.validate(value, ToAddressStrategy.FIELD, context)) .thenReturn(false); strategy.validate(request, context); Mockito.verify(requiredFieldRule) .validateAtLeastOne(toAddressBlock, ToAddressStrategy.FIELD, context); Mockito.verify(requiredFieldRule).validate(value, ToAddressStrategy.FIELD, context); Mockito.verifyNoMoreInteractions(requiredFieldRule, emailAddressFormatRule); }
@Test public void empty_list() { List<String> toAddressBlock = new ArrayList<String>(); Mockito.when(request.getTo()).thenReturn(toAddressBlock); Mockito.when( requiredFieldRule.validateAtLeastOne(toAddressBlock, ToAddressStrategy.FIELD, context)) .thenReturn(false); strategy.validate(request, context); Mockito.verify(requiredFieldRule) .validateAtLeastOne(toAddressBlock, ToAddressStrategy.FIELD, context); Mockito.verifyNoMoreInteractions(context, requiredFieldRule, emailAddressFormatRule); }