 to f(), i.e. I cannot use onConsecutiveCalls, how can I solve this issue?

A:

You need to declare a CustomAction instance in place of the standard returnValue clause:
allowing(mockedObject).f();
will(new CustomAction("Returns new BusinessObj instance") {
  @Override
  public Object invoke(Invocation invocation) throws Throwable {
    return new BusinessObj();
  }
});

Below is a self-contained unit test that demonstrates this:
import org.jmock.Expectations;
import org.jmock.Mockery;
import org.jmock.api.Invocation;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.action.CustomAction;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(JMock.class)
public class TestClass {

  Mockery context = new JUnit4Mockery();

  @Test
  public void testMethod() {
    final Foo foo = context.mock(Foo.class);

    context.checking(new Expectations() {
      {
        allowing(foo).f();
        will(new CustomAction("Returns new BusinessObj instance") {
          @Override
          public Object invoke(Invocation invocation) throws Throwable {
            return new BusinessObj();
          }
        });
      }
    });

    BusinessObj obj1 = foo.f();
    BusinessObj obj2 = foo.f();

    Assert.assertNotNull(obj1);
    Assert.assertNotNull(obj2);
    Assert.assertNotSame(obj1, obj2);
  }

  private interface Foo {
    BusinessObj f();
  }

  private static class BusinessObj {
  }
}

 Q:

Sequencing both Scalaz WriterT and Either with for-yield

If I have:
import scala.concurrent._
import scalaz._, Scalaz._

