Search in sources :

Example 11 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class Taxonomy_applicable_IntegTest method can_add_applicability_for_same_domain_types_with_different_atPath.

@Test
public void can_add_applicability_for_same_domain_types_with_different_atPath() {
    // eg given an applicability for "/ITA" and 'DemoObject', can also add an applicability for "/ITA/MIL" and 'DemoObject'
    Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
    final List<Applicability> byDomainTypeAndUnderAtPath = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
    assertThat(byDomainTypeAndUnderAtPath).hasSize(2);
    assertThat(byDomainTypeAndUnderAtPath).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
    // when
    wrap(italianColours).applicable("/ITA/MIL", DemoObjectWithAtPath.class.getName());
    // then
    final List<Applicability> byDomainTypeAndUnderAtPathNew = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA/MIL");
    assertThat(byDomainTypeAndUnderAtPathNew).hasSize(3);
    assertThat(byDomainTypeAndUnderAtPathNew).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
}
Also used : DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Applicability(org.incode.module.classification.dom.impl.applicability.Applicability) Test(org.junit.Test)

Example 12 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class Taxonomy_notApplicable_IntegTest method cannot_.

@Test
public void cannot_() {
    // given
    Taxonomy dutchColours = categoryRepository.createTaxonomy("Dutch Colours");
    assertThat(dutchColours.getAppliesTo()).isEmpty();
    // when
    String message = dutchColours.disableNotApplicable().toString();
    // then
    assertThat(message).isEqualTo("tr: No applicabilities to remove");
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Test(org.junit.Test)

Example 13 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class Taxonomy_notApplicable_IntegTest method happy_case.

@Test
public void happy_case() {
    // given
    Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
    List<Applicability> applicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
    assertThat(applicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).containsOnly("Italian Colours", "Sizes");
    Applicability italianColoursApplicability = applicabilities.stream().filter(applicability -> applicability.getTaxonomy().getName().equals("Italian Colours")).findFirst().get();
    // when
    wrap(italianColours).notApplicable(italianColoursApplicability);
    // then
    List<Applicability> newApplicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
    assertThat(newApplicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).containsOnly("Sizes");
}
Also used : Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Applicability(org.incode.module.classification.dom.impl.applicability.Applicability) Test(org.junit.Test)

Example 14 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class Taxonomy_notApplicable_IntegTest method existing_classifications_are_ignored.

@Test
public void existing_classifications_are_ignored() {
    // given
    Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
    List<Applicability> applicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
    assertThat(applicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).contains("Italian Colours");
    Applicability italianColoursApplicability = applicabilities.stream().filter(applicability -> applicability.getTaxonomy().getName().equals("Italian Colours")).findFirst().get();
    DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(d -> d.getName().equals("Demo foo (in Italy)")).findFirst().get();
    List<Classification> classifications = classificationRepository.findByClassified(demoFooInItaly);
    assertThat(classifications).extracting(Classification::getTaxonomy).contains(italianColours);
    // when
    wrap(italianColours).notApplicable(italianColoursApplicability);
    // then
    assertThat(classificationRepository.findByClassified(demoFooInItaly)).extracting(Classification::getTaxonomy).contains(italianColours);
}
Also used : DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Classification(org.incode.module.classification.dom.impl.classification.Classification) Applicability(org.incode.module.classification.dom.impl.applicability.Applicability) Test(org.junit.Test)

Example 15 with Taxonomy

use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.

the class T_classify_IntegTest method when_applicability_and_no_classification.

@Test
public void when_applicability_and_no_classification() {
    // given
    DemoObjectWithAtPath demoBip = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(demoObject -> demoObject.getName().equals("Demo bip (in Milan)")).findFirst().get();
    assertThat(classificationRepository.findByClassified(demoBip)).isEmpty();
    // when
    final ClassificationForDemoObjectWithAtPath.classify classification = factoryService.mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoBip);
    Collection<Taxonomy> choices0Classify = classification.choices0Classify();
    assertThat(choices0Classify).extracting(Taxonomy::getName).containsOnly("Italian Colours", "Sizes");
    List<String> categoryNames = new ArrayList<>();
    for (Taxonomy taxonomy : choices0Classify) {
        Category category = classification.default1Classify(taxonomy);
        categoryNames.add(category.getName());
        wrap(classification).classify(taxonomy, category);
    }
    // then
    assertThat(classificationRepository.findByClassified(demoBip)).extracting(Classification::getCategory).extracting(Category::getName).containsOnlyElementsOf(categoryNames);
}
Also used : ClassificationForDemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath) ClassificationForDemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath) DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath) Category(org.incode.module.classification.dom.impl.category.Category) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Classification(org.incode.module.classification.dom.impl.classification.Classification) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)18 Test (org.junit.Test)11 Category (org.incode.module.classification.dom.impl.category.Category)7 DemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)5 Applicability (org.incode.module.classification.dom.impl.applicability.Applicability)4 Classification (org.incode.module.classification.dom.impl.classification.Classification)4 Programmatic (org.apache.isis.applib.annotation.Programmatic)2 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)2 OtherObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.otherwithatpath.OtherObjectWithAtPath)2 ClassificationForDemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath)2 ArrayList (java.util.ArrayList)1 DomainObject (org.apache.isis.applib.annotation.DomainObject)1 Bookmark (org.apache.isis.applib.services.bookmark.Bookmark)1 Property (org.estatio.module.asset.dom.Property)1 Unit (org.estatio.module.asset.dom.Unit)1 Lease (org.estatio.module.lease.dom.Lease)1 Occupancy (org.estatio.module.lease.dom.occupancy.Occupancy)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1