@Test public void isJMockitMockableType_A$String_StringIsEmpty() throws Exception { ClassMeta classMeta = null; AvailableTypeDetector target = new AvailableTypeDetector(classMeta); String typeName = ""; try { target.isJMockitMockableType(typeName); fail(); } catch (JUnitHelperCoreException e) { } }
public boolean isJMockitMockableType(String typeName) { if (typeName == null) { return false; } if (PrimitiveTypeUtil.isPrimitive(typeName) || typeName.matches(".+?\\[\\]$")) { return false; } try { Class<?> clazz = Class.forName("java.lang." + typeName); return (Modifier.isFinal(clazz.getModifiers())) ? false : true; } catch (Exception ignore) { for (String importedPackage : classMeta.importedList) { importedPackage = importedPackage.replaceAll(" if (importedPackage.matches(".+?\\." + typeName + "$")) { return true; } } if (typeName.matches(".+?\\..+")) { try { Class<?> clazz = Class.forName(typeName); return !(Modifier.isFinal(clazz.getModifiers())); } catch (Exception e) { return false; } } } return false; }
AvailableTypeDetector { public boolean isJMockitMockableType(String typeName) { if (typeName == null) { return false; } if (PrimitiveTypeUtil.isPrimitive(typeName) || typeName.matches(".+?\\[\\]$")) { return false; } try { Class<?> clazz = Class.forName("java.lang." + typeName); return (Modifier.isFinal(clazz.getModifiers())) ? false : true; } catch (Exception ignore) { for (String importedPackage : classMeta.importedList) { importedPackage = importedPackage.replaceAll(" if (importedPackage.matches(".+?\\." + typeName + "$")) { return true; } } if (typeName.matches(".+?\\..+")) { try { Class<?> clazz = Class.forName(typeName); return !(Modifier.isFinal(clazz.getModifiers())); } catch (Exception e) { return false; } } } return false; } }
AvailableTypeDetector { public boolean isJMockitMockableType(String typeName) { if (typeName == null) { return false; } if (PrimitiveTypeUtil.isPrimitive(typeName) || typeName.matches(".+?\\[\\]$")) { return false; } try { Class<?> clazz = Class.forName("java.lang." + typeName); return (Modifier.isFinal(clazz.getModifiers())) ? false : true; } catch (Exception ignore) { for (String importedPackage : classMeta.importedList) { importedPackage = importedPackage.replaceAll(" if (importedPackage.matches(".+?\\." + typeName + "$")) { return true; } } if (typeName.matches(".+?\\..+")) { try { Class<?> clazz = Class.forName(typeName); return !(Modifier.isFinal(clazz.getModifiers())); } catch (Exception e) { return false; } } } return false; } AvailableTypeDetector(ClassMeta classMeta); }
AvailableTypeDetector { public boolean isJMockitMockableType(String typeName) { if (typeName == null) { return false; } if (PrimitiveTypeUtil.isPrimitive(typeName) || typeName.matches(".+?\\[\\]$")) { return false; } try { Class<?> clazz = Class.forName("java.lang." + typeName); return (Modifier.isFinal(clazz.getModifiers())) ? false : true; } catch (Exception ignore) { for (String importedPackage : classMeta.importedList) { importedPackage = importedPackage.replaceAll(" if (importedPackage.matches(".+?\\." + typeName + "$")) { return true; } } if (typeName.matches(".+?\\..+")) { try { Class<?> clazz = Class.forName(typeName); return !(Modifier.isFinal(clazz.getModifiers())); } catch (Exception e) { return false; } } } return false; } AvailableTypeDetector(ClassMeta classMeta); boolean isPrimitive(String typeName); boolean isArray(String typeName); boolean isJavaLangPackageType(String typeName); boolean isAvailableType(String typeName, Configuration config); boolean isJMockitMockableType(String typeName); }
AvailableTypeDetector { public boolean isJMockitMockableType(String typeName) { if (typeName == null) { return false; } if (PrimitiveTypeUtil.isPrimitive(typeName) || typeName.matches(".+?\\[\\]$")) { return false; } try { Class<?> clazz = Class.forName("java.lang." + typeName); return (Modifier.isFinal(clazz.getModifiers())) ? false : true; } catch (Exception ignore) { for (String importedPackage : classMeta.importedList) { importedPackage = importedPackage.replaceAll(" if (importedPackage.matches(".+?\\." + typeName + "$")) { return true; } } if (typeName.matches(".+?\\..+")) { try { Class<?> clazz = Class.forName(typeName); return !(Modifier.isFinal(clazz.getModifiers())); } catch (Exception e) { return false; } } } return false; } AvailableTypeDetector(ClassMeta classMeta); boolean isPrimitive(String typeName); boolean isArray(String typeName); boolean isJavaLangPackageType(String typeName); boolean isAvailableType(String typeName, Configuration config); boolean isJMockitMockableType(String typeName);  }