org.jusecase.test.UsecaseTestInterface Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jusecase-test Show documentation
Show all versions of jusecase-test Show documentation
Java framework for a usecase centric architecture as proposed by Uncle Bob and others. Supports Java 1.6+.
The newest version!
package org.jusecase.test;
import org.jusecase.util.GenericTypeResolver;
public abstract class UsecaseTestInterface {
protected Request request;
protected Throwable error;
@SuppressWarnings({"unchecked", "ConstantConditions"})
public void createRequest() {
try {
Class> requestClass = GenericTypeResolver.resolve(UsecaseTestInterface.class, getClass(), 0);
request = (Request) requestClass.getConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException("Failed to instantiate request. You need to override createRequest() and do it manually.", e);
}
}
protected abstract void whenRequestIsExecuted();
protected void whenErrorRequestIsExecuted() {
try {
whenRequestIsExecuted();
} catch (Throwable e) {
error = e;
}
}
protected abstract void thenErrorIs(Throwable expected);
protected abstract void thenErrorIs(Class extends Throwable> expected);
protected abstract void thenErrorMessageIs(String expected);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy