public static boolean isExcludedInterface(Class<?> clazz) { if (includedInterfacePackages == null || includedInterfacePackages.length == 0) { return false; } for (String packagePrefix : includedInterfacePackages) { if (clazz.getCanonicalName().startsWith(packagePrefix)) { return false; } } return true; }
public static boolean isExcludedInterface(Class<?> clazz) { if (includedInterfacePackages == null || includedInterfacePackages.length == 0) { return false; } for (String packagePrefix : includedInterfacePackages) { if (clazz.getCanonicalName().startsWith(packagePrefix)) { return false; } } return true; }
public static boolean isExcludedType(Class<?> clazz) { if (includedTypePackages == null || includedTypePackages.length == 0) { return false; } for (String packagePrefix : includedTypePackages) { if (clazz.getCanonicalName().startsWith(packagePrefix)) { return false; } } return true; }
public static boolean isExcludedType(Class<?> clazz) { if (includedTypePackages == null || includedTypePackages.length == 0) { return false; } for (String packagePrefix : includedTypePackages) { if (clazz.getCanonicalName().startsWith(packagePrefix)) { return false; } } return true; }
private static @Nullable AnnotationMirror getMirror(Element element, Class<? extends Annotation> annotation) { for (AnnotationMirror annotationMirror : element.getAnnotationMirrors()) { if (annotationMirror.getAnnotationType().toString().equals(annotation.getCanonicalName())) { return annotationMirror; } } return null; }
public static boolean needAnalyzing(Class<?> clazz) { String canonicalName = clazz.getCanonicalName(); if (closedTypes != null && closedTypes.length > 0) { for (String type : closedTypes) { if (canonicalName.startsWith(type)) { return false; } } } return !isExcludedType(clazz); }
public static boolean needAnalyzing(Class<?> clazz) { String canonicalName = clazz.getCanonicalName(); if (closedTypes != null && closedTypes.length > 0) { for (String type : closedTypes) { if (canonicalName.startsWith(type)) { return false; } } } return !isExcludedType(clazz); }
@Override public Set<String> getSupportedAnnotationTypes() { Set<String> types = new LinkedHashSet<>(); for (Class<? extends Annotation> annotation : getSupportedAnnotations()) { types.add(annotation.getCanonicalName()); } return types; }
public static void assertClassSourcesGeneratedToOutput(Class<?> clazz) { String canonicalName = clazz.getCanonicalName(); String filePath = canonicalName.replace(".", "/").concat(".java"); File generatedSourcesDir = new File(OUTPUT_DIRECTORY); File generatedSourceFile = new File(generatedSourcesDir, filePath); File sourcesDir = new File(MAIN_SOURCE_FOLDER); File expectedResult = new File(sourcesDir, filePath); assertOutput(expectedResult, generatedSourceFile); }
public static void assertClassSourcesNotGeneratedToOutput(Class<?> clazz) { String canonicalName = clazz.getCanonicalName(); String filePath = canonicalName.replace(".", "/").concat(".java"); File generatedSourcesDir = new File(OUTPUT_DIRECTORY); File output = new File(generatedSourcesDir, filePath); assertFalse(output.exists()); }
public AbstractJClass refClass(Class<?> clazz) { AbstractJClass referencedClass = codeModel.ref(clazz); loadedClasses.put(clazz.getCanonicalName(), referencedClass); return referencedClass; }
@Override public TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>, TypeDefinition> typeCache) { // Process the component type of an array. Class<?> componentType = clazz.getComponentType(); TypeDefinitionBuilder.build(componentType, componentType, typeCache); final String canonicalName = clazz.getCanonicalName(); return new TypeDefinition(canonicalName); }
@Override public TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>, TypeDefinition> typeCache) { // Process the component type of an array. Class<?> componentType = clazz.getComponentType(); TypeDefinitionBuilder.build(componentType, componentType, typeCache); final String canonicalName = clazz.getCanonicalName(); return new TypeDefinition(canonicalName); }
@Override public String toString() { return getDeclaringClass().getCanonicalName() + "@" + hashCode(); } }
@Override public TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>, TypeDefinition> typeCache) { TypeDefinition td = new TypeDefinition(clazz.getCanonicalName()); try { Method methodValues = clazz.getDeclaredMethod("values", new Class<?>[0]); Object[] values = (Object[]) methodValues.invoke(clazz, new Object[0]); int length = values.length; for (int i = 0; i < length; i++) { Object value = values[i]; td.getEnums().add(value.toString()); } } catch (Throwable t) { td.setId("-1"); } typeCache.put(clazz, td); return td; }
@Override public TypeDefinition build(Type type, Class<?> clazz, Map<Class<?>, TypeDefinition> typeCache) { TypeDefinition td = new TypeDefinition(clazz.getCanonicalName()); try { Method methodValues = clazz.getDeclaredMethod("values", new Class<?>[0]); Object[] values = (Object[]) methodValues.invoke(clazz, new Object[0]); int length = values.length; for (int i = 0; i < length; i++) { Object value = values[i]; td.getEnums().add(value.toString()); } } catch (Throwable t) { td.setId("-1"); } typeCache.put(clazz, td); return td; }
public <T> T mock(Class<T> typeToMock, MockSettings settings) { if (!MockSettingsImpl.class.isInstance(settings)) { throw new IllegalArgumentException("Unexpected implementation of '" + settings.getClass().getCanonicalName() + "'\n" + "At the moment, you cannot provide your own implementations of that class."); } MockSettingsImpl impl = MockSettingsImpl.class.cast(settings); MockCreationSettings<T> creationSettings = impl.build(typeToMock); T mock = createMock(creationSettings); mockingProgress().mockingStarted(mock, creationSettings); return mock; }
@Override public void contextDestroyed(ServletContextEvent sce) { ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory(); if (iLoggerFactory instanceof LoggerContext) { LoggerContext loggerContext = (LoggerContext) iLoggerFactory; contextAwareBase.setContext(loggerContext); StatusViaSLF4JLoggerFactory.addInfo("About to stop " + loggerContext.getClass().getCanonicalName() + " [" + loggerContext.getName() + "]", this); loggerContext.stop(); } }
public static MockitoException cannotInjectDependency(Field field, Object matchingMock, Exception details) { return new MockitoException(join( "Mockito couldn't inject mock dependency '" + MockUtil.getMockName(matchingMock) + "' on field ", "'" + field + "'", "whose type '" + field.getDeclaringClass().getCanonicalName() + "' was annotated by @InjectMocks in your test.", "Also I failed because: " + exceptionCauseMessageIfAvailable(details), "" ), details); }
private GenericMetadataSupport resolveGenericType(Type type, Method method) { if (type instanceof Class) { return new NotGenericReturnTypeSupport(this, type); } if (type instanceof ParameterizedType) { return new ParameterizedReturnType(this, method.getTypeParameters(), (ParameterizedType) type); } if (type instanceof TypeVariable) { return new TypeVariableReturnType(this, method.getTypeParameters(), (TypeVariable<?>) type); } throw new MockitoException("Ouch, it shouldn't happen, type '" + type.getClass().getCanonicalName() + "' on method : '" + method.toGenericString() + "' is not supported : " + type); }