class ReceiverGenerator implements IReceiverGenerator {

    @Override
    public IMessageReceiver generate(
            final Object objInstance,
            final IResolveDependencyStrategy wrapperResolutionStrategy,
            final String methodName
    ) throws InvalidArgumentException, ReceiverGeneratorException {
        if (
                null == objInstance ||
                null == methodName ||
                methodName.isEmpty() ||
                null == wrapperResolutionStrategy
        ) {
            throw new InvalidArgumentException("One of the arguments null or empty.");
        }
        try {
            Class<IMessageReceiver> clazz = generateClass(
                    objInstance,
                    methodName
            );
            return clazz.getConstructor(
                    new Class[]{objInstance.getClass(), IResolveDependencyStrategy.class}
            )
                    .newInstance(new Object[]{objInstance, wrapperResolutionStrategy});
        } catch (Throwable e) {
            throw new ReceiverGeneratorException(
                    "Could not generate message receiver because of the following error:",
                    e
            );
        }
    }

}

class ReceiverGeneratorTest {

    @Test(expected = ReceiverGeneratorException.class)
    public void checkReceiverGeneratorExceptionOn()
            throws Exception {

        CustomActor a = new CustomActor();
        IResolveDependencyStrategy strategy = mock(IResolveDependencyStrategy.class);

        IReceiverGenerator rg = new ReceiverGenerator(null);
        rg.generate(a, strategy, "a");
        fail();
    }

}