### Question:
FormatRule implements Rule<JType, JType> { @Override public JType apply(String nodeName, JsonNode node, JsonNode parent, JType baseType, Schema schema) { Class<?> type = getType(node.asText()); if (type != null) { JType jtype = baseType.owner().ref(type); if (ruleFactory.getGenerationConfig().isUsePrimitives()) { jtype = jtype.unboxify(); } return jtype; } else { return baseType; } } protected  FormatRule(RuleFactory ruleFactory); @Override JType apply(String nodeName, JsonNode node, JsonNode parent, JType baseType, Schema schema); static String ISO_8601_DATE_FORMAT; static String ISO_8601_TIME_FORMAT; static String ISO_8601_DATETIME_FORMAT; }### Answer:
@Test public void applyGeneratesTypeFromFormatValue() { TextNode formatNode = TextNode.valueOf(formatValue); JType result = rule.apply("fooBar", formatNode, null, new JCodeModel().ref(String.class), null); assertThat(result.fullName(), equalTo(expectedType.getName())); }
@Test public void applyDefaultsToBaseType() { TextNode formatNode = TextNode.valueOf("unknown-format"); JType baseType = new JCodeModel().ref(Long.class); JType result = rule.apply("fooBar", formatNode, null, baseType, null); assertThat(result, equalTo(baseType)); }