private DynamicContainer(String displayName, URI testSourceUri, Stream<? extends DynamicNode> children) { super(displayName, testSourceUri); Preconditions.notNull(children, "children must not be null"); this.children = children; }
private DynamicTest(String displayName, URI testSourceUri, Executable executable) { super(displayName, testSourceUri); this.executable = Preconditions.notNull(executable, "executable must not be null"); }
@Override public <K, V> V getOrComputeIfAbsent(K key, Function<K, V> defaultCreator, Class<V> requiredType) { Preconditions.notNull(key, "key must not be null"); Preconditions.notNull(defaultCreator, "defaultCreator function must not be null"); Preconditions.notNull(requiredType, "requiredType must not be null"); return this.valuesStore.getOrComputeIfAbsent(this.namespace, key, defaultCreator, requiredType); }
DefaultParameterContext(Parameter parameter, int index, Optional<Object> target) { Preconditions.condition(index >= 0, "index must be greater than or equal to zero"); this.parameter = Preconditions.notNull(parameter, "parameter must not be null"); this.index = index; this.target = Preconditions.notNull(target, "target must not be null"); }
@Override public <K, V> Object getOrComputeIfAbsent(K key, Function<K, V> defaultCreator) { Preconditions.notNull(key, "key must not be null"); Preconditions.notNull(defaultCreator, "defaultCreator function must not be null"); return this.valuesStore.getOrComputeIfAbsent(this.namespace, key, defaultCreator); }
static TestInstance.Lifecycle getTestInstanceLifecycle(Class<?> testClass, JupiterConfiguration configuration) { Preconditions.notNull(testClass, "testClass must not be null"); Preconditions.notNull(configuration, "configuration must not be null"); // @formatter:off return AnnotationUtils.findAnnotation(testClass, TestInstance.class) .map(TestInstance::value) .orElseGet(configuration::getDefaultTestInstanceLifecycle); // @formatter:on }
@Override public <T> Optional<T> findInstance(Class<T> requiredType) { Preconditions.notNull(requiredType, "requiredType must not be null"); ListIterator<Object> iterator = instances.listIterator(instances.size()); while (iterator.hasPrevious()) { Object instance = iterator.previous(); if (requiredType.isInstance(instance)) { return Optional.of(requiredType.cast(instance)); } } return Optional.empty(); }
/** * Compile a string representation from all simple parameter type names. * * @param method the method providing parameter types for the result; never {@code null} * @return a string representation of all parameter types of the * supplied method or {@code "()"} if the method has no parameters */ static String parameterTypesAsString(Method method) { Preconditions.notNull(method, "Method must not be null"); return '(' + ClassUtils.nullSafeToString(Class::getSimpleName, method.getParameterTypes()) + ')'; }
@Override public Object get(Object key) { Preconditions.notNull(key, "key must not be null"); return this.valuesStore.get(this.namespace, key); }
@Override public void put(Object key, Object value) { Preconditions.notNull(key, "key must not be null"); this.valuesStore.put(this.namespace, key, value); }
@Override public Object remove(Object key) { Preconditions.notNull(key, "key must not be null"); return this.valuesStore.remove(this.namespace, key); }
@Override public Store getStore(Namespace namespace) { Preconditions.notNull(namespace, "Namespace must not be null"); return new NamespaceAwareStore(this.valuesStore, namespace); }
private static StoreAdapter getContainerInstance(final Object testInstance, final Field field) { try { field.setAccessible(true); Startable containerInstance = Preconditions.notNull((Startable) field.get(testInstance), "Container " + field.getName() + " needs to be initialized"); return new StoreAdapter(field.getDeclaringClass(), field.getName(), containerInstance); } catch (IllegalAccessException e) { throw new ExtensionConfigurationException("Can not access container defined in field " + field.getName()); } }
/** * @since 5.3 */ static TestSource fromUri(URI uri) { Preconditions.notNull(uri, "URI must not be null"); return CLASSPATH_SCHEME.equals(uri.getScheme()) ? ClasspathResourceSource.from(uri) : UriSource.from(uri); }
static void assertAll(String heading, Collection<Executable> executables) { Preconditions.notNull(executables, "executables collection must not be null"); Preconditions.containsNoNullElements(executables, "individual executables must not be null"); assertAll(heading, executables.stream()); }
@Override public boolean isAnnotated(Class<? extends Annotation> annotationType) { Preconditions.notNull(annotationType, "annotationType must not be null"); return AnnotationUtils.isAnnotated(getMethod(), annotationType); }
@Override public <A extends Annotation> Optional<A> findAnnotation(Class<A> annotationType) { Preconditions.notNull(annotationType, "annotationType must not be null"); return AnnotationUtils.findAnnotation(getMethod(), annotationType); }
MethodBasedTestDescriptor(UniqueId uniqueId, String displayName, Class<?> testClass, Method testMethod, JupiterConfiguration configuration) { super(uniqueId, displayName, MethodSource.from(testClass, testMethod), configuration); this.testClass = Preconditions.notNull(testClass, "Class must not be null"); this.testMethod = testMethod; this.tags = getTags(testMethod); }
@Override public <A extends Annotation> List<A> findRepeatableAnnotations(Class<A> annotationType) { Preconditions.notNull(annotationType, "annotationType must not be null"); return AnnotationUtils.findRepeatableAnnotations(getMethod(), annotationType); }