@Test public void test_should_not_throw_exception_when_date_time_format_is_valid() { final DateTimeAttributeValidator validator = new DateTimeAttributeValidator(); final ServiceRequest serviceRequest = mock(ServiceRequest.class); when(serviceRequest.getAttributeWithKey("dateTime1")) .thenReturn(new AttributeEntry("dateTime1", "02-11-2017 23:32:45")); final AttributeDefinition attributeDefinition = AttributeDefinition.builder() .dataType(AttributeDataType.DATE_TIME) .code("dateTime1") .build(); final ServiceDefinition serviceDefinition = ServiceDefinition.builder() .attributes(Collections.singletonList(attributeDefinition)) .build(); validator.validate(serviceRequest, serviceDefinition, ServiceStatus.CITIZEN_SERVICE_APPROVED); }
@Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedDateTimeAttributes = serviceDefinition. getNonComputedDateTimeAttributes(); if (CollectionUtils.isEmpty(nonComputedDateTimeAttributes)) { return; } nonComputedDateTimeAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingDateTimeAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingDateTimeAttributeEntry == null || isEmpty(matchingDateTimeAttributeEntry.getCode())) { return; } validateDateTimeFormat(matchingDateTimeAttributeEntry); }); }
DateTimeAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedDateTimeAttributes = serviceDefinition. getNonComputedDateTimeAttributes(); if (CollectionUtils.isEmpty(nonComputedDateTimeAttributes)) { return; } nonComputedDateTimeAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingDateTimeAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingDateTimeAttributeEntry == null || isEmpty(matchingDateTimeAttributeEntry.getCode())) { return; } validateDateTimeFormat(matchingDateTimeAttributeEntry); }); } }
DateTimeAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedDateTimeAttributes = serviceDefinition. getNonComputedDateTimeAttributes(); if (CollectionUtils.isEmpty(nonComputedDateTimeAttributes)) { return; } nonComputedDateTimeAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingDateTimeAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingDateTimeAttributeEntry == null || isEmpty(matchingDateTimeAttributeEntry.getCode())) { return; } validateDateTimeFormat(matchingDateTimeAttributeEntry); }); }  }
DateTimeAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedDateTimeAttributes = serviceDefinition. getNonComputedDateTimeAttributes(); if (CollectionUtils.isEmpty(nonComputedDateTimeAttributes)) { return; } nonComputedDateTimeAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingDateTimeAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingDateTimeAttributeEntry == null || isEmpty(matchingDateTimeAttributeEntry.getCode())) { return; } validateDateTimeFormat(matchingDateTimeAttributeEntry); }); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action); }
DateTimeAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedDateTimeAttributes = serviceDefinition. getNonComputedDateTimeAttributes(); if (CollectionUtils.isEmpty(nonComputedDateTimeAttributes)) { return; } nonComputedDateTimeAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingDateTimeAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingDateTimeAttributeEntry == null || isEmpty(matchingDateTimeAttributeEntry.getCode())) { return; } validateDateTimeFormat(matchingDateTimeAttributeEntry); }); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action);  }