### Question:
ToRuleConverter { public Rule convert(com.sabre.oss.yare.serializer.json.model.Rule rule) { Set<Attribute> attributes = prepareAttributes(rule); List<Fact> facts = prepareFacts(rule); return new Rule( attributes, facts, predicateConverter.convert(rule.getPredicate()), actionConverter.convert(rule.getActions())); } ToRuleConverter(TypeConverter typeConverter); Rule convert(com.sabre.oss.yare.serializer.json.model.Rule rule);  }### Answer:
@Test void shouldConvertRule() { Rule toConvert = new Rule() .withAttributes( new Attribute() .withName("attribute-name-1") .withValue("attribute-value-1") .withType("String"), new Attribute() .withName("attribute-name-2") .withValue(100) .withType("Integer") ) .withFacts( new Fact() .withName("fact-name-1") .withType("Character"), new Fact() .withName("fact-name-2") .withType("BigDecimal") ) .withPredicate( new Operator() .withType("operator-type-1") .withOperands( new Operator() .withType("operator-type-2") .withOperands( new Value() .withValue(100) .withType(BigInteger.class.getName()) ), null, new Function() .withName("function-name-1") .withReturnType("Boolean") .withParameters( new Parameter() .withName("parameter-name-1") .withExpression(new Values() .withType("List") .withValues(Collections.emptyList())), null ) ) ) .withActions( null, new Action() .withName("action-name") .withParameters( new Parameter() .withName("parameter-name-2") .withExpression( new Function() .withName("function-name-2") .withReturnType("Boolean") .withParameters(Collections.emptyList()) ) ) ); com.sabre.oss.yare.core.model.Rule rule = toRuleConverter.convert(toConvert); com.sabre.oss.yare.core.model.Rule expected = new com.sabre.oss.yare.core.model.Rule( new LinkedHashSet<>(Arrays.asList( new com.sabre.oss.yare.core.model.Attribute("attribute-name-1", String.class, "attribute-value-1"), new com.sabre.oss.yare.core.model.Attribute("attribute-name-2", Integer.class, 100) )), Arrays.asList( new com.sabre.oss.yare.core.model.Fact("fact-name-1", Character.class), new com.sabre.oss.yare.core.model.Fact("fact-name-2", BigDecimal.class) ), operatorOf(null, Boolean.class, "operator-type-1", Arrays.asList( operatorOf(null, Boolean.class, "operator-type-2", Collections.singletonList( valueOf(null, BigInteger.class, 100) )), null, functionOf("function-name-1", Boolean.class, "function-name-1", Arrays.asList( valuesOf("parameter-name-1", List.class, Collections.emptyList()), null )) )), Arrays.asList( null, actionOf("action-name", "action-name", Collections.singletonList( functionOf("parameter-name-2", Boolean.class, "function-name-2", Collections.emptyList()) )) ) ); assertThat(rule).isEqualTo(expected); }