Search in sources :

Example 1 with PhoneNumber

use of gov.ca.cwds.rest.api.domain.PhoneNumber in project API by ca-cwds.

the class PhoneNumberServiceTest method testCreateReturnsPostedClass.

@Test
@Override
public void testCreateReturnsPostedClass() throws Exception {
    gov.ca.cwds.data.persistence.ns.PhoneNumber toCreate = new gov.ca.cwds.data.persistence.ns.PhoneNumber(1L, "408 987-6543", "Home");
    PhoneNumber request = new PhoneNumber(toCreate);
    when(phoneNumberDao.create(any(gov.ca.cwds.data.persistence.ns.PhoneNumber.class))).thenReturn(toCreate);
    PostedPhoneNumber postedPhoneNumber = phoneNumberService.create(request);
    assertThat(postedPhoneNumber.getClass(), is(PostedPhoneNumber.class));
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Example 2 with PhoneNumber

use of gov.ca.cwds.rest.api.domain.PhoneNumber in project API by ca-cwds.

the class PhoneNumberServiceTest method testUpdateReturnsDomain.

@Test
@Override
public void testUpdateReturnsDomain() throws Exception {
    thrown.expect(NotImplementedException.class);
    phoneNumberService.update(1L, new PhoneNumber("408 987-6543", "Home"));
}
Also used : PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Example 3 with PhoneNumber

use of gov.ca.cwds.rest.api.domain.PhoneNumber in project API by ca-cwds.

the class PersonServiceTest method testFindReturnsCorrectPersonWhenFound.

/*
   * find tests
   */
@Test
public void testFindReturnsCorrectPersonWhenFound() throws Exception {
    Address address = new Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "Home");
    PhoneNumber phoneNumber = new PhoneNumber("408-277-4778", "cell");
    Language language = new Language("English");
    Race race = new Race("White", "European");
    Ethnicity ethnicity = new Ethnicity("Unknown", "South American");
    Set<Address> addresses = new HashSet<Address>();
    addresses.add(address);
    Set<PhoneNumber> phoneNumbers = new HashSet<PhoneNumber>();
    phoneNumbers.add(phoneNumber);
    Set<Language> languages = new HashSet<Language>();
    languages.add(language);
    Set<Race> races = new HashSet<Race>();
    races.add(race);
    Set<Ethnicity> ethnicities = new HashSet<Ethnicity>();
    ethnicities.add(ethnicity);
    Person expected = new Person("Bart", "Simpson", "M", "2016-10-31", "1234556789", addresses, phoneNumbers, languages, races, ethnicities);
    gov.ca.cwds.data.persistence.ns.Person person = new gov.ca.cwds.data.persistence.ns.Person(expected, null, null);
    when(personDao.find(123L)).thenReturn(person);
    Person found = personService.find(123L);
    assertThat(found, is(expected));
}
Also used : PersonAddress(gov.ca.cwds.data.persistence.ns.PersonAddress) Address(gov.ca.cwds.rest.api.domain.Address) Ethnicity(gov.ca.cwds.rest.api.domain.Ethnicity) Language(gov.ca.cwds.rest.api.domain.Language) Race(gov.ca.cwds.rest.api.domain.Race) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) Person(gov.ca.cwds.rest.api.domain.Person) PostedPerson(gov.ca.cwds.rest.api.domain.PostedPerson) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with PhoneNumber

use of gov.ca.cwds.rest.api.domain.PhoneNumber in project API by ca-cwds.

the class PersonService method populatePersonDetails.

/**
   * 
   * @param person - The person
   * @param managedPerson - The managedPerson
   */
