ModuleDataModelOracleUtils { public static String getFieldFullyQualifiedClassName(final ModuleDataModelOracle dmo, final String fullyQualifiedClassName, final String fieldName) { final ModelField[] mfs = dmo.getModuleModelFields().get(fullyQualifiedClassName); if (mfs == null) { return null; } for (ModelField mf : mfs) { if (mf.getName().equals(fieldName)) { return mf.getClassName(); } } return null; }  static String[] getFactTypes(final ModuleDataModelOracle dmo); static List<String> getSuperType(final ModuleDataModelOracle dmo, final String factType); static Set<Annotation> getTypeAnnotations(final ModuleDataModelOracle dmo, final String factType); static Map<String, Set<Annotation>> getTypeFieldsAnnotations(final ModuleDataModelOracle dmo, final String factType); static String getFieldClassName(final ModuleDataModelOracle dmo, final String factType, final String fieldName); static String getParametricFieldType(final ModuleDataModelOracle dmo, final String factType, final String fieldName); static TypeSource getTypeSource(final ModuleDataModelOracle dmo, final String factType); static String getFieldFullyQualifiedClassName(final ModuleDataModelOracle dmo, final String fullyQualifiedClassName, final String fieldName);  }
@Test public void getFieldFullyQualifiedClassNameTest() { ModuleDataModelOracle mockedDMO = mock(ModuleDataModelOracle.class); Map<String, ModelField[]> moduleModelFields = new HashMap<>(); when(mockedDMO.getModuleModelFields()).thenReturn(moduleModelFields); String fullyQualifiedClassName = this.getClass().getName(); String fieldName = "nonExistentField"; String fqnFieldClassName = getFieldFullyQualifiedClassName(mockedDMO, fullyQualifiedClassName, fieldName); assertNull("Expected a null FQN field class name", fqnFieldClassName); moduleModelFields.put(fullyQualifiedClassName, new ModelField[]{ new ModelField("existentField", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, null) }); when(mockedDMO.getModuleModelFields()).thenReturn(moduleModelFields); fqnFieldClassName = getFieldFullyQualifiedClassName(mockedDMO, fullyQualifiedClassName, fieldName); assertNull("Expected a null FQN field class name", fqnFieldClassName); fieldName = "testField"; String fieldType = "org.acme.test.field.type"; moduleModelFields.put(fullyQualifiedClassName, new ModelField[]{ new ModelField("existentField", String.class.getName(), FIELD_CLASS_TYPE.REGULAR_CLASS, FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, null), new ModelField(fieldName, fieldType, FIELD_CLASS_TYPE.REGULAR_CLASS, FIELD_ORIGIN.DECLARED, FieldAccessorsAndMutators.ACCESSOR, null) }); when(mockedDMO.getModuleModelFields()).thenReturn(moduleModelFields); fqnFieldClassName = getFieldFullyQualifiedClassName(mockedDMO, fullyQualifiedClassName, fieldName); assertEquals("Expected a null FQN field class name", fieldType, fqnFieldClassName); }