package com.eway.payment.rapid.sdk.integration.transaction;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import com.eway.payment.rapid.sdk.InputModelFactory;
import com.eway.payment.rapid.sdk.RapidClient;
import com.eway.payment.rapid.sdk.beans.external.Address;
import com.eway.payment.rapid.sdk.beans.external.CardDetails;
import com.eway.payment.rapid.sdk.beans.external.Customer;
import com.eway.payment.rapid.sdk.beans.external.PaymentDetails;
import com.eway.payment.rapid.sdk.beans.external.PaymentMethod;
import com.eway.payment.rapid.sdk.beans.external.Transaction;
import com.eway.payment.rapid.sdk.integration.IntegrationTest;
import com.eway.payment.rapid.sdk.output.CreateTransactionResponse;
import com.eway.payment.rapid.sdk.output.QueryTransactionResponse;

public class QueryTransactionTest extends IntegrationTest {

    RapidClient client;
    Transaction trans;

    @Before
    public void setup() {
        client = getSandboxClient();

    }

    @Test
    public void testValidInput() {
        trans = InputModelFactory.createTransaction();
        Customer c = InputModelFactory.initCustomer();
        Address a = InputModelFactory.initAddress();
        PaymentDetails p = InputModelFactory.initPaymentDetails();
        CardDetails cd = InputModelFactory.initCardDetails("12", "24");
        c.setCardDetails(cd);
        c.setAddress(a);
        trans.setCustomer(c);
        trans.setPaymentDetails(p);

        CreateTransactionResponse transResponse = client.create(
                PaymentMethod.Direct, trans);
        Assert.assertTrue(transResponse.getTransactionStatus().isStatus());
        Assert.assertNotEquals(0, transResponse.getTransactionStatus()
                .getTransactionID());

        int transactionId = transResponse.getTransactionStatus()
                .getTransactionID();
        QueryTransactionResponse query = client.queryTransaction(transactionId);
        Assert.assertEquals(transactionId, query.getTransactionStatus()
                .getTransactionID());
        Assert.assertFalse(query.getTransaction().getOptions().isEmpty());
        Assert.assertTrue(query.getErrors() == null || query.getErrors().isEmpty());

    }

    @Test
    public void testBlankInput() {
        QueryTransactionResponse res = client.queryTransaction("");
        Assert.assertNull(res.getTransaction());
    }

    @Test
    public void testInvalidInput() {
        QueryTransactionResponse res = client
                .queryTransaction(InputModelFactory.randomString(50));
        Assert.assertNull(res.getTransaction());
    }

    @After
    public void tearDown() {

    }

}

@@ -58,106 +58,8 @@
 n;%0A%0A
-import org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0A
 impo
@@ -203,23 +203,17 @@
 xternal.
-Address
+*
 ;%0Aimport
@@ -244,222 +244,103 @@
 sdk.
-beans.external.CardDetails;%0Aimport com.eway.payment.rapid.sdk.beans.external.Customer;%0Aimport com.eway.payment.rapid.sdk.beans.external.PaymentDetails;%0Aimport com.eway.payment.rapid.sdk.beans.external.PaymentMethod
+integration.IntegrationTest;%0Aimport com.eway.payment.rapid.sdk.output.CreateTransactionResponse
 ;%0Aim
@@ -371,31 +371,28 @@
 pid.sdk.
-beans.external.
+output.Query
 Transact
@@ -394,16 +394,24 @@
 nsaction
+Response
 ;%0Aimport
@@ -415,197 +415,96 @@
 ort 
-com.eway.payment.rapid.sdk.integration.IntegrationTest;%0Aimport com.eway.payment.rapid.sdk.output.CreateTransactionResponse;%0Aimport com.eway.payment.rapid.sdk.output.QueryTransactionResponse
+org.junit.After;%0Aimport org.junit.Assert;%0Aimport org.junit.Before;%0Aimport org.junit.Test
 ;%0A%0Ap
@@ -1778,14 +1778,14 @@
 sert
-Fals
+Tru
 e(
+!
 quer
@@ -2047,36 +2047,36 @@
    Assert.assert
-Null
+True
 (res.getTransact
@@ -2070,34 +2070,96 @@
 s.getTransaction
-()
+Status().getTransactionID() == 0 %7C%7C res.getTransaction() == null
 );%0A    %7D%0A%0A    @T

Update QueryTransactionTest.java