@Test public void checkDeleteNoErrorIfEntityDoesNotExists() throws ODataJPAProcessException, ODataJPAModelException { final String id = "1"; final Organization beforImage = new Organization(id); doReturn(null).when(em).find(Organization.class, id); doReturn(helper.getJPAEntityType("Organizations")).when(requestEntity).getEntityType(); keys.put("iD", id); cut.deleteEntity(requestEntity, em); verify(em, times(0)).remove(beforImage); }
@Override public void deleteEntity(JPARequestEntity requestEntity, EntityManager em) throws ODataJPAProcessException { final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil().createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType())); if (instance != null) em.remove(instance); }
JPAExampleCUDRequestHandler extends JPAAbstractCUDRequestHandler { @Override public void deleteEntity(JPARequestEntity requestEntity, EntityManager em) throws ODataJPAProcessException { final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil().createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType())); if (instance != null) em.remove(instance); } }
JPAExampleCUDRequestHandler extends JPAAbstractCUDRequestHandler { @Override public void deleteEntity(JPARequestEntity requestEntity, EntityManager em) throws ODataJPAProcessException { final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil().createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType())); if (instance != null) em.remove(instance); } JPAExampleCUDRequestHandler(); }
JPAExampleCUDRequestHandler extends JPAAbstractCUDRequestHandler { @Override public void deleteEntity(JPARequestEntity requestEntity, EntityManager em) throws ODataJPAProcessException { final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil().createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType())); if (instance != null) em.remove(instance); } JPAExampleCUDRequestHandler(); @Override Object createEntity(final JPARequestEntity requestEntity, final EntityManager em); @Override void deleteEntity(JPARequestEntity requestEntity, EntityManager em); @Override JPAUpdateResult updateEntity(final JPARequestEntity requestEntity, final EntityManager em,
      final HttpMethod method); @Override void validateChanges(EntityManager em); }
JPAExampleCUDRequestHandler extends JPAAbstractCUDRequestHandler { @Override public void deleteEntity(JPARequestEntity requestEntity, EntityManager em) throws ODataJPAProcessException { final Object instance = em.find(requestEntity.getEntityType().getTypeClass(), requestEntity.getModifyUtil().createPrimaryKey(requestEntity.getEntityType(), requestEntity.getKeys(), requestEntity.getEntityType())); if (instance != null) em.remove(instance); } JPAExampleCUDRequestHandler(); @Override Object createEntity(final JPARequestEntity requestEntity, final EntityManager em); @Override void deleteEntity(JPARequestEntity requestEntity, EntityManager em); @Override JPAUpdateResult updateEntity(final JPARequestEntity requestEntity, final EntityManager em,
      final HttpMethod method); @Override void validateChanges(EntityManager em);  }