@Test @TestTarget(ServerVersion.AGM) public void testDeleteEntity() { handler.addRequest(false, "DELETE", "/qcbin/rest/domains/domain/projects/project/defects/86", 200); handler.async(); addEntityListener(new EntityNotFound(handler, "defect", 86, true)); Entity defect = new Entity("defect", 86); boolean deleted = entityService.deleteEntity(defect); Assert.assertTrue(deleted); }
public boolean deleteEntity(Entity entity) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return deleteOldDefectLink(entity); } MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}", entity.getType(), entity.getId()) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); return false; } else { fireEntityNotFound(new EntityRef(entity), true); return true; } }
EntityService { public boolean deleteEntity(Entity entity) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return deleteOldDefectLink(entity); } MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}", entity.getType(), entity.getId()) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); return false; } else { fireEntityNotFound(new EntityRef(entity), true); return true; } } }
EntityService { public boolean deleteEntity(Entity entity) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return deleteOldDefectLink(entity); } MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}", entity.getType(), entity.getId()) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); return false; } else { fireEntityNotFound(new EntityRef(entity), true); return true; } } EntityService(Project project, RestService restService, MetadataService metadataService, ErrorService errorService); }
EntityService { public boolean deleteEntity(Entity entity) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return deleteOldDefectLink(entity); } MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}", entity.getType(), entity.getId()) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); return false; } else { fireEntityNotFound(new EntityRef(entity), true); return true; } } EntityService(Project project, RestService restService, MetadataService metadataService, ErrorService errorService); void addEntityListener(EntityListener listener); void removeEntityListener(EntityListener listener); void refreshEntity(EntityRef ref); void getEntityAsync(EntityRef ref, EntityListener callback); Entity getEntity(EntityRef ref); EntityList query(EntityQuery query); InputStream queryForStream(EntityQuery query); Entity getDefectLink(int defectId, int linkId); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent, boolean reloadOnFailure); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent, boolean reloadOnFailure, boolean fireUpdate); Entity createEntity(Entity entity, boolean silent); Entity lockEntity(Entity entity, boolean silent); boolean deleteEntity(Entity entity); void unlockEntity(Entity entity); void fireEntityLoaded(final Entity entity, final EntityListener.Event event); void fireEntityNotFound(final EntityRef ref, final boolean removed); void requestCachedEntity(final EntityRef ref, final List<String> properties, final EntityListener callback); }
EntityService { public boolean deleteEntity(Entity entity) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return deleteOldDefectLink(entity); } MyResultInfo result = new MyResultInfo(); if(restService.delete(result, "{0}s/{1}", entity.getType(), entity.getId()) != HttpStatus.SC_OK) { errorService.showException(new RestException(result)); return false; } else { fireEntityNotFound(new EntityRef(entity), true); return true; } } EntityService(Project project, RestService restService, MetadataService metadataService, ErrorService errorService); void addEntityListener(EntityListener listener); void removeEntityListener(EntityListener listener); void refreshEntity(EntityRef ref); void getEntityAsync(EntityRef ref, EntityListener callback); Entity getEntity(EntityRef ref); EntityList query(EntityQuery query); InputStream queryForStream(EntityQuery query); Entity getDefectLink(int defectId, int linkId); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent, boolean reloadOnFailure); Entity updateEntity(Entity entity, Set<String> fieldsToUpdate, boolean silent, boolean reloadOnFailure, boolean fireUpdate); Entity createEntity(Entity entity, boolean silent); Entity lockEntity(Entity entity, boolean silent); boolean deleteEntity(Entity entity); void unlockEntity(Entity entity); void fireEntityLoaded(final Entity entity, final EntityListener.Event event); void fireEntityNotFound(final EntityRef ref, final boolean removed); void requestCachedEntity(final EntityRef ref, final List<String> properties, final EntityListener callback);  }