예제 #1
0
 @Test
 public void deveLancarExcecaoQuandoPersistirUmaInstanciaNula() {
   try {
     this.keeper.persist(null);
   } catch (RepositoryException e) {
     assertEquals(ErrorEnum.NULL_INSTANCE.getMessage(), e.getMessage());
   }
 }
예제 #2
0
  @Test
  public void deveLancarExcecaoQuandoHouverUmaExcecaoJPANoRemoveFisico() {
    try {
      this.manager.close();

      EntidadeExemplo instance = new EntidadeExemplo();
      this.keeper.remove(instance, RemoveEnum.PHYSICAL);
    } catch (RepositoryException e) {
      assertTrue(e.getMessage().contains(ErrorEnum.UNEXPECTED_EXCEPTION.getMessage("")));
    }
  }
예제 #3
0
  @Test
  public void naoDeveLancarExcecaoQuandoRemoverDeFormaFisicaUmaInstanciaInexistente() {
    try {
      EntidadeExemplo instance = new EntidadeExemplo();

      this.keeper.persist(instance);
      assertNotNull(instance.getId());
      assertTrue(instance.getActive());
      assertTrue(this.manager.contains(instance));

      this.keeper.remove(instance, RemoveEnum.PHYSICAL);

      assertNotNull(instance.getId());
      assertTrue(instance.getActive());
      assertFalse(this.manager.contains(instance));
      assertNull(this.manager.find(EntidadeExemplo.class, instance.getId()));

      this.keeper.remove(instance, RemoveEnum.PHYSICAL);
    } catch (RepositoryException e) {
      fail(e.getMessage());
    }
  }