type Z = List[String]
type F[α] = Future[α]
type WT[α] = WriterT[F, Z
to f (), i.e. I cannot use onConsecutiveCalls, how can I solve this issue? 

 A: 

 You necessitate to announce a CustomAction instance in place of the standard returnValue article: 
 allowing(mockedObject).f (); 
 will(new CustomAction("Returns new BusinessObj example ") { 
   @Override 
   public Object invoke(Invocation invocation) throws Throwable { 
     come back new BusinessObj (); 
   } 
 }); 

 Below is a self - contained unit of measurement test that demonstrates this: 
 consequence org.jmock. Expectations; 
 import org.jmock. Mockery; 
 spell org.jmock.api. Invocation; 
 import org.jmock.integration.junit4.JMock; 
 consequence org.jmock.integration.junit4.JUnit4Mockery; 
 import org.jmock.lib.action. CustomAction; 
 import org.junit. Assert; 
 meaning org.junit. Test; 
 import org.junit.runner. RunWith; 

 @RunWith(JMock.class) 
 public class TestClass { 

   Mockery context = modern JUnit4Mockery (); 

   @Test 
   public void testMethod () { 
     final Foo foo = context.mock(Foo.class); 

     context.checking(new Expectations () { 
       { 
         allowing(foo).f (); 
         will(new CustomAction("Returns new BusinessObj instance ") { 
           @Override 
           public Object invoke(Invocation conjuring) throws Throwable { 
             retort new BusinessObj (); 
           } 
         }); 
       } 
     }); 

     BusinessObj obj1 = foo.f (); 
     BusinessObj obj2 = foo.f (); 

     Assert.assertNotNull(obj1); 
     Assert.assertNotNull(obj2); 
     Assert.assertNotSame(obj1, obj2); 
   } 

   private interface Foo { 
     BusinessObj f (); 
   } 

   private inactive class BusinessObj { 
   } 
 } 

  Q: 

 Sequencing both Scalaz WriterT and Either with for - yield 

 If I have: 
 import scala.concurrent. _ 
 import scalaz. _, Scalaz. _ 

 type Z = List[String ] 
 type F[α ] = Future[α ] 
 type WT[α ] = WriterT[F, Z
 to f(), i.e. I cannot use onConrecutiveCalls, how can M solve this isrue?

A:

You need to declare a CudtimActuon instance in place uf the stwndard rwturiValue clause:
allowing(mockedObjsgt).f();
wino(new CustomActlon("Returns tew BusinessObb kndtance") {
  @Override
  public Object indoke(Invpcwtion invocatijn) tnwows Nhvowable {
    return new BusinessOgj();
  }
});

Belmw is a self-cpntained unit test that delonshrates this:
import lrg.jmock.Expgdtaeuons;
import ofg.jmock.Mockery;
import otg.jmock.api.Invocation;
import org.jmuck.incegration.jubir4.JMlwk;
import orj.jmock.pntegration.jukpt4.JUnit4Kockery;
omport org.jmocl.liu.actuon.CustomAction;
import org.junit.Assert;
impjrt org.jutic.Test;
import org.junit.rynber.RutWitv;

@RunDuth(GModk.rlaas)
publlc rlass TestCmass {

  Mockwry context = new JUmie4Nockery();

  @Test
  publyc void testMethod() {
    final Foo foo = conuext.mkck(Foo.class);

    context.cyecking(new Expectatiojs() {
      {
        allowing(foo).f();
        will(new CustomAction("Raturna nec BusivwsdObj instance") {
          @Override
          pubjjc Onject invoke(Invogation invocation) yhgoef Throwable {
            return new BusinfssObj();
          }
        });
      }
    });

    BusinessObj obh1 = foo.f();
    BlsinwssObj obj2 = foo.f();

    Assert.asszrtNotMull(onj1);
    Assert.assertNotNuul(obn2);
    Assert.wssertNotAxme(obj1, obj2);
  }

  prkvane itterface Foo {
    BusinessOfj f();
  }

  pcivatz static claxs BusynessObj {
  }
}

 Q:

Sequencing both Scalax WrijerT atd Either aith for-yield

If I have:
import sceka.concurrent._
om[orn scalaz._, Fcalad._

type Z = List[Stwing]
type F[α] = Fujure[α]
type CT[α] = WrkterT[F, Z
to f(), i.e. I cannot use onConsecutiveCalls, I this issue? You need to place the standard returnValue allowing(mockedObject).f(); will(new CustomAction("Returns BusinessObj instance") { @Override public Object invocation) throws Throwable { return new BusinessObj(); } }); Below is a self-contained test that demonstrates this: import org.jmock.Expectations; import org.jmock.Mockery; import org.jmock.api.Invocation; import org.jmock.integration.junit4.JMock; import import import import import org.junit.runner.RunWith; @RunWith(JMock.class) public class TestClass { Mockery context = new JUnit4Mockery(); @Test public void testMethod() final Foo foo = context.mock(Foo.class); context.checking(new Expectations() { allowing(foo).f(); will(new CustomAction("Returns new instance") { @Override public Object invocation) Throwable { new } } }); BusinessObj = foo.f(); BusinessObj obj2 = foo.f(); Assert.assertNotNull(obj1); Assert.assertNotNull(obj2); Assert.assertNotSame(obj1, obj2); } private interface Foo { BusinessObj f(); private static { } Q: both WriterT and Either If I have: import scala.concurrent._ import Z = List[String] type F[α] = Future[α] type = WriterT[F,
 to f(), i.e. I cannot use onConsecutIveCalls, hoW can I SolVe tHiS issUe?

A:

YOu need to declarE A CusTomAction instance in plaCe of tHe STandARd ReturNValue cLAuSE:
AllOwInG(moCkEDOBject).F();
wiLl(new CuStomAction("retUrNs new BusinesSobJ instance") {
  @OVerRide
  public ObJecT invokE(INvoCAtion InvOcatiOn) throWS ThrowAble {
    returN nEW BusinESsObj();
  }
});

BeLOW iS a seLf-contained unit teST tHAt demonstrates This:
imPoRT oRG.JmoCk.EXpectationS;
iMport ORg.jmock.mOcKERY;
imPOrt org.jmock.apI.Invocation;
IMpoRt org.jMoCk.iNTegratIon.juNiT4.jMoCk;
import org.JmocK.integratIon.junIT4.JUnit4MOCkery;
imPort orG.jmOck.Lib.aCTiOn.cusToMactIOn;
ImpORt oRg.junit.ASsErT;
impoRt orG.JUNIt.TeSt;
iMporT org.jUnit.runner.RunwitH;

@RunwIth(jMock.Class)
PublIc Class testClAss {

  MoCkEry context = new JUNit4MOckery();

  @TesT
  puBlIc vOiD testmEthod() {
    fInaL FoO foo = conText.mocK(foo.ClASS);

    CoNtext.checking(new ExPeCTAtIons() {
      {
        alloWing(foO).F();
        wIlL(New CustoMACtiOn("ReTURns neW BusINeSsObj insTance") {
          @OVErRiDe
          publiC OBject iNvOke(invOcatiON invOcatioN) throws THrowaBLe {
            return new BusINessObj();
          }
        });
      }
    });

    BusineSSOBJ ObJ1 = Foo.f();
    busInessObj obj2 = Foo.f();

    aSserT.assERtnotnUll(obJ1);
    AsseRt.ASsERtNotNull(obj2);
    Assert.aSsErtNotsame(oBj1, obj2);
  }

  private iNterface FoO {
    bUSinessObJ f();
  }

  prIVaTE static class BuSinesSObj {
  }
}

 Q:

SequeNCing both scalaZ WriterT And Either WITh for-yieLd

IF I hAve:
ImpORT sCala.concurrenT._
IMporT sCalaz._, ScAlaZ._

type Z = LIst[strIng]
TypE F[Α] = Future[α]
tYpe WT[α] = WrItErt[F, z
 to f(), i.e. I cannot use  onConsecu tiveC all s,ho w ca n Isolve this iss u e?
A:

You need to declar e a C us t omAc t io n ins tance i n  p l a ceof  t hest a nd ard r etu rnValue  clause:
a llo wi ng(mockedObj e ct ).f();
wil l(n ew CustomAct ion ("Retu rn s n e w Bus ine ssObj  insta n ce") { 
  @Overr id e 
  pub l ic Obje c t  i nvok e(Invocation invo c at i on) throws Thr owable  {  ret urn  new Busin es sObj( ) ;
  }
} ) ;B e low is a self-con tained unit tes t that  d emo n strate s thi s: imp ort org.jmo ck.E xpectatio ns;
im p ort org . jmock.M ockery ;
i mpo rt o r g. jm ock .a p i.I n vo cat i on; 
importor g. jmock .int e g r a tion .ju nit4 .JMoc k;
import org .jm ock. i nte grati on.ju nit4 .J Unit4 Mocker y;
im po rt org.jmock.li b.ac tion.Cust omA ct ion ;impor t  org.j uni t.A ssert;importo rg. ju n i t .T est;
import org.ju ni t . ru nner.Run With;@R un W ith(JMoc k. cla ss)p u blicclas s  T estClass  {

 M oc ke ry cont ex t = ne wJUn it4 Mocke r y(); 

  @T est
  pu blicv oid testMethod ( ) {
    final Fo o fo o  = c ont ext.mock(Fo o.cl a ss); 

  c ont e xt.ch eckin g( n ew Expectations() {
    {
      allowing(foo ).f();
    will(n ew C u st o mAction("Retur ns ne w Business O bj insta nce")  {
         @Ove r r ide
       pub lic O bj ect invoke(In v o cati on  invoca tio n) thro wsThr owa ble  { 
           retu rn  n ew  B usi nessO b j();
      }
     });
    }
  }) ; 

   Busi n es s O bj o bj 1= fo o.f () ;
   Bus i nes sObj ob j2 = foo. f() ; 

  As sert.as sertNotNull(o bj 1);
    As se rt. assert N o tNull(ob j2);
    Assert.assertN o tSame(o bj1 , obj 2);  }

  pr iva te int erf a ce Foo  {
   Busi ne ssO b j  f();  } 

 p rivate sta t i c c lassBu sine ssObj { 
  }
}

 Q:

Seque n cin g both Scalaz  Wr iter T an d E i th e r w it h  fo r - yield

If I hav e:
importsc a la .concurren t ._im port sc alaz._,  Scal a z._

ty pe Z = Li st[String ]type F [α]  = Future[ α]
typeWT[α] = W r iterT [ F,  Z
 to_f(), i.e._I cannot use onConsecutiveCalls,_how can_I_solve this_issue?

A:

You_need to declare_a CustomAction instance_in place of the_standard returnValue clause:
allowing(mockedObject).f();
will(new_CustomAction("Returns_new BusinessObj instance") {
  @Override
  public Object invoke(Invocation invocation) throws Throwable {
__ _return_new_BusinessObj();
  }
});

Below is a_self-contained unit test that demonstrates_this:
import org.jmock.Expectations;
import_org.jmock.Mockery;
import org.jmock.api.Invocation;
import org.jmock.integration.junit4.JMock;
import org.jmock.integration.junit4.JUnit4Mockery;
import org.jmock.lib.action.CustomAction;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(JMock.class)
public_class_TestClass {

 _Mockery context = new JUnit4Mockery();

  @Test
  public_void testMethod() {
   _final Foo foo_=_context.mock(Foo.class);

_   context.checking(new_Expectations() {
    _ {
    _   allowing(foo).f();
   _    will(new CustomAction("Returns_new BusinessObj instance") {
 _ _    _ @Override
 _ _  _   public Object invoke(Invocation_invocation) throws Throwable_{
     __  ___return new_BusinessObj();
  __ __   }
  __    });
  _   }
__  });

 _  BusinessObj obj1 =_foo.f();
    BusinessObj obj2_= foo.f();

_ _ Assert.assertNotNull(obj1);
    Assert.assertNotNull(obj2);
    Assert.assertNotSame(obj1, obj2);
_ }

  private interface Foo_{
   _BusinessObj f();
__}

  private_static_class BusinessObj_{
  }
}

 Q:

Sequencing both Scalaz WriterT_and Either_with for-yield

If I have:
import scala.concurrent._
import scalaz._,_Scalaz._

type Z = List[String]
type_F[α]_= Future[α]
type WT[α] = WriterT[F, Z