JavaTransformer { public ObjectModel generateModel(final OWLOntology ontology, final ContextDefinition context) { try { final JCodeModel cm = new JCodeModel(); voc = createVocabularyClass(cm); generateVocabulary(ontology, cm, context); _generateModel(ontology, cm, context, modelPackageName()); return new ObjectModel(cm); } catch (JClassAlreadyExistsException e) { throw new OWL2JavaException("Transformation FAILED.", e); } } JavaTransformer(TransformationConfiguration configuration); ObjectModel generateModel(final OWLOntology ontology, final ContextDefinition context); ObjectModel generateVocabulary(final OWLOntology ontology, ContextDefinition context);  }
@Test void generateModelGeneratesFieldOfTypeMultilingualStringForLangStringRangeWhenConfiguredToPreferMultilingualStrings() { final String className = "TestClass1"; final String fieldName = "multilingualString"; final ContextDefinition context = generateAxiomsForLangStrings(className, fieldName); final ObjectModel result = sut.generateModel(ontology, context); final JDefinedClass resultClass = result.getCodeModel()._getClass(Constants.MODEL_PACKAGE + Constants.PACKAGE_SEPARATOR + className); assertNotNull(resultClass); final JFieldVar resultField = resultClass.fields().get(fieldName); assertNotNull(resultField); assertEquals(MultilingualString.class.getCanonicalName(), resultField.type().fullName()); }
@Test void generateModelGeneratesFieldOfTypeStringForLangStringRangeWhenConfiguredNotToPreferMultilingualStrings() { this.sut = new JavaTransformer(TransformationConfiguration.builder().preferMultilingualStrings(false).packageName("").build()); final String className = "TestClass"; final String fieldName = "multilingualString"; final ContextDefinition context = generateAxiomsForLangStrings(className, fieldName); final ObjectModel result = sut.generateModel(ontology, context); final JDefinedClass resultClass = result.getCodeModel()._getClass(Constants.MODEL_PACKAGE + Constants.PACKAGE_SEPARATOR + className); assertNotNull(resultClass); final JFieldVar resultField = resultClass.fields().get(fieldName); assertNotNull(resultField); assertEquals(String.class.getCanonicalName(), resultField.type().fullName()); }