@Test public void test_should_thrown_exception_when_multiple_attribute_value_entries_present_for_attribute_of_date_type() { final SingleValueAttributeValidator validator = new SingleValueAttributeValidator(); final List<AttributeEntry> attributeEntries = Arrays.asList( new AttributeEntry("key1", "value1"), new AttributeEntry("key1", "value2"), new AttributeEntry("key2", "value3") ); final ServiceRequest serviceRequest = createServiceRequest(attributeEntries); final AttributeDefinition attributeDefinition = AttributeDefinition.builder() .code("key1") .dataType(AttributeDataType.DATE) .build(); final ServiceDefinition serviceDefinition = ServiceDefinition.builder() .attributes(Collections.singletonList(attributeDefinition)) .build(); try { validator.validate(serviceRequest, serviceDefinition, ServiceStatus.COMPLAINT_REGISTERED); Assert.fail("Expected exception to be thrown"); } catch (MultipleAttributeValuesReceivedException ex) { assertEquals("key1", ex.getAttributeCode()); } }
@Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> singleValueTypeAttributes = serviceDefinition.getSingleValueTypeAttributes(); singleValueTypeAttributes .forEach(attributeDefinition -> validateAttributeEntries(serviceRequest, attributeDefinition)); }
SingleValueAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> singleValueTypeAttributes = serviceDefinition.getSingleValueTypeAttributes(); singleValueTypeAttributes .forEach(attributeDefinition -> validateAttributeEntries(serviceRequest, attributeDefinition)); } }
SingleValueAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> singleValueTypeAttributes = serviceDefinition.getSingleValueTypeAttributes(); singleValueTypeAttributes .forEach(attributeDefinition -> validateAttributeEntries(serviceRequest, attributeDefinition)); }  }
SingleValueAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> singleValueTypeAttributes = serviceDefinition.getSingleValueTypeAttributes(); singleValueTypeAttributes .forEach(attributeDefinition -> validateAttributeEntries(serviceRequest, attributeDefinition)); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action); }
SingleValueAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> singleValueTypeAttributes = serviceDefinition.getSingleValueTypeAttributes(); singleValueTypeAttributes .forEach(attributeDefinition -> validateAttributeEntries(serviceRequest, attributeDefinition)); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action);  }