@Test(
     expectedExceptions = {IllegalArgumentException.class},
     expectedExceptionsMessageRegExp = TestsUtil.PRECONDITION_FAILED_REGEX)
 public void imageAnnotationLinkerShouldRejectNullAnnotationParam() {
   AnnotationLinker linker = AnnotationLinkers.forAnnotatedType(AnnotatedType.image);
   linker.link(null, newImage("image.name"));
 }
 @Test(
     expectedExceptions = {IllegalArgumentException.class},
     expectedExceptionsMessageRegExp = TestsUtil.PRECONDITION_FAILED_REGEX)
 public void imageAnnotationLinkerShouldRejectNullModelObjectParam() {
   AnnotationLinker linker = AnnotationLinkers.forAnnotatedType(AnnotatedType.image);
   linker.link(newAttachment("some.annotation"), null);
 }
  @Test
  public void datasetAnnotationLinkerTests() {
    AnnotationLinker linker = AnnotationLinkers.forAnnotatedType(AnnotatedType.dataset);

    IObject result = linker.link(newAttachment("dataset.annotation"), newDataset("dataset.name"));

    assertNotNull(result, "Non-null results expected");
    assertTrue(result instanceof DatasetAnnotationLinkI, "Incorrect link type");

    DatasetAnnotationLinkI link = (DatasetAnnotationLinkI) result;
    assertNotNull(link.getParent(), "Non-null link parent expected");
    assertNotNull(link.getChild(), "Non-null link child expected");
  }
 @Test(expectedExceptions = {ClassCastException.class})
 public void imageAnnotationLinkerShouldRaiseClassCastOnInvalidModelObject() {
   AnnotationLinker linker = AnnotationLinkers.forAnnotatedType(AnnotatedType.image);
   linker.link(newAttachment("some.annotation"), newDataset("dataset.name"));
 }