@Test
 public void testCreatePreauthorization() {
   String token = getToken();
   PreauthorizationService srv = Paymill.getService(PreauthorizationService.class);
   Preauthorization params = new Preauthorization();
   params.setToken(token);
   params.setAmount(399);
   params.setCurrency("EUR");
   Preauthorization preauthorization = srv.create(params);
   assertNotNull(preauthorization.getId());
   assertNull(preauthorization.getToken());
   assertEquals(399, (int) preauthorization.getAmount());
   assertNotNull(preauthorization.getPayment());
   assertNotNull(preauthorization.getPayment().getId());
 }
  @Test
  public void testCreateWithPayment() {
    PaymentService srvPayment = Paymill.getService(PaymentService.class);
    Payment payment = srvPayment.create(getToken());

    PreauthorizationService svrTx = Paymill.getService(PreauthorizationService.class);
    Preauthorization preauthorizationParams = new Preauthorization();
    preauthorizationParams.setPayment(payment);
    preauthorizationParams.setAmount(100);
    preauthorizationParams.setCurrency("EUR");
    Preauthorization tx = svrTx.create(preauthorizationParams);

    assertNotNull(tx);
    assertNotNull(tx.getId());
    assertEquals((int) tx.getAmount(), 100);
    assertNotNull(tx.getPayment());
    assertEquals(payment.getId(), tx.getPayment().getId());
  }