Search in sources :

Example 1 with Category

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

the class Category_removeChild_IntegTest method happy_case_cascading.

@Test
public void happy_case_cascading() {
    // given
    Category sizes = categoryRepository.findByReference("SIZES");
    Category large = categoryRepository.findByReference("LGE");
    assertThat(sizes.getChildren()).contains(large);
    assertThat(large.getChildren()).isNotEmpty();
    // when
    wrap(sizes).removeChild(large);
    transactionService.nextTransaction();
    // then
    assertThat(sizes.getChildren()).doesNotContain(large);
    assertThat(categoryRepository.findByReference("LGE")).isNull();
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 2 with Category

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

the class Classification_category_IntegTest method happy_case.

@Ignore
public void happy_case() {
    // given
    DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(demoObject -> demoObject.getName().equals("Demo foo (in Italy)")).findFirst().get();
    Classification italianClassificationRed = classificationRepository.findByClassified(demoFooInItaly).stream().filter(classification -> classification.getCategory().getName().equals("Red")).findFirst().get();
    Category italianGreen = categoryRepository.findByReference("GREEN");
    // when
    wrap(italianClassificationRed).setCategory(italianGreen);
    // then
    assertThat(classificationRepository.findByClassified(demoFooInItaly)).extracting(Classification::getCategory).extracting(Category::getName).contains("Green").doesNotContain("Red");
}
Also used : DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath) Category(org.incode.module.classification.dom.impl.category.Category) Classification(org.incode.module.classification.dom.impl.classification.Classification) Ignore(org.junit.Ignore)

Example 3 with Category

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

the class CategoryRepository_findByParentAndReference_IntegTest method when_none.

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

Example 4 with Category

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

the class CategoryRepository_findByParentAndName_IntegTest method happy_case.

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

Example 5 with Category

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

the class CategoryRepository_findByParentCascade_IntegTest method when_no_grandchildren.

@Test
public void when_no_grandchildren() {
    // given
    Category parentLarge = categoryRepository.findByReference("LGE");
    // when
    List<Category> childrenLarge = categoryRepository.findByParentCascade(parentLarge);
    // then
    assertThat(childrenLarge).hasSize(3);
    assertThat(childrenLarge).extracting(Category::getFullyQualifiedName).containsOnly("Sizes/Large/Large", "Sizes/Large/Larger", "Sizes/Large/Largest");
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) 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