Search in sources :

Example 1 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class PersonFactoryTest method getUser.

private User getUser(final String name, String email) {
    final User user = new User();
    user.setDisplayName(name);
    user.setDepartment(DEPT);
    user.setBusinessPhones(Collections.singletonList(BUSINESS_PHONE));
    user.setId(ID);
    user.setJobTitle(JOB);
    user.setMail(email);
    user.setMobilePhone(MOBILE_PHONE);
    user.setOfficeLocation(OFFICE);
    user.setUserPrincipalName(String.format(USER_PRINCIPAL_NAME_FORMAT, name));
    return user;
}
Also used : User(uk.nhs.digital.intranet.json.User)

Example 2 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class PersonFactoryTest method createsPersonListFromUserList.

@Test
public void createsPersonListFromUserList() {
    final User user1 = getUser("user1", null);
    final User user2 = getUser("user2", null);
    final User user3 = getUser("user3", null);
    final List<User> users = Arrays.asList(user1, user2, user3);
    final List<Person> persons = personFactory.createPersons(users);
    assertEquals(3, persons.size());
    IntStream.range(0, 3).forEach(index -> {
        assertEquals(users.get(index).getDisplayName(), persons.get(index).getDisplayName());
        assertEquals(users.get(index).getDepartment(), persons.get(index).getDepartment());
        assertEquals(users.get(index).getId(), persons.get(index).getId());
        assertNull(persons.get(index).getBusinessPhones());
        assertNull(persons.get(index).getEmail());
        assertNull(persons.get(index).getPhoneNumber());
        assertNull(persons.get(index).getJobRole());
        assertNull(persons.get(index).getOfficeLocation());
        assertNull(persons.get(index).getPhoto());
    });
}
Also used : User(uk.nhs.digital.intranet.json.User) Person(uk.nhs.digital.intranet.model.Person) Test(org.junit.Test)

Example 3 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class PersonFactoryTest method createsPersonFromUserAndPhotoUsingUserPrincipalNameAsMail.

@Test
public void createsPersonFromUserAndPhotoUsingUserPrincipalNameAsMail() {
    final String userName = "user1";
    final User user = getUser(userName, null);
    final Person person = personFactory.createPerson(user, PHOTO);
    assertEquals(user.getDisplayName(), person.getDisplayName());
    assertEquals(user.getBusinessPhones(), person.getBusinessPhones());
    assertEquals(user.getDepartment(), person.getDepartment());
    assertEquals(user.getJobTitle(), person.getJobRole());
    assertEquals(user.getUserPrincipalName(), person.getEmail());
    assertEquals(user.getMobilePhone(), person.getPhoneNumber());
    assertEquals(user.getId(), person.getId());
    assertEquals(PHOTO, person.getPhoto());
}
Also used : User(uk.nhs.digital.intranet.json.User) Person(uk.nhs.digital.intranet.model.Person) Test(org.junit.Test)

Example 4 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class PersonFactoryTest method createsPersonFromUserAndPhoto.

@Test
public void createsPersonFromUserAndPhoto() {
    final String userName = "user1";
    final User user = getUser(userName, String.format(MAIL_FORMAT, userName));
    final Person person = personFactory.createPerson(user, PHOTO);
    assertEquals(user.getDisplayName(), person.getDisplayName());
    assertEquals(user.getBusinessPhones(), person.getBusinessPhones());
    assertEquals(user.getDepartment(), person.getDepartment());
    assertEquals(user.getJobTitle(), person.getJobRole());
    assertEquals(user.getMail(), person.getEmail());
    assertEquals(user.getMobilePhone(), person.getPhoneNumber());
    assertEquals(user.getId(), person.getId());
    assertEquals(PHOTO, person.getPhoto());
}
Also used : User(uk.nhs.digital.intranet.json.User) Person(uk.nhs.digital.intranet.model.Person) Test(org.junit.Test)

Example 5 with User

use of uk.nhs.digital.intranet.json.User in project hippo by NHS-digital-website.

the class GraphProviderImpl method getPerson.

@Override
public Person getPerson(final String id) throws ProviderCommunicationException {
    final User user = getUser(id);
    final String photo = getPhoto(id);
    return personFactory.createPerson(user, photo);
}
Also used : User(uk.nhs.digital.intranet.json.User)

Aggregations

User (uk.nhs.digital.intranet.json.User)6 Test (org.junit.Test)3 Person (uk.nhs.digital.intranet.model.Person)3 URI (java.net.URI)1 HttpStatusCodeException (org.springframework.web.client.HttpStatusCodeException)1 ProviderCommunicationException (uk.nhs.digital.intranet.model.exception.ProviderCommunicationException)1