Search in sources :

Example 16 with Category

use of org.incode.module.classification.dom.impl.category.Category 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)

Example 17 with Category

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

the class CategoryRepository_findByParentAndReference_IntegTest method happy_case.

@Test
public void happy_case() {
    // given
    Category parentLarge = categoryRepository.findByReference("LGE");
    // when
    Category childLarge = categoryRepository.findByParentAndReference(parentLarge, "XL");
    // then
    assertThat(childLarge.getName()).isEqualTo("Larger");
    assertThat(childLarge.getParent()).isEqualTo(parentLarge);
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 18 with Category

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

the class CategoryRepository_findByParent_IntegTest method happy_case.

@Test
public void happy_case() {
    // given
    Category large = categoryRepository.findByReference("LGE");
    // when
    List<Category> results = categoryRepository.findByParent(large);
    // then
    assertThat(results).hasSize(3);
    assertThat(results).allMatch(c -> c.getParent().equals(large));
    assertThat(results).extracting(Category::getReference).containsOnly("L", "XL", "XXL");
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 19 with Category

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

the class CategoryRepository_findByParent_IntegTest method when_none.

@Test
public void when_none() {
    // given
    Category frenchRed = categoryRepository.findByReference("FRRED");
    // when
    List<Category> results = categoryRepository.findByParent(frenchRed);
    // then
    assertThat(results).isEmpty();
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 20 with Category

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

the class CategoryRepository_findByParentAndName_IntegTest method when_none.

@Test
public void when_none() {
    // given
    Taxonomy parentFrenchColours = (Taxonomy) categoryRepository.findByReference("FRCOL");
    // when
    Category childFrenchColours = categoryRepository.findByParentAndName(parentFrenchColours, "Nonexisting");
    // then
    assertThat(childFrenchColours).isNull();
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Taxonomy(org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy) Test(org.junit.Test)

Aggregations

Category (org.incode.module.classification.dom.impl.category.Category)27 Test (org.junit.Test)22 Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)7 Classification (org.incode.module.classification.dom.impl.classification.Classification)4 DemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)3 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 TranslatableString (org.apache.isis.applib.services.i18n.TranslatableString)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 OtherObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.otherwithatpath.OtherObjectWithAtPath)1 ApplicationTenancy (org.isisaddons.module.security.dom.tenancy.ApplicationTenancy)1 Ignore (org.junit.Ignore)1