public List<OntologyTerm> findTags(String description, List<String> ontologyIds) {
    Set<String> searchTerms = removeStopWords(description);

    List<OntologyTerm> matchingOntologyTerms =
        ontologyService.findOntologyTerms(ontologyIds, searchTerms, MAX_NUM_TAGS);

    return matchingOntologyTerms;
  }
  @Test
  public void testSearchUnicode() throws InterruptedException, ExecutionException {
    Mockito.reset(ontologyService);
    attribute.setDescription("/əˈnædrəməs/");

    when(ontologyService.findOntologyTerms(ontologies, ImmutableSet.of("əˈnædrəməs"), 100))
        .thenReturn(ontologyTerms);
    Hit<OntologyTerm> result = semanticSearchService.findTags(attribute, ontologies);
    assertEquals(result, null);
  }
 @Test
 public void testSearchDescription() throws InterruptedException, ExecutionException {
   Mockito.reset(ontologyService);
   attribute.setDescription("Standing height in meters.");
   when(ontologyService.findOntologyTerms(
           ontologies, ImmutableSet.<String>of("standing", "height", "meters"), 100))
       .thenReturn(ontologyTerms);
   Hit<OntologyTerm> result = semanticSearchService.findTags(attribute, ontologies);
   assertEquals(result, Hit.<OntologyTerm>create(standingHeight, 0.81250f));
 }
 @Test
 public void testSearchHypertension() throws InterruptedException, ExecutionException {
   Mockito.reset(ontologyService);
   attribute.setDescription("History of Hypertension");
   when(ontologyService.findOntologyTerms(
           ontologies, ImmutableSet.<String>of("history", "hypertens"), 100))
       .thenReturn(ontologyTerms);
   Hit<OntologyTerm> result = semanticSearchService.findTags(attribute, ontologies);
   assertEquals(result, null);
 }
  @Test
  public void testSearchMultipleTags() throws InterruptedException, ExecutionException {
    Mockito.reset(ontologyService);
    attribute.setDescription("Body mass index");

    when(ontologyService.findOntologyTerms(
            ontologies, ImmutableSet.of("body", "mass", "index"), 100))
        .thenReturn(ontologyTerms);
    Hit<OntologyTerm> result = semanticSearchService.findTags(attribute, ontologies);
    assertEquals(result, null);
  }
  @Test
  public void testFindAttributes() {
    DefaultEntityMetaData sourceEntityMetaData = new DefaultEntityMetaData("sourceEntityMetaData");
    EntityMetaData targetEntityMetaData = new DefaultEntityMetaData("targetEntityMetaData");
    DefaultAttributeMetaData targetAttribute = new DefaultAttributeMetaData("targetAttribute");

    // Mock the id's of the attribute entities that should be searched
    List<String> attributeIdentifiers = Arrays.asList("1", "2");
    when(semanticSearchServiceHelper.getAttributeIdentifiers(sourceEntityMetaData))
        .thenReturn(attributeIdentifiers);

    // Mock the createDisMaxQueryRule method
    List<QueryRule> rules = new ArrayList<QueryRule>();
    QueryRule targetQueryRuleLabel =
        new QueryRule(AttributeMetaDataMetaData.LABEL, Operator.FUZZY_MATCH, "height");
    rules.add(targetQueryRuleLabel);
    QueryRule targetQueryRuleOntologyTermTag =
        new QueryRule(AttributeMetaDataMetaData.LABEL, Operator.FUZZY_MATCH, "standing height");
    rules.add(targetQueryRuleOntologyTermTag);
    QueryRule targetQueryRuleOntologyTermTagSyn =
        new QueryRule(AttributeMetaDataMetaData.LABEL, Operator.FUZZY_MATCH, "length");
    rules.add(targetQueryRuleOntologyTermTagSyn);
    QueryRule disMaxQueryRule = new QueryRule(rules);
    disMaxQueryRule.setOperator(Operator.DIS_MAX);

    when(semanticSearchServiceHelper.createDisMaxQueryRuleForAttribute(
            targetEntityMetaData, targetAttribute))
        .thenReturn(disMaxQueryRule);

    MapEntity entity1 =
        new MapEntity(
            ImmutableMap.of(
                AttributeMetaDataMetaData.NAME,
                "height_0",
                AttributeMetaDataMetaData.LABEL,
                "height",
                AttributeMetaDataMetaData.DESCRIPTION,
                "this is a height measurement in m!"));
    List<Entity> attributeMetaDataEntities = Arrays.<Entity>asList(entity1);

    List<QueryRule> disMaxQueryRules =
        Lists.newArrayList(
            new QueryRule(AttributeMetaDataMetaData.IDENTIFIER, Operator.IN, attributeIdentifiers),
            new QueryRule(Operator.AND),
            disMaxQueryRule);

    AttributeMetaData attributeHeight = new DefaultAttributeMetaData("height_0");
    AttributeMetaData attributeWeight = new DefaultAttributeMetaData("weight_0");
    sourceEntityMetaData.addAttributeMetaData(attributeHeight);
    sourceEntityMetaData.addAttributeMetaData(attributeWeight);

    // Case 1
    when(dataService.findAll(
            AttributeMetaDataMetaData.ENTITY_NAME, new QueryImpl(disMaxQueryRules)))
        .thenReturn(attributeMetaDataEntities);

    Iterable<AttributeMetaData> termsActual1 =
        semanticSearchService.findAttributes(
            sourceEntityMetaData, targetEntityMetaData, targetAttribute);

    Iterable<AttributeMetaData> termsExpected1 = Arrays.<AttributeMetaData>asList(attributeHeight);

    assertEquals(termsActual1, termsExpected1);

    // Case 2
    when(dataService.findAll(
            AttributeMetaDataMetaData.ENTITY_NAME, new QueryImpl(disMaxQueryRules)))
        .thenReturn(Arrays.<Entity>asList());

    Iterable<AttributeMetaData> termsActual2 =
        semanticSearchService.findAttributes(
            sourceEntityMetaData, targetEntityMetaData, targetAttribute);

    Iterable<AttributeMetaData> termsExpected2 = Arrays.<AttributeMetaData>asList();

    assertEquals(termsActual2, termsExpected2);

    Mockito.reset(ontologyService);
    attribute.setDescription("Standing height (Ångstrøm)");

    when(ontologyService.findOntologyTerms(
            ontologies, ImmutableSet.of("standing", "height", "ångstrøm"), 100))
        .thenReturn(ontologyTerms);
    Hit<OntologyTerm> result = semanticSearchService.findTags(attribute, ontologies);
    assertEquals(result, Hit.<OntologyTerm>create(standingHeight, 0.76471f));
  }