@Test public void testGetAttachmentEntity_failure() { handler.addRequest("GET", "/qcbin/rest/domains/domain/projects/project/defects/1/attachments/my%20name?alt=application/xml", 500) .responseBody("Not this time"); Entity entity = attachmentService.getAttachmentEntity("my name", new EntityRef("defect", 1)); Assert.assertNull(entity); checkError("Not this time"); }
public Entity getAttachmentEntity(Entity entity) { if(!"attachment".equals(entity.getType())) { throw new IllegalArgumentException("not an attachment entity"); } return getAttachmentEntity(entity.getPropertyValue("name"), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id")))); }
AttachmentService { public Entity getAttachmentEntity(Entity entity) { if(!"attachment".equals(entity.getType())) { throw new IllegalArgumentException("not an attachment entity"); } return getAttachmentEntity(entity.getPropertyValue("name"), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id")))); } }
AttachmentService { public Entity getAttachmentEntity(Entity entity) { if(!"attachment".equals(entity.getType())) { throw new IllegalArgumentException("not an attachment entity"); } return getAttachmentEntity(entity.getPropertyValue("name"), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id")))); } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); }
AttachmentService { public Entity getAttachmentEntity(Entity entity) { if(!"attachment".equals(entity.getType())) { throw new IllegalArgumentException("not an attachment entity"); } return getAttachmentEntity(entity.getPropertyValue("name"), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id")))); } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); Entity getAttachmentEntity(Entity entity); Entity getAttachmentEntity(String name, EntityRef parent); String createAttachment(String filename, IndicatingInputStream is, long length, EntityRef parent); boolean updateAttachmentContent(String name, EntityRef parent, IndicatingInputStream is, long length, boolean silent); Entity updateAttachmentProperty(String name, EntityRef parent, String propertyName, String propertyValue, boolean silent); void deleteAttachment(String name, EntityRef parent); }
AttachmentService { public Entity getAttachmentEntity(Entity entity) { if(!"attachment".equals(entity.getType())) { throw new IllegalArgumentException("not an attachment entity"); } return getAttachmentEntity(entity.getPropertyValue("name"), new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id")))); } AttachmentService(RestService restService, EntityService entityService, ErrorService errorService); Entity getAttachmentEntity(Entity entity); Entity getAttachmentEntity(String name, EntityRef parent); String createAttachment(String filename, IndicatingInputStream is, long length, EntityRef parent); boolean updateAttachmentContent(String name, EntityRef parent, IndicatingInputStream is, long length, boolean silent); Entity updateAttachmentProperty(String name, EntityRef parent, String propertyName, String propertyValue, boolean silent); void deleteAttachment(String name, EntityRef parent);  }