@Test public void generateReadsSchemaAsObject() throws IOException { final SchemaRule mockSchemaRule = mock(SchemaRule.class); final RuleFactory mockRuleFactory = mock(RuleFactory.class); when(mockRuleFactory.getSchemaRule()).thenReturn(mockSchemaRule); when(mockRuleFactory.getGenerationConfig()).thenReturn(new DefaultGenerationConfig()); URL schemaContent = this.getClass().getResource("/schema/address.json"); new SchemaMapper(mockRuleFactory, new SchemaGenerator()).generate(new JCodeModel(), "Address", "com.example.package", schemaContent); ArgumentCaptor<JPackage> capturePackage = ArgumentCaptor.forClass(JPackage.class); ArgumentCaptor<JsonNode> captureNode = ArgumentCaptor.forClass(JsonNode.class); verify(mockSchemaRule).apply(eq("Address"), captureNode.capture(), eq(null), capturePackage.capture(), Mockito.isA(Schema.class)); assertThat(capturePackage.getValue().name(), is("com.example.package")); assertThat(captureNode.getValue(), is(notNullValue())); }
public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); }
SchemaMapper { public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); } }
SchemaMapper { public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); } SchemaMapper(RuleFactory ruleFactory, SchemaGenerator schemaGenerator);  SchemaMapper(); }
SchemaMapper { public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); } SchemaMapper(RuleFactory ruleFactory, SchemaGenerator schemaGenerator);  SchemaMapper(); JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl); JType generate(JCodeModel codeModel, String className, String packageName, String json,
            URI schemaLocation); JType generate(JCodeModel codeModel, String className, String packageName, String json); }
SchemaMapper { public JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl) { JPackage jpackage = codeModel._package(packageName); ObjectNode schemaNode = readSchema(schemaUrl); return ruleFactory.getSchemaRule().apply(className, schemaNode, null, jpackage, new Schema(null, schemaNode, null)); } SchemaMapper(RuleFactory ruleFactory, SchemaGenerator schemaGenerator);  SchemaMapper(); JType generate(JCodeModel codeModel, String className, String packageName, URL schemaUrl); JType generate(JCodeModel codeModel, String className, String packageName, String json,
            URI schemaLocation); JType generate(JCodeModel codeModel, String className, String packageName, String json);  }