Search in sources :

Example 6 with Taxonomy

use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.

the class TaxonomyConfigServiceTest method merge_taxonomy_with_one_missing_vocabulary.

@Test
public void merge_taxonomy_with_one_missing_vocabulary() {
    Taxonomy tax001 = new Taxonomy("tax001");
    tax001.addVocabulary(createVocabulary("voc001", null, null));
    Taxonomy tax002 = new Taxonomy("tax002");
    new TaxonomyConfigService().mergeVocabulariesTerms(tax001, tax002);
    assert tax001.hasVocabulary("voc001");
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Test(org.junit.Test)

Example 7 with Taxonomy

use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.

the class TaxonomyConfigServiceTest method merge_taxonomy_with_one_having_extra_vocabulary.

@Test
public void merge_taxonomy_with_one_having_extra_vocabulary() {
    Taxonomy tax001 = new Taxonomy("tax001");
    Taxonomy tax002 = new Taxonomy("tax002");
    tax002.addVocabulary(createVocabulary("voc002", null, null));
    new TaxonomyConfigService().mergeVocabulariesTerms(tax001, tax002);
    assert tax001.hasVocabulary("voc002");
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Test(org.junit.Test)

Example 8 with Taxonomy

use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.

the class TaxonomyConfigServiceTest method validateTaxonomyDuplicateAlias.

@Test(expected = VocabularyDuplicateAliasException.class)
public void validateTaxonomyDuplicateAlias() {
    Taxonomy taxonomy = new Taxonomy("tax001");
    taxonomy.addVocabulary(createVocabulary("voc001", null, AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc").build()));
    taxonomy.addVocabulary(createVocabulary("voc002", null, AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc").build()));
    new TaxonomyConfigService().validateTaxonomy(taxonomy);
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Test(org.junit.Test)

Example 9 with Taxonomy

use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.

the class TaxonomyConfigServiceTest method validateRangeTaxonomyWithoutTermsAndRange.

@Test
public void validateRangeTaxonomyWithoutTermsAndRange() {
    Taxonomy taxonomy = new Taxonomy("tax001");
    taxonomy.addVocabulary(createVocabulary("voc001", null, AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc-range").type("integer").build()));
    new TaxonomyConfigService().validateTaxonomy(taxonomy);
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Test(org.junit.Test)

Example 10 with Taxonomy

use of org.obiba.opal.core.domain.taxonomy.Taxonomy in project mica2 by obiba.

the class TaxonomyConfigServiceTest method validateRangeTaxonomyWithTerms.

@Test
public void validateRangeTaxonomyWithTerms() {
    Taxonomy taxonomy = new Taxonomy("tax001");
    taxonomy.addVocabulary(createVocabulary("voc001", createTerms("term001", "term002"), AttributeBuilder.newBuilder().field("tax.voc").alias("tax-voc-range").range("true").build()));
    new TaxonomyConfigService().validateTaxonomy(taxonomy);
}
Also used : Taxonomy(org.obiba.opal.core.domain.taxonomy.Taxonomy) Test(org.junit.Test)

Aggregations

Taxonomy (org.obiba.opal.core.domain.taxonomy.Taxonomy)22 Test (org.junit.Test)10 Vocabulary (org.obiba.opal.core.domain.taxonomy.Vocabulary)6 Map (java.util.Map)4 TaxonomyTarget (org.obiba.mica.spi.search.TaxonomyTarget)3 Timed (com.codahale.metrics.annotation.Timed)2 Strings (com.google.common.base.Strings)2 List (java.util.List)2 Inject (javax.inject.Inject)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 TaxonomyResolver.asMap (org.obiba.mica.taxonomy.TaxonomyResolver.asMap)2 Term (org.obiba.opal.core.domain.taxonomy.Term)2 Opal (org.obiba.opal.web.model.Opal)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 File (java.io.File)1 URI (java.net.URI)1