All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jusecase.test.UsecaseTestInterface Maven / Gradle / Ivy

Go to download

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 expected);

    protected abstract void thenErrorMessageIs(String expected);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy