Search in sources :

Example 1 with FixedTextEntity

use of org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedTextEntity in project kogito-apps by kiegroup.

the class CounterfactualEntityFactoryTest method testTextFactory.

@Test
void testTextFactory() {
    final String value = "foo";
    final Feature feature = FeatureFactory.newTextFeature("text-feature", value);
    CounterfactualEntity counterfactualEntity = CounterfactualEntityFactory.from(feature);
    assertTrue(counterfactualEntity instanceof FixedTextEntity);
    assertEquals(Type.TEXT, counterfactualEntity.asFeature().getType());
    final Feature varyingFeature = FeatureFactory.newTextFeature("text-feature", value, EmptyFeatureDomain.create());
    IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
        CounterfactualEntityFactory.from(varyingFeature);
    });
    assertEquals("Unsupported feature type: text", exception.getMessage());
}
Also used : CounterfactualEntity(org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity) Feature(org.kie.kogito.explainability.model.Feature) FixedTextEntity(org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedTextEntity) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)1 CounterfactualEntity (org.kie.kogito.explainability.local.counterfactual.entities.CounterfactualEntity)1 FixedTextEntity (org.kie.kogito.explainability.local.counterfactual.entities.fixed.FixedTextEntity)1 Feature (org.kie.kogito.explainability.model.Feature)1