コード例 #1
0
  public void testPersist() {
    City city = newCity();
    IAddressService service = AddressServiceFactory.createAddressService();
    service.persist(city);

    assertNotNull(city.getId());
    CountryState state = city.getState();
    assertNotNull(state.getId());
    Country country = state.getCountry();
    assertNotNull(country.getId());

    List<Address> lista = service.findAllAddresses();
    assertTrue("It was not persisted", +lista.size() > 0);
  }
コード例 #2
0
  public void testUpdate() {
    City city = newCity();

    IAddressService service = AddressServiceFactory.createAddressService();
    service.persist(city);

    final String novoNome = "cidade do sol";

    city.setName(novoNome);
    city.getState().setName(novoNome);

    service.merge(city);

    City saved = service.findCityById(city.getId());

    assertEquals("The streets are diferent!", novoNome, saved.getName());

    // the merge cannot occur in the related elements.
    CountryState cs = service.findCountryStateById(city.getState().getId());
    assertNotEquals("It cant be updated! ", novoNome, cs.getName());
  }