Search in sources :

Example 1 with Classification

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

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

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

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

the class ClassificationForPropertyImport method importData.

@Override
public List<Object> importData(final Object previousRow) {
    final Property property = propertyRepository.findPropertyByReference(getPropertyReference());
    if (property == null) {
        throw new IllegalArgumentException(String.format("No property found for '%s'", getPropertyReference()));
    }
    final Taxonomy taxonomy = (Taxonomy) categoryRepository.findByReference(getTaxonomyReference());
    if (taxonomy == null) {
        throw new IllegalArgumentException(String.format("No taxonomy found for '%s'", getTaxonomyReference()));
    }
    final Category category = categoryRepository.findByTaxonomyAndReference(taxonomy, getCategoryReference());
    if (category == null) {
        throw new IllegalArgumentException(String.format("No category found for '%s'", getCategoryReference()));
    }
    final Classification classification = classificationRepository.create(category, property);
    return Lists.newArrayList(classification);
}
Also used : 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) Property(org.estatio.module.asset.dom.Property)

Example 5 with Classification

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

Classification (org.incode.module.classification.dom.impl.classification.Classification)9 DemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.demo.dom.demowithatpath.DemoObjectWithAtPath)7 Test (org.junit.Test)6 Category (org.incode.module.classification.dom.impl.category.Category)4 Taxonomy (org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy)4 ClassificationForDemoObjectWithAtPath (org.incode.platform.dom.classification.integtests.dom.classification.dom.classification.demowithatpath.ClassificationForDemoObjectWithAtPath)3 ArrayList (java.util.ArrayList)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 Applicability (org.incode.module.classification.dom.impl.applicability.Applicability)1 Ignore (org.junit.Ignore)1