コード例 #1
0
  @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());
  }
コード例 #2
0
  @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();
  }
コード例 #3
0
  @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();
  }
コード例 #4
0
  @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();
  }
コード例 #5
0
  @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();
  }
コード例 #6
0
  @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();
  }
コード例 #7
0
  @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();
  }
コード例 #8
0
  @Test
  public void shouldFindAll() {
    scenarioHelper.createOutsiderTeacher();
    scenarioHelper.createOutsiderTeacher();
    scenarioHelper.createOutsiderTeacher();

    assertThat(outsiderTeacherManager.findAll()).hasSize(3);
  }
コード例 #9
0
  @Test
  public void shouldFindOneById() {
    OutsiderTeacher model = OutsiderTeacherTest.createOne();
    scenarioHelper.createOutsiderTeacher(model);

    OutsiderTeacher fetched = outsiderTeacherManager.findOneById(model.getId());
    assertThat(fetched).isNotNull();
  }
コード例 #10
0
  @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());
  }
コード例 #11
0
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailAddPhoneWithNullPhone() {
   outsiderTeacherManager.addPhone(12L, null);
 }
コード例 #12
0
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailCreateIfIdIsAlreadyDefined() {
   OutsiderTeacher model = OutsiderTeacherTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.create(model);
 }
コード例 #13
0
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddAddressWithAddressHavingIdAlreadyDefined() {
   Address model = AddressTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addAddress(12L, model);
 }
コード例 #14
0
 /*
  * removeAddress()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailRemoveAddressWithNullAddressId() {
   outsiderTeacherManager.removeAddress(null);
 }
コード例 #15
0
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailCreateWithNull() {
   outsiderTeacherManager.create(null);
 }
コード例 #16
0
 /*
  * removePhone()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailRemovePhoneWithNullPhoneId() {
   outsiderTeacherManager.removePhone(null);
 }
コード例 #17
0
 @Test(expected = PhoneResourceNotFoundException.class)
 public void shouldFailRemovePhoneWithNonExistingTeacher() {
   outsiderTeacherManager.removePhone(12L);
 }
コード例 #18
0
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddEmailWithEmailHavingIdAlreadyDefined() {
   Email model = EmailTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addEmail(12L, model);
 }
コード例 #19
0
 @Test(expected = PhoneTypeResourceNotFoundException.class)
 public void shouldFailAddPhoneWithPhoneHavingNonExistingType() {
   OutsiderTeacher model = scenarioHelper.createEmptyOutsiderTeacher();
   outsiderTeacherManager.addPhone(model.getId(), PhoneTest.createOne());
 }
コード例 #20
0
 /*
  * addPhone()
  */
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailAddPhoneWithNullTeacherId() {
   outsiderTeacherManager.addPhone(null, PhoneTest.createOne());
 }
コード例 #21
0
 @Test(expected = IllegalArgumentException.class)
 public void shouldFailFindOneByIdWithNull() {
   outsiderTeacherManager.findOneById(null);
 }
コード例 #22
0
 @Test(expected = TeacherResourceNotFoundException.class)
 public void shouldFailAddPhoneWithNonExistingTeacher() {
   PhoneType type = scenarioHelper.createPhoneType();
   outsiderTeacherManager.addPhone(12L, PhoneTest.createOne(type));
 }
コード例 #23
0
 @Test(expected = TeacherResourceNotFoundException.class)
 public void shouldFailFindOneByIdWithNonExisting() {
   outsiderTeacherManager.findOneById(156L);
 }
コード例 #24
0
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailAddPhoneWithPhoneHavingIdAlreadyDefined() {
   Phone model = PhoneTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.addPhone(12L, model);
 }