use of org.incode.module.classification.dom.impl.classification.Classification 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");
}
use of org.incode.module.classification.dom.impl.classification.Classification 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);
}
use of org.incode.module.classification.dom.impl.classification.Classification 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");
}
use of org.incode.module.classification.dom.impl.classification.Classification in project estatio by estatio.
the class ClassificationForOccImport method importData.
@Override
public List<Object> importData(final Object previousRow) {
final Lease lease = leaseRepository.findLeaseByReference(getLeaseReference());
if (lease == null) {
throw new IllegalArgumentException(String.format("No lease found for '%s'", getLeaseReference()));
}
final Unit unit = unitRepository.findUnitByReference(getUnitReference());
if (unit == null) {
throw new IllegalArgumentException(String.format("No unit found for '%s'", getUnitReference()));
}
final Occupancy occupancy = occupancyRepository.findByLease(lease).stream().filter(x -> x.getUnit().equals(unit)).findFirst().get();
if (occupancy == null) {
throw new IllegalArgumentException(String.format("No occupancy found for lease '%s' and unit '%s'", getLeaseReference(), getUnitReference()));
}
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, occupancy);
return Lists.newArrayList(classification);
}
Aggregations