@Test public void testHasIntegerAndFractionalDigits() { when(config.isIncludeJsr303Annotations()).thenReturn(true); final int intValue = new Random().nextInt(); final int fractionalValue = new Random().nextInt(); when(subNodeInteger.asInt()).thenReturn(intValue); when(subNodeFractional.asInt()).thenReturn(fractionalValue); when(node.get("integerDigits")).thenReturn(subNodeInteger); when(node.get("fractionalDigits")).thenReturn(subNodeFractional); when(fieldVar.annotate(Digits.class)).thenReturn(annotation); when(node.has("integerDigits")).thenReturn(true); when(node.has("fractionalDigits")).thenReturn(true); when(fieldVar.type().boxify().fullName()).thenReturn(fieldClass.getTypeName()); JFieldVar result = rule.apply("node", node, null, fieldVar, null); assertSame(fieldVar, result); verify(fieldVar, times(isApplicable ? 1 : 0)).annotate(Digits.class); verify(annotation, times(isApplicable ? 1 : 0)).param("integer", intValue); verify(annotation, times(isApplicable ? 1 : 0)).param("fraction", fractionalValue); }
@Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && isApplicableType(field)) { JAnnotationUse annotation = field.annotate(Digits.class); annotation.param("integer", node.get("integerDigits").asInt()); annotation.param("fraction", node.get("fractionalDigits").asInt()); } return field; }
DigitsRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && isApplicableType(field)) { JAnnotationUse annotation = field.annotate(Digits.class); annotation.param("integer", node.get("integerDigits").asInt()); annotation.param("fraction", node.get("fractionalDigits").asInt()); } return field; } }
DigitsRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && isApplicableType(field)) { JAnnotationUse annotation = field.annotate(Digits.class); annotation.param("integer", node.get("integerDigits").asInt()); annotation.param("fraction", node.get("fractionalDigits").asInt()); } return field; } protected  DigitsRule(RuleFactory ruleFactory); }
DigitsRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && isApplicableType(field)) { JAnnotationUse annotation = field.annotate(Digits.class); annotation.param("integer", node.get("integerDigits").asInt()); annotation.param("fraction", node.get("fractionalDigits").asInt()); } return field; } protected  DigitsRule(RuleFactory ruleFactory); @Override JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema); }
DigitsRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && node.has("integerDigits") && node.has("fractionalDigits") && isApplicableType(field)) { JAnnotationUse annotation = field.annotate(Digits.class); annotation.param("integer", node.get("integerDigits").asInt()); annotation.param("fraction", node.get("fractionalDigits").asInt()); } return field; } protected  DigitsRule(RuleFactory ruleFactory); @Override JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema);  }