Search in sources :

Example 1 with DemoObjectWithAtPath

use of org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath 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 2 with DemoObjectWithAtPath

use of org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath in project estatio by estatio.

the class T_classify_IntegTest method cannot_classify_when_applicability_but_classifications_already_defined.

@Test
public void cannot_classify_when_applicability_but_classifications_already_defined() {
    // given
    DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(demoObject -> demoObject.getName().equals("Demo foo (in Italy)")).findFirst().get();
    assertThat(classificationRepository.findByClassified(demoFooInItaly)).extracting(Classification::getCategory).extracting(Category::getName).contains("Red", "Medium");
    final ClassificationForDemoObjectWithAtPath.classify classification = factoryService.mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoFooInItaly);
    // when
    final String message = classification.disableClassify().toString();
    // then
    assertThat(message).isEqualTo("tr: There are no classifications that can be added");
}
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) Classification(org.incode.module.classification.dom.impl.classification.Classification) Test(org.junit.Test)

Example 3 with DemoObjectWithAtPath

use of org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath in project estatio by estatio.

the class T_unclassify_IntegTest method enabled_when_classifications_exist.

@Test
public void enabled_when_classifications_exist() {
    // given
    DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(demoObject -> demoObject.getName().equals("Demo foo (in Italy)")).findFirst().get();
    final List<Classification> byClassified = classificationRepository.findByClassified(demoFooInItaly);
    assertThat(byClassified).hasSize(2);
    // when
    final ClassificationForDemoObjectWithAtPath.unclassify unclassify = factoryService.mixin(ClassificationForDemoObjectWithAtPath.unclassify.class, demoFooInItaly);
    wrap(unclassify).unclassify(byClassified.get(0));
    // then
    assertThat(classificationRepository.findByClassified(demoFooInItaly)).hasSize(1);
}
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) Classification(org.incode.module.classification.dom.impl.classification.Classification) Test(org.junit.Test)

Example 4 with DemoObjectWithAtPath

use of org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath 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)

Example 5 with DemoObjectWithAtPath

use of org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath 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)

Aggregations

DemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)9 Classification (org.incode.module.classification.dom.impl.classification.Classification)7 Test (org.junit.Test)6 ClassificationForDemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath)5 Category (org.incode.module.classification.dom.impl.category.Category)3 Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)3 ArrayList (java.util.ArrayList)1 Applicability (org.incode.module.classification.dom.impl.applicability.Applicability)1 OtherObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.otherwithatpath.OtherObjectWithAtPath)1 Ignore (org.junit.Ignore)1