use of uk.gov.ida.saml.core.test.builders.DateAttributeValueBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogDateOfBirthHistory.
@Test
public void shouldLogDateOfBirthHistory() throws Exception {
Attribute dateOfBirthAttribute = new AttributeBuilder().buildObject();
dateOfBirthAttribute.setName(IdaConstants.Attributes_1_1.DateOfBirth.NAME);
AttributeValue oldDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(DateTime.now().minusDays(1)).withVerified(true).build();
AttributeValue currentDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(null).build();
dateOfBirthAttribute.getAttributeValues().add(oldDateOfBirthAttributeValue);
dateOfBirthAttribute.getAttributeValues().add(currentDateOfBirthAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withDateOfBirth(dateOfBirthAttribute).build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("any-issuer", LEVEL_2, attributes), AttributeStatementLogData.class);
Map<String, List<VerifiedAttributeLogData>> attributesMap = actual.getAttributes();
assertThat(attributesMap.get(IdaConstants.Attributes_1_1.DateOfBirth.NAME)).isEqualTo(List.of(new VerifiedAttributeLogData(true, "less than 180 days"), new VerifiedAttributeLogData(false, null)));
}
Aggregations