// Path: src/main/java/examples/auction/AuctionSession.java
// class UserInitData
// {
//   private String user;
//   private String password;
// 
//   private boolean isAdmin;
// 
//   public UserInitData()
//   {
//   }
// 
//   public UserInitData(String user, String password, boolean isAdmin)
//   {
//     this.user = user;
//     this.password = password;
//     this.isAdmin = isAdmin;
//   }
// 
//   public String getUser()
//   {
//     return user;
//   }
// 
//   public String getPassword()
//   {
//     return password;
//   }
// 
//   public boolean isAdmin()
//   {
//     return isAdmin;
//   }
// 
//   @Override
//   public String toString()
//   {
//     return this.getClass().getSimpleName() + "["
//            + user
//            + ", "
//            + password
//            + ']';
//   }
// }
// 
// 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);
//   }
// }


import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import io.baratine.service.ResultFuture;
import io.baratine.service.Service;
import io.baratine.service.Services;
import com.caucho.junit.ConfigurationBaratine;
import com.caucho.junit.RunnerBaratine;
import com.caucho.junit.ServiceTest;
import com.caucho.junit.State;
import examples.auction.AuctionSession.UserInitData;
import examples.auction.mock.MockPayPal;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
                       testTime = ConfigurationBaratine.TEST_TIME)
public class AuctionSettlementEnsureTest
{
  @Inject
  @Service("/User")
  UserVault _users;

  @Inject
  @Service("/Auction")
  AuctionVault _auctions;

  @Inject
  @Service("/AuctionSettlement")
  AuctionSettlementVault _settlements;

  @Inject
  @Service("/PayPal")
  MockPayPal _mockPayPal;

  @Inject
  Services _services;

  @Inject
  RunnerBaratine _baratine;

  @Test
  public void testEnsure()
    throws IOException, InterruptedException
  {
    UserSync spock = createUser("Spock", "passwd");
// Path: src/main/java/examples/auction/AuctionSession.java
// class UserInitData
// {
//   private String user;
//   private String password;
// 
//   private boolean isAdmin;
// 
//   public UserInitData()
//   {
//   }
// 
//   public UserInitData(String user, String password, boolean isAdmin)
//   {
//     this.user = user;
//     this.password = password;
//     this.isAdmin = isAdmin;
//   }
// 
//   public String getUser()
//   {
//     return user;
//   }
// 
//   public String getPassword()
//   {
//     return password;
//   }
// 
//   public boolean isAdmin()
//   {
//     return isAdmin;
//   }
// 
//   @Override
//   public String toString()
//   {
//     return this.getClass().getSimpleName() + "["
//            + user
//            + ", "
//            + password
//            + ']';
//   }
// }
// 
// 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/AuctionSettlementEnsureTest.java
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import io.baratine.service.ResultFuture;
import io.baratine.service.Service;
import io.baratine.service.Services;
import com.caucho.junit.ConfigurationBaratine;
import com.caucho.junit.RunnerBaratine;
import com.caucho.junit.ServiceTest;
import com.caucho.junit.State;
import examples.auction.AuctionSession.UserInitData;
import examples.auction.mock.MockPayPal;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

                       testTime = ConfigurationBaratine.TEST_TIME)
public class AuctionSettlementEnsureTest
{
  @Inject
  @Service("/User")
  UserVault _users;

  @Inject
  @Service("/Auction")
  AuctionVault _auctions;

  @Inject
  @Service("/AuctionSettlement")
  AuctionSettlementVault _settlements;

  @Inject
  @Service("/PayPal")
  MockPayPal _mockPayPal;

  @Inject
  Services _services;

  @Inject
  RunnerBaratine _baratine;

  @Test
  public void testEnsure()
    throws IOException, InterruptedException
  {
    UserSync spock = createUser("Spock", "passwd");
    UserSync kirk = createUser("Kirk", "passwd");