private void populatePersonDetails(Person person, gov.ca.cwds.data.persistence.ns.Person managedPerson) {
    if (person.getAddress() != null && !person.getAddress().isEmpty()) {
        for (Address address : person.getAddress()) {
            gov.ca.cwds.data.persistence.ns.Address managedAddress = new gov.ca.cwds.data.persistence.ns.Address(address, null, null);
            PersonAddress personAddress = new PersonAddress(managedPerson, managedAddress);
            managedPerson.addPersonAddress(personAddress);
            addressDao.create(managedAddress);
            personAddressDao.create(personAddress);
        }
    }
    if (person.getPhoneNumber() != null && !person.getPhoneNumber().isEmpty()) {
        for (PhoneNumber phoneNumber : person.getPhoneNumber()) {
            gov.ca.cwds.data.persistence.ns.PhoneNumber managedPhoneNumber = new gov.ca.cwds.data.persistence.ns.PhoneNumber(phoneNumber, null, null);
            PersonPhone personPhone = new PersonPhone(managedPerson, managedPhoneNumber);
            managedPerson.addPersonPhone(personPhone);
            phoneNumberDao.create(managedPhoneNumber);
            personPhoneDao.create(personPhone);
        }
    }
    if (person.getLanguage() != null && !person.getLanguage().isEmpty()) {
        for (Language language : person.getLanguage()) {
            gov.ca.cwds.data.persistence.ns.Language managedLanguage = new gov.ca.cwds.data.persistence.ns.Language(language, null, null);
            PersonLanguage personLanguage = new PersonLanguage(managedPerson, managedLanguage);
            managedPerson.addPersonLanguage(personLanguage);
            languageDao.create(managedLanguage);
            personLanguageDao.create(personLanguage);
        }
    }
    if (person.getRace() != null && !person.getRace().isEmpty()) {
        for (Race race : person.getRace()) {
            gov.ca.cwds.data.persistence.ns.Race managedRace = new gov.ca.cwds.data.persistence.ns.Race(race, null, null);
            PersonRace personRace = new PersonRace(managedPerson, managedRace);
            managedPerson.addPersonRace(personRace);
            raceDao.create(managedRace);
            personRaceDao.create(personRace);
        }
    }
    if (person.getEthnicity() != null && !person.getEthnicity().isEmpty()) {
        for (Ethnicity ethnicity : person.getEthnicity()) {
            gov.ca.cwds.data.persistence.ns.Ethnicity managedEthnicity = new gov.ca.cwds.data.persistence.ns.Ethnicity(ethnicity, null, null);
            PersonEthnicity personEthnicity = new PersonEthnicity(managedPerson, managedEthnicity);
            managedPerson.addPersonEthnicity(personEthnicity);
            ethnicityDao.create(managedEthnicity);
            personEthnicityDao.create(personEthnicity);
        }
    }
}
Also used : PersonRace(gov.ca.cwds.data.persistence.ns.PersonRace) PersonAddress(gov.ca.cwds.data.persistence.ns.PersonAddress) Address(gov.ca.cwds.rest.api.domain.Address) PersonAddress(gov.ca.cwds.data.persistence.ns.PersonAddress) PersonLanguage(gov.ca.cwds.data.persistence.ns.PersonLanguage) PersonPhone(gov.ca.cwds.data.persistence.ns.PersonPhone) Ethnicity(gov.ca.cwds.rest.api.domain.Ethnicity) PersonEthnicity(gov.ca.cwds.data.persistence.ns.PersonEthnicity) Language(gov.ca.cwds.rest.api.domain.Language) PersonLanguage(gov.ca.cwds.data.persistence.ns.PersonLanguage) PersonRace(gov.ca.cwds.data.persistence.ns.PersonRace) Race(gov.ca.cwds.rest.api.domain.Race) PersonEthnicity(gov.ca.cwds.data.persistence.ns.PersonEthnicity) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber)

Example 5 with PhoneNumber

use of gov.ca.cwds.rest.api.domain.PhoneNumber in project API by ca-cwds.

the class PhoneNumberServiceTest method testCreateReturnsCorrectEntity.

@Test
@Override
public void testCreateReturnsCorrectEntity() throws Exception {
    gov.ca.cwds.data.persistence.ns.PhoneNumber toCreate = new gov.ca.cwds.data.persistence.ns.PhoneNumber(10L, "408 987-6543", "Home");
    PhoneNumber request = new PhoneNumber(toCreate);
    when(phoneNumberDao.create(any(gov.ca.cwds.data.persistence.ns.PhoneNumber.class))).thenReturn(toCreate);
    PostedPhoneNumber expected = new PostedPhoneNumber(10, "408 987-6543", "Home");
    PostedPhoneNumber returned = phoneNumberService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Aggregations

PhoneNumber (gov.ca.cwds.rest.api.domain.PhoneNumber)9 PostedPhoneNumber (gov.ca.cwds.rest.api.domain.PostedPhoneNumber)7 Test (org.junit.Test)7 PersonAddress (gov.ca.cwds.data.persistence.ns.PersonAddress)2 Address (gov.ca.cwds.rest.api.domain.Address)2 Ethnicity (gov.ca.cwds.rest.api.domain.Ethnicity)2 Language (gov.ca.cwds.rest.api.domain.Language)2 Race (gov.ca.cwds.rest.api.domain.Race)2 PersonEthnicity (gov.ca.cwds.data.persistence.ns.PersonEthnicity)1 PersonLanguage (gov.ca.cwds.data.persistence.ns.PersonLanguage)1 PersonPhone (gov.ca.cwds.data.persistence.ns.PersonPhone)1 PersonRace (gov.ca.cwds.data.persistence.ns.PersonRace)1 Person (gov.ca.cwds.rest.api.domain.Person)1 PostedPerson (gov.ca.cwds.rest.api.domain.PostedPerson)1 HashSet (java.util.HashSet)1