use of org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedCompositeEntity in project kogito-apps by kiegroup.
the class CounterfactualEntityFactoryTest method testCompositeFactory.
@Test
void testCompositeFactory() {
Map<String, Object> map = new HashMap<>();
List<Feature> features = new LinkedList<>();
features.add(FeatureFactory.newObjectFeature("f1", new Object()));
features.add(FeatureFactory.newTextFeature("f2", "hola"));
features.add(FeatureFactory.newFulltextFeature("f3", "foo bar"));
features.add(FeatureFactory.newNumericalFeature("f4", 131));
features.add(FeatureFactory.newBooleanFeature("f5", false));
features.add(FeatureFactory.newDurationFeature("f6", Duration.ofDays(2)));
Map<String, Object> nestedMap = new HashMap<>();
nestedMap.put("nf-1", "nested text");
nestedMap.put("nf-2", ByteBuffer.allocate(1024));
features.add(FeatureFactory.newCompositeFeature("f7", nestedMap));
for (Feature f : features) {
map.put(f.getName(), f.getValue().getUnderlyingObject());
}
final Feature feature = FeatureFactory.newCompositeFeature("composite-feature", map);
CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
assertTrue(counterfactualEntity instanceof FixedCompositeEntity);
assertEquals(Type.COMPOSITE, counterfactualEntity.asFeature().getType());
}
Aggregations