Package org.qi4j.api.usecase

Examples of org.qi4j.api.usecase.Usecase


    @Test
    public void testTaskWithoutScheduling()
        throws UnitOfWorkCompletionException
    {
        Usecase usecase = UsecaseBuilder.newUsecase( "testTask" );
        String taskId;
        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
        {
            FooTask task = createFooTask( uow, "TestTask", BAZAR );
            taskId = task.identity().get();
View Full Code Here


    @Test
    public void testMinutely()
        throws UnitOfWorkCompletionException
    {
        Usecase usecase = UsecaseBuilder.newUsecase( "TestMinutely" );
        DateTime start = new DateTime();
        String taskIdentity;
        long sleepMillis;
        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
        {
            Scheduler scheduler = module.findService( Scheduler.class ).get();

            FooTask task = createFooTask( uow, usecase.name(), BAZAR );
            taskIdentity = task.identity().get();

            DateTime expectedRun = start.withMillisOfSecond( 0 ).withSecondOfMinute( 0 ).plusMinutes( 1 );
            scheduler.scheduleCron( task, "@minutely", true );

            uow.complete();

            sleepMillis = new Interval( start, expectedRun ).toDurationMillis();
            LOGGER.info( "Task scheduled on {} to be run at {}", start.getMillis(), expectedRun.getMillis() );
        }

        await( usecase.name() ).
            atMost( sleepMillis + 5000, MILLISECONDS ).
            until( taskOutput( taskIdentity ), equalTo( BAR ) );

        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
        {
View Full Code Here

    @Test
    public void testOnce()
        throws UnitOfWorkCompletionException
    {
        final Usecase usecase = UsecaseBuilder.newUsecase( "TestOnce" );
        final String taskIdentity;
        try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
        {
            Scheduler scheduler = module.findService( Scheduler.class ).get();

            FooTask task = createFooTask( uow, usecase.name(), BAZAR );
            taskIdentity = task.identity().get();

            scheduler.scheduleOnce( task, 2, true );

            uow.complete();
        }

        await( usecase.name() ).until( taskOutput( taskIdentity ), equalTo( BAR ) );
    }
View Full Code Here

TOP

Related Classes of org.qi4j.api.usecase.Usecase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.