Search in sources :

Example 6 with DemoObjectWithAtPath

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

the class Classification_remove_IntegTest method happy_case.

@Test
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();
    // when
    wrap(italianClassificationRed).remove();
    // then
    assertThat(classificationRepository.findByClassified(demoFooInItaly)).extracting(Classification::getCategory).extracting(Category::getName).doesNotContain("Red");
}
Also used : 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 7 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 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 8 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 createDemo.

private DemoObjectWithAtPath createDemo(final String name, final String atPath, final ExecutionContext executionContext) {
    final DemoObjectWithAtPath demoObject = wrap(demoObjectMenu).createDemoObjectWithAtPath(name, atPath);
    demoObjects.add(demoObject);
    return executionContext.addResult(this, demoObject);
}
Also used : ClassificationForDemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath) DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)

Example 9 with DemoObjectWithAtPath

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

the class CategoryRepository_findByClassified_IntegTest method happy_case.

@Test
public void happy_case() {
    // given
    DemoObjectWithAtPath demoFooInItaly = demoObjectMenu.listAllDemoObjectsWithAtPath().stream().filter(d -> d.getName().equals("Demo foo (in Italy)")).findFirst().get();
    assertThat(demoFooInItaly).isNotNull();
    // when
    List<Classification> classifications = classificationRepository.findByClassified(demoFooInItaly);
    // then
    assertThat(classifications.size()).isEqualTo(2);
    assertThat(classifications).extracting(Classification::getCategory).extracting(Category::getName).containsOnly("Red", "Medium");
}
Also used : DemoObjectWithAtPath(org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath) Classification(org.incode.module.classification.dom.impl.classification.Classification) 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