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");
}
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");
}
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);
}
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);
}
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);
}
Aggregations