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

org.seedstack.business.api.EventFixture Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/**
 * Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved.
 *
 * This file is part of SeedStack, An enterprise-oriented full development stack.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.business.api;

/**
 * This fixture provides methods for integration test on events. The {@code given(Event event)} method allow to test
 * which handler will received a given event. And the {@code given(Class aClass)} method allow to test which event is
 * fired by a given method.
 *
 * 
  • * Test that a given event was handled by an expected EventHandler: *
* *
 * {@literal @}Inject
 * private EventFixture fixture;
 *
 * fixture.given(eventFactory.createMyEvent())
 *     .whenFired()
 *     .wasHandledBy(MyHandler.class);
 * 
* *
  • * Test that a given event was handled by exactly a provided list of EventHandlers: *
* *
 * {@literal @}Inject
 * private EventFixture fixture;
 *
 * fixture.given(eventFactory.createMyEvent())
 *     .whenFired()
 *     .wasHandledExactlyBy(MyHandler.class, MyHandler2.class);
 * 
* *
  • * Test that a given event was not handled by an expected EventHandler: *
* *
 * {@literal @}Inject
 * private EventFixture fixture;
 *
 * fixture.given(eventFactory.createMyEvent())
 *     .whenFired()
 *     .wasNotHandledBy(MyHandler3.class);
 * 
* *
  • * Test that a given event was generated from an expected method() with appropriate *parameters* *
* *
 * {@literal @}Inject
 * private EventFixture fixture;
 *
 * MyEvent myEvent = eventFactory.createMyEvent(SOME_EVENT_PARAM);
 * fixtures.given(MyService.class)
 *     .whenCalled("doSomething", SOME_METHOD_PARAM)
 *     .eventWasHandledBy(myEvent, MyHandler.class);
 * 
* Test if MyHandler handler received myEvent event when doSomething() method of MyService is called. * * @author [email protected] * Date: 10/06/2014 */ public interface EventFixture { /** * Indicates the event to test. * * @param event event to test * @return itself */ EventProvider given(Event event); /** * Indicates the class to test. * * @param aClass class to test * @return itself */ ServiceProvider given(Class aClass); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy