示例#1
0
  public static DefaultAttributeMetaData getCompoundResultAttribute(
      RepositoryAnnotator annotator, EntityMetaData entityMetaData) {
    DefaultAttributeMetaData compoundAttributeMetaData =
        new DefaultAttributeMetaData(
            annotator.getFullName(), MolgenisFieldTypes.FieldTypeEnum.COMPOUND);
    compoundAttributeMetaData.setLabel(annotator.getSimpleName());

    List<AttributeMetaData> outputAttrs = annotator.getOutputMetaData();

    if (outputAttrs.size() == 1
        && Iterables.get(outputAttrs, 0)
            .getDataType()
            .getEnumType()
            .equals(MolgenisFieldTypes.FieldTypeEnum.COMPOUND)) {
      compoundAttributeMetaData = (DefaultAttributeMetaData) outputAttrs.get(0);
    } else {
      for (AttributeMetaData currentAmd : outputAttrs) {
        String currentAttributeName = currentAmd.getName();
        if (entityMetaData.getAttribute(currentAttributeName) == null) {
          compoundAttributeMetaData.addAttributePart(currentAmd);
        }
      }
    }
    return compoundAttributeMetaData;
  }
  @BeforeMethod
  public void beforeMethod() {
    annotationService = new AnnotationServiceImpl();
    metaData = mock(EntityMetaData.class);

    annotator1 = mock(RepositoryAnnotator.class);
    when(annotator1.getName()).thenReturn("annotator1");
    when(annotator1.canAnnotate(metaData)).thenReturn(false);
    annotationService.addAnnotator(annotator1);

    annotator2 = mock(RepositoryAnnotator.class);
    when(annotator2.getName()).thenReturn("annotator2");
    when(annotator2.canAnnotate(metaData)).thenReturn(true);
    annotationService.addAnnotator(annotator2);

    annotator3 = mock(RepositoryAnnotator.class);
    when(annotator3.getName()).thenReturn("annotator3");
    when(annotator3.canAnnotate(metaData)).thenReturn(true);
    annotationService.addAnnotator(annotator3);
  }