// Path: src/test/java/examples/auction/mock/MockPayPal.java
// @Service("/PayPal")
// public class MockPayPal implements PayPal
// {
//   public static boolean isSettle = true;
// 
//   private Payment _payment = new MockPayment("sale-id-0",
//                                              Payment.PaymentState.approved);
//   private long _sleep = 0;
// 
//   @Override
//   public void settle(AuctionData auction,
//                      Auction.Bid bid,
//                      CreditCard creditCard,
//                      String payPalRequestId,
//                      Result<Payment> result)
//   {
//     if (isSettle) {
//       try {
//         Thread.sleep(_sleep);
//       } catch (InterruptedException e) {
//         throw new RuntimeException(e);
//       }
// 
//       result.ok(_payment);
//     }
//   }
// 
//   @Override
//   public void refund(String settlementId,
//                      String payPalRequestId,
//                      String sale,
//                      Result<Refund> result)
//   {
//     Refund refund = new MockRefund(Refund.RefundState.completed);
// 
//     result.ok(refund);
//   }
// 
//   public void configure(Payment payment,
//                         long sleep,
//                         Result<Void> result)
//   {
//     _payment = payment;
//     _sleep = sleep;
// 
//     result.ok(null);
//   }
// }
// 
// Path: src/test/java/examples/auction/mock/MockPayment.java
// public class MockPayment implements Payment
// {
//   private String _saleId;
//   private PaymentState _state;
// 
//   public MockPayment()
//   {
//   }
// 
//   public MockPayment(String saleId, PaymentState state)
//   {
//     _saleId = saleId;
//     _state = state;
//   }
// 
//   @Override
//   public PaymentState getState()
//   {
//     return _state;
//   }
// 
//   @Override
//   public String getSaleId()
//   {
//     return _saleId;
//   }
// }


import java.util.logging.Logger;
import javax.inject.Inject;
import io.baratine.service.Result;
import io.baratine.service.Service;
import io.baratine.service.Services;
import io.baratine.vault.IdAsset;
import com.caucho.junit.LogConfig;
import com.caucho.junit.RunnerBaratine;
import com.caucho.junit.ServiceTest;
import com.caucho.junit.State;
import examples.auction.mock.MockPayPal;
import examples.auction.mock.MockPayment;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
                                    .contains(auctionData.getEncodedId()));

    Assert.assertEquals(auctionData.getLastBidder(),
                        winnerUserData.getEncodedId());

    SettlementTransactionState state = settlement.getTransactionState();

    Assert.assertEquals(state.getSettleStatus(),
                        AuctionSettlement.Status.SETTLING);

    Assert.assertEquals(state.getRefundStatus(),
                        AuctionSettlement.Status.NONE);

    Assert.assertEquals(state.getAuctionWinnerUpdateState(),
                        SettlementTransactionState.AuctionWinnerUpdateState.SUCCESS);
    Assert.assertEquals(state.getAuctionWinnerResetState(),
                        SettlementTransactionState.AuctionWinnerUpdateState.NONE);

    Assert.assertEquals(state.getUserSettleState(),
                        SettlementTransactionState.UserUpdateState.SUCCESS);
    Assert.assertEquals(state.getUserResetState(),
                        SettlementTransactionState.UserUpdateState.NONE);

    Assert.assertEquals(state.getPaymentState(),
                        SettlementTransactionState.PaymentTxState.PENDING);
    Assert.assertEquals(state.getRefundState(),
                        SettlementTransactionState.PaymentTxState.NONE);

    //retry
    _paypal.configure(
// Path: src/test/java/examples/auction/mock/MockPayPal.java
// @Service("/PayPal")
// public class MockPayPal implements PayPal
// {
//   public static boolean isSettle = true;
// 
//   private Payment _payment = new MockPayment("sale-id-0",
//                                              Payment.PaymentState.approved);
//   private long _sleep = 0;
// 
//   @Override
//   public void settle(AuctionData auction,
//                      Auction.Bid bid,
//                      CreditCard creditCard,
//                      String payPalRequestId,
//                      Result<Payment> result)
//   {
//     if (isSettle) {
//       try {
//         Thread.sleep(_sleep);
//       } catch (InterruptedException e) {
//         throw new RuntimeException(e);
//       }
// 
//       result.ok(_payment);
//     }
//   }
// 
//   @Override
//   public void refund(String settlementId,
//                      String payPalRequestId,
//                      String sale,
//                      Result<Refund> result)
//   {
//     Refund refund = new MockRefund(Refund.RefundState.completed);
// 
//     result.ok(refund);
//   }
// 
//   public void configure(Payment payment,
//                         long sleep,
//                         Result<Void> result)
//   {
//     _payment = payment;
//     _sleep = sleep;
// 
//     result.ok(null);
//   }
// }
// 
// Path: src/test/java/examples/auction/mock/MockPayment.java
// public class MockPayment implements Payment
// {
//   private String _saleId;
//   private PaymentState _state;
// 
//   public MockPayment()
//   {
//   }
// 
//   public MockPayment(String saleId, PaymentState state)
//   {
//     _saleId = saleId;
//     _state = state;
//   }
// 
//   @Override
//   public PaymentState getState()
//   {
//     return _state;
//   }
// 
//   @Override
//   public String getSaleId()
//   {
//     return _saleId;
//   }
// }


// Path: src/test/java/examples/auction/AuctionSettleResumeTest.java
import java.util.logging.Logger;
import javax.inject.Inject;
import io.baratine.service.Result;
import io.baratine.service.Service;
import io.baratine.service.Services;
import io.baratine.vault.IdAsset;
import com.caucho.junit.LogConfig;
import com.caucho.junit.RunnerBaratine;
import com.caucho.junit.ServiceTest;
import com.caucho.junit.State;
import examples.auction.mock.MockPayPal;
import examples.auction.mock.MockPayment;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

                                    .contains(auctionData.getEncodedId()));

    Assert.assertEquals(auctionData.getLastBidder(),
                        winnerUserData.getEncodedId());

    SettlementTransactionState state = settlement.getTransactionState();

    Assert.assertEquals(state.getSettleStatus(),
                        AuctionSettlement.Status.SETTLING);

    Assert.assertEquals(state.getRefundStatus(),
                        AuctionSettlement.Status.NONE);

    Assert.assertEquals(state.getAuctionWinnerUpdateState(),
                        SettlementTransactionState.AuctionWinnerUpdateState.SUCCESS);
    Assert.assertEquals(state.getAuctionWinnerResetState(),
                        SettlementTransactionState.AuctionWinnerUpdateState.NONE);

    Assert.assertEquals(state.getUserSettleState(),
                        SettlementTransactionState.UserUpdateState.SUCCESS);
    Assert.assertEquals(state.getUserResetState(),
                        SettlementTransactionState.UserUpdateState.NONE);

    Assert.assertEquals(state.getPaymentState(),
                        SettlementTransactionState.PaymentTxState.PENDING);
    Assert.assertEquals(state.getRefundState(),
                        SettlementTransactionState.PaymentTxState.NONE);

    //retry
    _paypal.configure(
      new MockPayment("sale-id", Payment.PaymentState.approved),