use of uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogMiddleNamesNameHistory.
@Test
public void shouldLogMiddleNamesNameHistory() throws Exception {
AttributeValue oldMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withTo(DateTime.now().minusDays(406)).withVerified(true).build();
AttributeValue currentMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.now().minusDays(405)).withVerified(true).build();
Attribute middleNamesAttribute = new AttributeBuilder().buildObject();
middleNamesAttribute.setName(IdaConstants.Attributes_1_1.Middlename.NAME);
middleNamesAttribute.getAttributeValues().add(oldMiddleNamesAttributeValue);
middleNamesAttribute.getAttributeValues().add(currentMiddleNamesAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withMiddleNames(middleNamesAttribute).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.Middlename.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "more than 405 days"), new VerifiedAttributeLogData(true, null)));
}
use of uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogSurnameNameHistory.
@Test
public void shouldLogSurnameNameHistory() throws Exception {
AttributeValue surnameAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withVerified(true).build();
Attribute surnameAttribute = new AttributeBuilder().buildObject();
surnameAttribute.setName(IdaConstants.Attributes_1_1.Surname.NAME);
surnameAttribute.getAttributeValues().add(surnameAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withSurname(surnameAttribute).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.Surname.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, null)));
}
use of uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogFirstNameHistory.
@Test
public void shouldLogFirstNameHistory() throws Exception {
AttributeValue oldFirstNameAttributeValue = new PersonNameAttributeValueBuilder().withTo(DateTime.now().minusDays(181)).withVerified(true).build();
AttributeValue currentFirstNameAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.now()).withTo(null).build();
Attribute firstNameAttribute = new AttributeBuilder().buildObject();
firstNameAttribute.setName(IdaConstants.Attributes_1_1.Firstname.NAME);
firstNameAttribute.getAttributeValues().add(oldFirstNameAttributeValue);
firstNameAttribute.getAttributeValues().add(currentFirstNameAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withFirstname(firstNameAttribute).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.Firstname.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "more than 180 days"), new VerifiedAttributeLogData(false, null)));
}
Aggregations