use of org.kie.kogito.explainability.api.CounterfactualSearchDomainUnitValue in project kogito-apps by kiegroup.
the class CounterfactualDomainSerialisationTest method testCounterfactualSearchDomain_Range_RoundTrip.
@Test
public void testCounterfactualSearchDomain_Range_RoundTrip() throws Exception {
CounterfactualDomainRange domainRange = new CounterfactualDomainRange(new IntNode(18), new IntNode(65));
CounterfactualSearchDomain searchDomain = new CounterfactualSearchDomain("age", new CounterfactualSearchDomainUnitValue("integer", "integer", Boolean.TRUE, domainRange));
mapper.writeValue(writer, searchDomain);
String searchDomainJson = writer.toString();
assertNotNull(searchDomainJson);
CounterfactualSearchDomain roundTrippedSearchDomain = mapper.readValue(searchDomainJson, CounterfactualSearchDomain.class);
assertTrue(roundTrippedSearchDomain.getValue() instanceof CounterfactualSearchDomainUnitValue);
assertEquals(searchDomain.getValue().getKind(), roundTrippedSearchDomain.getValue().getKind());
assertEquals(searchDomain.getName(), roundTrippedSearchDomain.getName());
assertEquals(searchDomain.getValue().getType(), roundTrippedSearchDomain.getValue().getType());
assertEquals(searchDomain.getValue().toUnit().getBaseType(), roundTrippedSearchDomain.getValue().toUnit().getBaseType());
assertEquals(searchDomain.getValue().toUnit().isFixed(), roundTrippedSearchDomain.getValue().toUnit().isFixed());
assertTrue(roundTrippedSearchDomain.getValue().toUnit().getDomain() instanceof CounterfactualDomainRange);
CounterfactualDomainRange roundTrippedDomainRange = (CounterfactualDomainRange) roundTrippedSearchDomain.getValue().toUnit().getDomain();
assertEquals(domainRange.getLowerBound(), roundTrippedDomainRange.getLowerBound());
assertEquals(domainRange.getUpperBound(), roundTrippedDomainRange.getUpperBound());
}
Aggregations