net.jqwik.spring.JupiterStoreAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jqwik-spring Show documentation
Show all versions of jqwik-spring Show documentation
Jqwik Spring support module
package net.jqwik.spring;
import java.util.function.*;
import net.jqwik.api.*;
import net.jqwik.api.lifecycle.*;
import org.junit.jupiter.api.extension.*;
import org.springframework.test.context.*;
class JupiterStoreAdapter implements ExtensionContext.Store {
private LifecycleContext context;
public JupiterStoreAdapter(LifecycleContext context) {
this.context = context;
}
@Override
public Object get(Object key) {
return JqwikSpringExtension.getTestContextManager(context.optionalContainerClass().orElseThrow(
() -> new JqwikException("No test context manager registered")
));
}
@Override
public V get(Object key, Class requiredType) {
if (requiredType.equals(TestContextManager.class)) {
return (V) get(key);
} else {
return null;
}
}
@Override
public Object getOrComputeIfAbsent(K key, Function defaultCreator) {
return get(key);
}
@Override
public V getOrComputeIfAbsent(K key, Function defaultCreator, Class requiredType) {
return get(key, requiredType);
}
@Override
public void put(Object key, Object value) {
throw new UnsupportedOperationException();
}
@Override
public Object remove(Object key) {
throw new UnsupportedOperationException();
}
@Override
public V remove(Object key, Class requiredType) {
throw new UnsupportedOperationException();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy