@Test public void deveLancarExcecaoQuandoPersistirUmaInstanciaNula() { try { this.keeper.persist(null); } catch (RepositoryException e) { assertEquals(ErrorEnum.NULL_INSTANCE.getMessage(), e.getMessage()); } }
@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(""))); } }
@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()); } }