use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.
the class Taxonomy_applicable_IntegTest method can_add_applicability_for_same_domain_types_with_different_atPath.
@Test
public void can_add_applicability_for_same_domain_types_with_different_atPath() {
// eg given an applicability for "/ITA" and 'DemoObject', can also add an applicability for "/ITA/MIL" and 'DemoObject'
Taxonomy italianColours = (Taxonomy) categoryRepository.findByParentAndName(null, "Italian Colours");
final List<Applicability> byDomainTypeAndUnderAtPath = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(byDomainTypeAndUnderAtPath).hasSize(2);
assertThat(byDomainTypeAndUnderAtPath).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
// when
wrap(italianColours).applicable("/ITA/MIL", DemoObjectWithAtPath.class.getName());
// then
final List<Applicability> byDomainTypeAndUnderAtPathNew = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA/MIL");
assertThat(byDomainTypeAndUnderAtPathNew).hasSize(3);
assertThat(byDomainTypeAndUnderAtPathNew).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getFullyQualifiedName).containsOnly("Italian Colours", "Sizes");
}
use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.
the class Taxonomy_notApplicable_IntegTest method cannot_.
@Test
public void cannot_() {
// given
Taxonomy dutchColours = categoryRepository.createTaxonomy("Dutch Colours");
assertThat(dutchColours.getAppliesTo()).isEmpty();
// when
String message = dutchColours.disableNotApplicable().toString();
// then
assertThat(message).isEqualTo("tr: No applicabilities to remove");
}
use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy in project estatio by estatio.
the class Taxonomy_notApplicable_IntegTest method happy_case.
@Test
public void happy_case() {
// 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).containsOnly("Italian Colours", "Sizes");
Applicability italianColoursApplicability = applicabilities.stream().filter(applicability -> applicability.getTaxonomy().getName().equals("Italian Colours")).findFirst().get();
// when
wrap(italianColours).notApplicable(italianColoursApplicability);
// then
List<Applicability> newApplicabilities = applicabilityRepository.findByDomainTypeAndUnderAtPath(DemoObjectWithAtPath.class, "/ITA");
assertThat(newApplicabilities).extracting(Applicability::getTaxonomy).extracting(Taxonomy::getName).containsOnly("Sizes");
}
use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy 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);
}
use of org.incode.module.classification.dom.impl.category.taxonomy.Taxonomy 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);
}
Aggregations