summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-21 09:24:23 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-06-21 09:24:23 +0000
commit9d393de96706a0bc0eaff5394eadd322b5fae277 (patch)
tree0124397ebef6e0edd4c435c6e1a1273ae6ee71c7 /sandbox
parent896792aac64e78c84e8b7cad3a87c3d729d1a7d3 (diff)
Tidy code in Payment component implementation
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@786960 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java35
-rw-r--r--sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java19
2 files changed, 16 insertions, 38 deletions
diff --git a/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java b/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java
index e3b1d88d4a..53e896a580 100644
--- a/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java
+++ b/sandbox/travelsample/contributions/payment-java-contribution/src/main/java/payment/PaymentImpl.java
@@ -57,34 +57,21 @@ public class PaymentImpl implements Payment {
protected float transactionFee = 0.01f;
public String makePaymentMember(String customerId, float amount) {
- Customer customer = null;
-
try {
- customer = customerRegistry.getCustomer(customerId);
+ Customer customer = customerRegistry.getCustomer(customerId);
+ String status = creditCardPayment.authorize(customer.getCreditCard(),
+ amount + transactionFee);
+ emailGateway.sendEmail("order@tuscanyscatours.com",
+ customer.getEmail(),
+ "Status for your payment",
+ customer + " >>> Status = " + status);
+ return status;
} catch (CustomerNotFoundException ex) {
return "Payment failed due to " + ex.getMessage();
+ } catch (AuthorizeFault_Exception e) {
+ return e.getFaultInfo().getErrorCode();
} catch (Throwable t) {
return "Payment failed due to system error " + t.getMessage();
- }
-
- CreditCardDetailsType ccDetails = customer.getCreditCard();
-
- float total = amount + transactionFee;
-
- String status;
- try {
- status = creditCardPayment.authorize(ccDetails, total);
- } catch (AuthorizeFault_Exception e) {
- status = e.getFaultInfo().getErrorCode();
- }
-
- StringBuffer body = new StringBuffer();
- body.append(customer);
- body.append("\n").append("Status: ").append(status).append("\n");
- emailGateway.sendEmail("order@tuscanyscatours.com", customer.getEmail(), "Status for your payment", body
- .toString());
-
- return status;
+ }
}
-
}
diff --git a/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java b/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java
index 39671b33ca..b6c7561a15 100644
--- a/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java
+++ b/sandbox/travelsample/contributions/payment-java-contribution/src/test/java/payment/PaymentTestCase.java
@@ -25,17 +25,12 @@ import org.apache.tuscany.sca.node.SCANode;
import org.apache.tuscany.sca.node.SCANodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import org.junit.Ignore;
import org.junit.Test;
-/**
- *
- */
public class PaymentTestCase {
private static SCANode node;
- /**
- * @throws java.lang.Exception
- */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
try {
@@ -53,26 +48,22 @@ public class PaymentTestCase {
public void testPayment() {
SCAClient client = (SCAClient) node;
Payment payment = client.getService(Payment.class, "PaymentComponent");
- System.out.println(payment.makePaymentMember("c-0", 100.00f));
- System.out.println(payment.makePaymentMember("c-1", 100.00f));
+
+ System.out.println("\n\nSuccessful Payment - Status = \n\n" + payment.makePaymentMember("c-0", 100.00f));
+ System.out.println("\n\nFailed Payment - Status = \n\n" + payment.makePaymentMember("c-1", 100.00f));
}
@Test
- //@Ignore
+ @Ignore
public void testWaitForInput() {
-/*
System.out.println("Press a key to end");
try {
System.in.read();
} catch (Exception ex) {
}
System.out.println("Shutting down");
-*/
}
- /**
- * @throws java.lang.Exception
- */
@AfterClass
public static void tearDownAfterClass() throws Exception {
if (node != null) {