protected SpecificationContext getSpecificationContext() { return (SpecificationContext) currentInstance.getSpecificationContext(); } }
/** * Specifies that no exception should be thrown, failing with a * {@link UnallowedExceptionThrownError} otherwise. */ public void noExceptionThrown() { Throwable thrown = getSpecificationContext().getThrownException(); if (thrown == null) return; throw new UnallowedExceptionThrownError(null, thrown); }
/** * Specifies that no exception of the given type should be * thrown, failing with a {@link UnallowedExceptionThrownError} otherwise. * * @param type the exception type that should not be thrown */ public void notThrown(Class<? extends Throwable> type) { Throwable thrown = getSpecificationContext().getThrownException(); if (thrown == null) return; if (type.isAssignableFrom(thrown.getClass())) { throw new UnallowedExceptionThrownError(type, thrown); } ExceptionUtil.sneakyThrow(thrown); }
IMockInvocation invocation = new MockInvocation(mockObject, mockMethod, Arrays.asList(normalizedArgs), realMethodInvoker); IMockController mockController = specification == null ? getFallbackMockController() : specification.getSpecificationContext().getMockController();
IMockController controller = specification.getSpecificationContext().getMockController(); return controller.handle(invocation);
specification.getSpecificationContext().getCurrentIteration().addCleanup(new Runnable() { @Override public void run() {
IMockController controller = specification.getSpecificationContext().getMockController();