@Test public void testGetAttachmentEntity_illegal() { Entity defect = new Entity("defect", 1); try { attachmentService.getAttachmentEntity(defect); Assert.fail("should have failed"); } catch (IllegalArgumentException e) { } }
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);  }