コード例 #1
0
  @Test
  public void shouldFindOneById() {
    OutsiderTeacher model = OutsiderTeacherTest.createOne();
    scenarioHelper.createOutsiderTeacher(model);

    OutsiderTeacher fetched = outsiderTeacherManager.findOneById(model.getId());
    assertThat(fetched).isNotNull();
  }
コード例 #2
0
  @Test
  public void shouldDeleteAddressAndEmailAndPhoneOnCascade() {
    OutsiderTeacher model = OutsiderTeacherTest.createOne();
    scenarioHelper.createOutsiderTeacher(model);
    outsiderTeacherRepository.delete(new OutsiderTeacherDomain(model));

    assertThat(addressRepository.findAll()).isEmpty();
    assertThat(emailRepository.findAll()).isEmpty();
    assertThat(phoneRepository.findAll()).isEmpty();
  }
コード例 #3
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());
  }
コード例 #4
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());
  }
コード例 #5
0
 @Test(expected = AlreadyDefinedInOnNonPersistedEntity.class)
 public void shouldFailCreateIfIdIsAlreadyDefined() {
   OutsiderTeacher model = OutsiderTeacherTest.createOne();
   model.setId(12L);
   outsiderTeacherManager.create(model);
 }