@Test public void test_should_throw_exception_when_long_format_is_invalid() { final LongAttributeValidator validator = new LongAttributeValidator(); final ServiceRequest serviceRequest = mock(ServiceRequest.class); when(serviceRequest.getAttributeWithKey("Long1")) .thenReturn(new AttributeEntry("Long1", "15.23")); final AttributeDefinition attributeDefinition = AttributeDefinition.builder() .dataType(AttributeDataType.LONG) .code("Long1") .build(); final ServiceDefinition serviceDefinition = ServiceDefinition.builder() .attributes(Collections.singletonList(attributeDefinition)) .build(); try { validator.validate(serviceRequest, serviceDefinition, ServiceStatus.CITIZEN_SERVICE_APPROVED); Assert.fail("Expected exception to be thrown"); } catch (InvalidLongAttributeEntryException ex) { assertEquals("Long1", ex.getAttributeCode()); } }
@Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedLongAttributes = serviceDefinition.getNonComputedLongAttributes(); if (CollectionUtils.isEmpty(nonComputedLongAttributes)) { return; } nonComputedLongAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingLongAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingLongAttributeEntry == null || isEmpty(matchingLongAttributeEntry.getCode())) { return; } validateLong(matchingLongAttributeEntry); }); }
LongAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedLongAttributes = serviceDefinition.getNonComputedLongAttributes(); if (CollectionUtils.isEmpty(nonComputedLongAttributes)) { return; } nonComputedLongAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingLongAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingLongAttributeEntry == null || isEmpty(matchingLongAttributeEntry.getCode())) { return; } validateLong(matchingLongAttributeEntry); }); } }
LongAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedLongAttributes = serviceDefinition.getNonComputedLongAttributes(); if (CollectionUtils.isEmpty(nonComputedLongAttributes)) { return; } nonComputedLongAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingLongAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingLongAttributeEntry == null || isEmpty(matchingLongAttributeEntry.getCode())) { return; } validateLong(matchingLongAttributeEntry); }); }  }
LongAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedLongAttributes = serviceDefinition.getNonComputedLongAttributes(); if (CollectionUtils.isEmpty(nonComputedLongAttributes)) { return; } nonComputedLongAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingLongAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingLongAttributeEntry == null || isEmpty(matchingLongAttributeEntry.getCode())) { return; } validateLong(matchingLongAttributeEntry); }); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action); }
LongAttributeValidator implements AttributeValueValidator { @Override public void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action) { final List<AttributeDefinition> nonComputedLongAttributes = serviceDefinition.getNonComputedLongAttributes(); if (CollectionUtils.isEmpty(nonComputedLongAttributes)) { return; } nonComputedLongAttributes.forEach(attributeDefinition -> { final AttributeEntry matchingLongAttributeEntry = serviceRequest .getAttributeWithKey(attributeDefinition.getCode()); if(matchingLongAttributeEntry == null || isEmpty(matchingLongAttributeEntry.getCode())) { return; } validateLong(matchingLongAttributeEntry); }); }  @Override void validate(ServiceRequest serviceRequest, ServiceDefinition serviceDefinition, ServiceStatus action);  }