@Test @TestTarget(ServerVersion.ALM11) public void testCreateEntity_MayaLink_silentFailure() { handler.addRequest(false, "POST", "/qcbin/rest/domains/domain/projects/project/defects/86/defect-links", 500) .responseBody("Failed"); Entity link = new Entity("defect-link"); link.setProperty("first-endpoint-id", "86"); Entity created = entityService.createEntity(link, true); Assert.assertNull(created); }
public Entity createEntity(Entity entity, boolean silent) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return createOldDefectLink(entity, silent); } String xml = XMLOutputterFactory.getXMLOutputter().outputString(new Document(entity.toElement(null))); MyResultInfo result = new MyResultInfo(); if(restService.post(xml, result, "{0}s", entity.getType()) != HttpStatus.SC_CREATED) { if(!silent) { errorService.showException(new RestException(result)); } return null; } else { return parseEntityAndFireEvent(result.getBodyAsStream(), EntityListener.Event.CREATE); } }
EntityService { public Entity createEntity(Entity entity, boolean silent) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return createOldDefectLink(entity, silent); } String xml = XMLOutputterFactory.getXMLOutputter().outputString(new Document(entity.toElement(null))); MyResultInfo result = new MyResultInfo(); if(restService.post(xml, result, "{0}s", entity.getType()) != HttpStatus.SC_CREATED) { if(!silent) { errorService.showException(new RestException(result)); } return null; } else { return parseEntityAndFireEvent(result.getBodyAsStream(), EntityListener.Event.CREATE); } } }
EntityService { public Entity createEntity(Entity entity, boolean silent) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return createOldDefectLink(entity, silent); } String xml = XMLOutputterFactory.getXMLOutputter().outputString(new Document(entity.toElement(null))); MyResultInfo result = new MyResultInfo(); if(restService.post(xml, result, "{0}s", entity.getType()) != HttpStatus.SC_CREATED) { if(!silent) { errorService.showException(new RestException(result)); } return null; } else { return parseEntityAndFireEvent(result.getBodyAsStream(), EntityListener.Event.CREATE); } } EntityService(Project project, RestService restService, MetadataService metadataService, ErrorService errorService); }
EntityService { public Entity createEntity(Entity entity, boolean silent) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return createOldDefectLink(entity, silent); } String xml = XMLOutputterFactory.getXMLOutputter().outputString(new Document(entity.toElement(null))); MyResultInfo result = new MyResultInfo(); if(restService.post(xml, result, "{0}s", entity.getType()) != HttpStatus.SC_CREATED) { if(!silent) { errorService.showException(new RestException(result)); } return null; } else { return parseEntityAndFireEvent(result.getBodyAsStream(), EntityListener.Event.CREATE); } } 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 Entity createEntity(Entity entity, boolean silent) { if("defect-link".equals(entity.getType()) && restService.getServerStrategy().hasSecondLevelDefectLink()) { return createOldDefectLink(entity, silent); } String xml = XMLOutputterFactory.getXMLOutputter().outputString(new Document(entity.toElement(null))); MyResultInfo result = new MyResultInfo(); if(restService.post(xml, result, "{0}s", entity.getType()) != HttpStatus.SC_CREATED) { if(!silent) { errorService.showException(new RestException(result)); } return null; } else { return parseEntityAndFireEvent(result.getBodyAsStream(), EntityListener.Event.CREATE); } } 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);  }