use of com.devonfw.cobigen.javaplugin.unittest.inputreader.testdata.RootClass in project cobigen by devonfw.
the class ParsedJavaModelBuilderTest method testCorrectExtractionOfInheritedFields_input_packageFolder.
/**
* Tests the correct extraction of 'methodAccessibleFields' for {@link PackageFolder} as input.
*/
@Test
@Ignore("see com.devonfw.cobigen.javaplugin.inputreader.ParsedJavaModelBuilder.extractMethodAccessibleFields#L115")
public void testCorrectExtractionOfInheritedFields_input_packageFolder() {
File packageFolderFile = new File(testFileRootPath + "packageFolder");
PackageFolder packageFolder = new PackageFolder(packageFolderFile.toURI(), RootClass.class.getPackage().getName());
JavaInputReader javaInputReader = new JavaInputReader();
List<Object> objects = javaInputReader.getInputObjects(packageFolder, Charsets.UTF_8);
assertThat(objects).as("The package folder does not contain any java sources!").isNotNull();
assertThat(objects).hasSize(2);
boolean found = false;
for (Object o : objects) {
Map<String, Object> model = javaInputReader.createModel(o);
assertThat(model).as("No model has been created!").isNotNull();
if (RootClass.class.getSimpleName().equals(JavaModelUtil.getName(model))) {
List<Map<String, Object>> methodAccessibleFields = JavaModelUtil.getMethodAccessibleFields(model);
assertThat(methodAccessibleFields).isNotNull();
assertThat(methodAccessibleFields).hasSize(3);
Map<String, Object> field = JavaModelUtil.getMethodAccessibleField(model, "value");
assertThat(field).as("Field 'value' not found!").isNotNull();
assertThat(field.get(ModelConstant.NAME)).isEqualTo("value");
assertThat(field.get(ModelConstant.TYPE)).isEqualTo("String");
assertThat(field.get(ModelConstant.CANONICAL_TYPE)).isEqualTo("java.lang.String");
field = JavaModelUtil.getMethodAccessibleField(model, "setterVisibleByte");
assertThat(field).as("Field 'setterVisibleByte' not found!").isNotNull();
assertThat(field.get(ModelConstant.NAME)).isEqualTo("setterVisibleByte");
assertThat(field.get(ModelConstant.TYPE)).isEqualTo("byte");
assertThat(field.get(ModelConstant.CANONICAL_TYPE)).isEqualTo("byte");
field = JavaModelUtil.getMethodAccessibleField(model, "genericAccessible");
assertThat(field).as("Field 'genericAccessible' not found!").isNotNull();
assertThat(field.get(ModelConstant.NAME)).isEqualTo("genericAccessible");
// TODO: Known Issue, this is not possible as the SuperClass2 is not in the same folder and
// thus not parsed. Thus, due to type erasure the parametric type will be lost.
// assertThat(field.get(ModelConstant.TYPE)).isEqualTo("List<RootClass>");
// assertThat(field.get(ModelConstant.CANONICAL_TYPE)).isEqualTo("java.util.List<RootClass>");
assertThat(field.get(ModelConstant.TYPE)).isEqualTo("List");
assertThat(field.get(ModelConstant.CANONICAL_TYPE)).isEqualTo("java.util.List");
found = true;
}
}
assertTrue("Class " + RootClass.class.getName() + "could not be found as child of the package folder.", found);
}
Aggregations