use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class CategoryRepository_findByParentCascade_IntegTest method when_grandchildren.
@Test
public void when_grandchildren() {
// given
Taxonomy parentSizes = (Taxonomy) categoryRepository.findByReference("SIZES");
// when
List<Category> childrenSizes = categoryRepository.findByParentCascade(parentSizes);
// then
assertThat(childrenSizes).hasSize(9);
assertThat(childrenSizes).extracting(Category::getFullyQualifiedName).containsOnly("Sizes/Large", "Sizes/Medium", "Sizes/Small", "Sizes/Large/Largest", "Sizes/Large/Larger", "Sizes/Large/Large", "Sizes/Small/Small", "Sizes/Small/Smaller", "Sizes/Small/Smallest");
}
use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class Category_name_IntegTest method cannot_rename_to_a_name_already_in_use.
@Test
public void cannot_rename_to_a_name_already_in_use() {
// given
Category red = categoryRepository.findByReference("FRRED");
// then
expectedExceptions.expect(InvalidException.class);
expectedExceptions.expectMessage("A category with name 'White' already exists (under this parent)");
// when
wrap(red).setName("White");
}
use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class Category_reference_IntegTest method happy_case.
@Test
public void happy_case() {
// given
Category smallest = categoryRepository.findByReference("XXS");
// when
smallest.modifyReference("V.SMALL");
// then
assertThat(smallest.getReference()).isEqualTo("V.SMALL");
}
use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class Category_reference_IntegTest method can_clear.
@Test
public void can_clear() {
// given
Category smallest = categoryRepository.findByReference("XXS");
// when
smallest.setReference(null);
// then
assertThat(smallest.getReference()).isNull();
}
use of org.incode.module.classification.dom.impl.category.Category in project estatio by estatio.
the class DemoObjectWithAtPath_and_OtherObjectWithAtPath_create3 method execute.
@Override
protected void execute(final ExecutionContext executionContext) {
// italian taxonomy applicable only to Italian DemoObject and OtherObject
Taxonomy italianColours = categoryRepository.createTaxonomy("Italian Colours");
italianColours.setReference("ITACOL");
Category italianRed = italianColours.addChild("Red", "RED", null);
Category italianGreen = italianColours.addChild("Green", "GREEN", null);
Category italianWhite = italianColours.addChild("White", "WHITE", null);
wrap(italianColours).applicable("/ITA", DemoObjectWithAtPath.class.getName());
wrap(italianColours).applicable("/ITA", OtherObjectWithAtPath.class.getName());
// french taxonomy applicable only to French DemoObject (and not to OtherObject even if with FRA app tenancy)
Taxonomy frenchColours = categoryRepository.createTaxonomy("French Colours");
frenchColours.setReference("FRCOL");
Category frenchRed = frenchColours.addChild("Red", "FRRED", null);
Category frenchWhite = frenchColours.addChild("White", "FRWHITE", null);
Category frenchBlue = frenchColours.addChild("Blue", "FRBLUE", null);
wrap(frenchColours).applicable("/FRA", DemoObjectWithAtPath.class.getName());
// global taxonomy applicable only to DemoObject (any app tenancy)
Taxonomy globalSizes = categoryRepository.createTaxonomy("Sizes");
globalSizes.setReference("SIZES");
Category large = globalSizes.addChild("Large", "LGE", 1);
Category medium = globalSizes.addChild("Medium", "M", 2);
Category small = globalSizes.addChild("Small", "SML", 3);
Category largeLargest = large.addChild("Largest", "XXL", 1);
Category largeLarger = large.addChild("Larger", "XL", 2);
Category largeLarge = large.addChild("Large", "L", 3);
Category smallSmall = small.addChild("Small", "S", 1);
Category smallSmaller = small.addChild("Smaller", "XS", 2);
Category smallSmallest = small.addChild("Smallest", "XXS", 3);
wrap(globalSizes).applicable("/", DemoObjectWithAtPath.class.getName());
// create a sample set of DemoObject and OtherObject, for various app tenancies
final DemoObjectWithAtPath demoFooInItaly = createDemo("Demo foo (in Italy)", "/ITA", executionContext);
final DemoObjectWithAtPath demoBarInFrance = createDemo("Demo bar (in France)", "/FRA", executionContext);
final DemoObjectWithAtPath demoBaz = createDemo("Demo baz (Global)", "/", executionContext);
final DemoObjectWithAtPath demoBip = createDemo("Demo bip (in Milan)", "/ITA/I-MIL", executionContext);
final DemoObjectWithAtPath demoBop = createDemo("Demo bop (in Paris)", "/FRA/F-PAR", executionContext);
final OtherObjectWithAtPath otherFooInItaly = createOther("Other foo (in Italy)", "/ITA", executionContext);
final OtherObjectWithAtPath otherBarInFrance = createOther("Other bar (in France)", "/FRA", executionContext);
final OtherObjectWithAtPath otherBaz = createOther("Other baz (Global)", "/", executionContext);
final OtherObjectWithAtPath otherBip = createOther("Other bip (in Milan)", "/ITA/I-MIL", executionContext);
final OtherObjectWithAtPath otherBop = createOther("Other bop (in Paris)", "/FRA/F-PAR", executionContext);
// classify DemoObject
wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoFooInItaly)).classify(italianColours, italianRed);
wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoFooInItaly)).classify(globalSizes, medium);
wrap(mixin(ClassificationForDemoObjectWithAtPath.classify.class, demoBarInFrance)).classify(globalSizes, smallSmaller);
// leave OtherObject unclassified
}
Aggregations