Search in sources :

Example 1 with Transaction

use of io.spine.server.entity.Transaction in project core-java by SpineEventEngine.

the class TestTransaction method injectState.

/**
     * A hack allowing to inject state and version into an {@code EventPlayingEntity} instance
     * by creating and committing a fake transaction.
     *
     * <p>To be used in tests only.
     */
public static void injectState(EventPlayingEntity entity, Message state, Version version) {
    @SuppressWarnings("unchecked") final Transaction tx = new Transaction(entity, state, version) {

        @Override
        protected void dispatch(EventPlayingEntity entity, Message eventMessage, EventContext context) throws InvocationTargetException {
        // do nothing.
        }
    };
    tx.commit();
}
Also used : EventContext(io.spine.base.EventContext) Transaction(io.spine.server.entity.Transaction) Message(com.google.protobuf.Message)

Aggregations

Message (com.google.protobuf.Message)1 EventContext (io.spine.base.EventContext)1 Transaction (io.spine.server.entity.Transaction)1