@Test
  public void shouldCreate() {
    OutsiderTeacher model = OutsiderTeacherTest.createOneEmpty();
    OutsiderTeacher saved = outsiderTeacherManager.create(model);
    OutsiderTeacher fetched = outsiderTeacherManager.findOneById(model.getId());

    assertThat(model.getId()).isNotNull();
    assertThat(saved.getId()).isNotNull();
    assertThat(fetched.getName()).isEqualTo(model.getName());
    assertThat(fetched.getContact()).isEqualTo(model.getContact());
  }
  @Test
  public void shouldRemoveEmail() {
    OutsiderTeacher teacher = scenarioHelper.createOutsiderTeacher();

    assertThat(teacher.getContact().getEmails()).isNotEmpty();

    for (Email email : teacher.getContact().getEmails()) {
      outsiderTeacherManager.removeEmail(email.getId());
    }
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getEmails())
        .isEmpty();
    assertThat(emailRepository.findAll()).isEmpty();
  }
  @Test
  public void shouldRemoveAddress() {
    OutsiderTeacher teacher = scenarioHelper.createOutsiderTeacher();

    assertThat(teacher.getContact().getAddresses()).isNotEmpty();

    for (Address address : teacher.getContact().getAddresses()) {
      outsiderTeacherManager.removeAddress(address.getId());
    }
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getAddresses())
        .isEmpty();
    assertThat(addressRepository.findAll()).isEmpty();
  }
  @Test
  public void shouldRemovePhone() {
    OutsiderTeacher teacher = scenarioHelper.createOutsiderTeacher();

    assertThat(teacher.getContact().getPhones()).isNotEmpty();

    for (Phone phone : teacher.getContact().getPhones()) {
      outsiderTeacherManager.removePhone(phone.getId());
    }
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getPhones())
        .isEmpty();
    assertThat(phoneRepository.findAll()).isEmpty();
  }
  @Test
  public void shouldAddEmail() {
    OutsiderTeacher teacher = scenarioHelper.createEmptyOutsiderTeacher();
    Email email = EmailTest.createOne(scenarioHelper.createEmailType());

    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getEmails())
        .isEmpty();
    Email saved = outsiderTeacherManager.addEmail(teacher.getId(), email);

    assertThat(emailRepository.findAll()).hasSize(1);
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getEmails())
        .hasSize(1);
    assertThat(saved.getId()).isNotNull();
  }
  @Test
  public void shouldAddPhone() {
    OutsiderTeacher teacher = scenarioHelper.createEmptyOutsiderTeacher();
    Phone phone = PhoneTest.createOne(scenarioHelper.createPhoneType());

    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getPhones())
        .isEmpty();
    Phone saved = outsiderTeacherManager.addPhone(teacher.getId(), phone);

    assertThat(phoneRepository.findAll()).hasSize(1);
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getPhones())
        .hasSize(1);
    assertThat(saved.getId()).isNotNull();
  }
  @Test
  public void shouldAddAddress() {
    OutsiderTeacher teacher = scenarioHelper.createEmptyOutsiderTeacher();
    Address address = AddressTest.createOne(scenarioHelper.createAddressType());

    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getAddresses())
        .isEmpty();
    Address saved = outsiderTeacherManager.addAddress(teacher.getId(), address);

    assertThat(addressRepository.findAll()).hasSize(1);
    assertThat(outsiderTeacherManager.findOneById(teacher.getId()).getContact().getAddresses())
        .hasSize(1);
    assertThat(saved.getId()).isNotNull();
  }
  @Test
  public void shouldFindAll() {
    scenarioHelper.createOutsiderTeacher();
    scenarioHelper.createOutsiderTeacher();
    scenarioHelper.createOutsiderTeacher();

    assertThat(outsiderTeacherManager.findAll()).hasSize(3);
  }
  @Test
  public void shouldFindOneById() {
    OutsiderTeacher model = OutsiderTeacherTest.createOne();
    scenarioHelper.createOutsiderTeacher(model);

    OutsiderTeacher fetched = outsiderTeacherManager.findOneById(model.getId());
    assertThat(fetched).isNotNull();
  }
  @Test
  public void shouldCreateAddressAndEmailAndPhoneOnCascade() {
    OutsiderTeacher model = OutsiderTeacherTest.createOne();
    scenarioHelper.createOutsiderTeacher(model);
    OutsiderTeacher fetched = outsiderTeacherManager.findOneById(model.getId());

    assertThat(addressRepository.findAll()).hasSameSizeAs(model.getContact().getAddresses());
    assertThat(emailRepository.findAll()).hasSameSizeAs(model.getContact().getEmails());
    assertThat(phoneRepository.findAll()).hasSameSizeAs(model.getContact().getPhones());
    assertThat(fetched.getContact().getAddresses())
        .hasSameSizeAs(model.getContact().getAddresses());
    assertThat(fetched.getContact().getEmails()).hasSameSizeAs(model.getContact().getEmails());
    assertThat(fetched.getContact().getPhones()).hasSameSizeAs(model.getContact().getPhones());
  }
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailAddPhoneWithNullPhone() {
   outsiderTeacherManager.addPhone(12L, null);
 }
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailCreateIfIdIsAlreadyDefined() {
   OutsiderTeacher model = OutsiderTeacherTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.create(model);
 }
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddAddressWithAddressHavingIdAlreadyDefined() {
   Address model = AddressTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addAddress(12L, model);
 }
 /*
  * removeAddress()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailRemoveAddressWithNullAddressId() {
   outsiderTeacherManager.removeAddress(null);
 }
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailCreateWithNull() {
   outsiderTeacherManager.create(null);
 }
 /*
  * removePhone()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailRemovePhoneWithNullPhoneId() {
   outsiderTeacherManager.removePhone(null);
 }
 @Test(expected = PhoneResourceNotFoundException.class)
 public void shouldFailRemovePhoneWithNonExistingTeacher() {
   outsiderTeacherManager.removePhone(12L);
 }
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddEmailWithEmailHavingIdAlreadyDefined() {
   Email model = EmailTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addEmail(12L, model);
 }
 @Test(expected = PhoneTypeResourceNotFoundException.class)
 public void shouldFailAddPhoneWithPhoneHavingNonExistingType() {
   OutsiderTeacher model = scenarioHelper.createEmptyOutsiderTeacher();
   outsiderTeacherManager.addPhone(model.getId(), PhoneTest.createOne());
 }
 /*
  * addPhone()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailAddPhoneWithNullTeacherId() {
   outsiderTeacherManager.addPhone(null, PhoneTest.createOne());
 }
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailFindOneByIdWithNull() {
   outsiderTeacherManager.findOneById(null);
 }
 @Test(expected = TeacherResourceNotFoundException.class)
 public void shouldFailAddPhoneWithNonExistingTeacher() {
   PhoneType type = scenarioHelper.createPhoneType();
   outsiderTeacherManager.addPhone(12L, PhoneTest.createOne(type));
 }
 @Test(expected = TeacherResourceNotFoundException.class)
 public void shouldFailFindOneByIdWithNonExisting() {
   outsiderTeacherManager.findOneById(156L);
 }
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddPhoneWithPhoneHavingIdAlreadyDefined() {
   Phone model = PhoneTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addPhone(12L, model);
 }