Search in sources :

Example 6 with Category

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

the class CategoryRepository_findByParentCascade_IntegTest method when_grandchildren.

@Test
public void when_grandchildren() {
    // given
    Taxonomy parentSizes = (Taxonomy) categoryRepository.findByReference("SIZES");
    // when
    List<Category> childrenSizes = categoryRepository.findByParentCascade(parentSizes);
    // then
    assertThat(childrenSizes).hasSize(9);
    assertThat(childrenSizes).extracting(Category::getFullyQualifiedName).containsOnly("Sizes/Large", "Sizes/Medium", "Sizes/Small", "Sizes/Large/Largest", "Sizes/Large/Larger", "Sizes/Large/Large", "Sizes/Small/Small", "Sizes/Small/Smaller", "Sizes/Small/Smallest");
}
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)

Example 7 with Category

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

the class Category_name_IntegTest method cannot_rename_to_a_name_already_in_use.

@Test
public void cannot_rename_to_a_name_already_in_use() {
    // given
    Category red = categoryRepository.findByReference("FRRED");
    // then
    expectedExceptions.expect(InvalidException.class);
    expectedExceptions.expectMessage("A category with name 'White' already exists (under this parent)");
    // when
    wrap(red).setName("White");
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 8 with Category

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

the class Category_reference_IntegTest method happy_case.

@Test
public void happy_case() {
    // given
    Category smallest = categoryRepository.findByReference("XXS");
    // when
    smallest.modifyReference("V.SMALL");
    // then
    assertThat(smallest.getReference()).isEqualTo("V.SMALL");
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 9 with Category

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

the class Category_reference_IntegTest method can_clear.

@Test
public void can_clear() {
    // given
    Category smallest = categoryRepository.findByReference("XXS");
    // when
    smallest.setReference(null);
    // then
    assertThat(smallest.getReference()).isNull();
}
Also used : Category(org.incode.module.classification.dom.impl.category.Category) Test(org.junit.Test)

Example 10 with Category

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

the class DemoObjectWithAtPath_and_OtherObjectWithAtPath_create3 method execute.

@Override
protected void execute(final ExecutionContext executionContext) {
    // italian taxonomy applicable only to Italian DemoObject and OtherObject
    Taxonomy italianColours = categoryRepository.createTaxonomy("Italian Colours");
    italianColours.setReference("ITACOL");
    Category italianRed = italianColours.addChild("Red", "RED", null);
    Category italianGreen = italianColours.addChild("Green", "GREEN", null);
    Category italianWhite = italianColours.addChild("White", "WHITE", null);
    wrap(italianColours).applicable("/ITA", DemoObjectWithAtPath.class.getName());
    wrap(italianColours).applicable("/ITA", OtherObjectWithAtPath.class.getName());
    // french taxonomy applicable only to French DemoObject (and not to OtherObject even if with FRA app tenancy)
    Taxonomy frenchColours = categoryRepository.createTaxonomy("French Colours");
    frenchColours.setReference("FRCOL");
    Category frenchRed = frenchColours.addChild("Red", "FRRED", null);
    Category frenchWhite = frenchColours.addChild("White", "FRWHITE", null);
    Category frenchBlue = frenchColours.addChild("Blue", "FRBLUE", null);
    wrap(frenchColours).applicable("/FRA", DemoObjectWithAtPath.class.getName());
    // global taxonomy applicable only to DemoObject (any app tenancy)
    Taxonomy globalSizes = categoryRepository.createTaxonomy("Sizes");
    globalSizes.setReference("SIZES");
    Category large = globalSizes.addChild("Large", "LGE", 1);
    Category medium = globalSizes.addChild("Medium", "M", 2);
    Category small = globalSizes.addChild("Small", "SML", 3);
    Category largeLargest = large.addChild("Largest", "XXL", 1);
    Category largeLarger = large.addChild("Larger", "XL", 2);
    Category largeLarge = large.addChild("Large", "L", 3);
    Category smallSmall = small.addChild("Small", "S", 1);
    Category smallSmaller = small.addChild("Smaller", "XS", 2);
    Category smallSmallest = small.addChild("Smallest", "XXS", 3);
    wrap(globalSizes).applicable("/", DemoObjectWithAtPath.class.getName());
    // create a sample set of DemoObject and OtherObject, for various app tenancies
    final DemoObjectWithAtPath demoFooInItaly = createDemo("Demo foo (in Italy)", "/ITA", executionContext);
    final DemoObjectWithAtPath demoBarInFrance = createDemo("Demo bar (in France)", "/FRA", executionContext);
    final DemoObjectWithAtPath demoBaz = createDemo("Demo baz (Global)", "/", executionContext);
    final DemoObjectWithAtPath demoBip = createDemo("Demo bip (in Milan)", "/ITA/I-MIL", executionContext);
    final DemoObjectWithAtPath demoBop = createDemo("Demo bop (in Paris)", "/FRA/F-PAR", executionContext);
    final OtherObjectWithAtPath otherFooInItaly = createOther("Other foo (in Italy)", "/ITA", executionContext);
    final OtherObjectWithAtPath otherBarInFrance = createOther("Other bar (in France)", "/FRA", executionContext);
    final OtherObjectWithAtPath otherBaz = createOther("Other baz (Global)", "/", executionContext);
    final OtherObjectWithAtPath otherBip = createOther("Other bip (in Milan)", "/ITA/I-MIL", executionContext);
    final OtherObjectWithAtPath otherBop = createOther("Other bop (in Paris)", "/FRA/F-PAR", executionContext);
    // classify DemoObject
    wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoFooInItaly)).classify(italianColours, italianRed);
    wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoFooInItaly)).classify(globalSizes, medium);
    wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoBarInFrance)).classify(globalSizes, smallSmaller);
// leave OtherObject unclassified
}
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) OtherObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.otherwithatpath.OtherObjectWithAtPath)

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