package com.bigcommerce.api;

import static org.junit.Assert.*;

import org.jmock.Mockery;
import org.junit.Test;
import org.w3c.dom.Element;

/**
 * A simple test that serves as an example and starting point for building out
 * the test suite.
 */
public class ResourceTest {
	
	public static void main(String[] args) {
		String storeUrl = "https://examplestore.com";
		String use	= "admin";
		String apiKey = "akjfalksjflksjflaskdjflasdk";

		// Get Store API connection
		Store api = new Store(storeUrl, user, apiKey);

		// Get Orders resource to manage
		StringBuffer uriPath = new StringBuffer("/orders");
		BaseResource<Order> ordersRes = api.newResource(Order.class,
				uriPath.toString(), "order");

		testListOrderWithNoFilter(ordersRes);
		testListOrderWithFilter(ordersRes);
		testGetAnOrder(ordersRes);
		testUpdateOrder(ordersRes);
		testDeleteOrder(ordersRes);
	}

	/**
	 * 
	 * 
	 */
	public static void testGetAnOrder(BaseResource<Order> ordersRes) {
		Order order = null;

		// Set ID of the record
		ordersRes.setId(105);

		// Get an Order
		order = ordersRes.get();

		System.out.print(order.getId());
	}

	/**
	 * Test Orders with No Filter
	 * 
	 * @param api
	 */
	public static void testListOrderWithNoFilter(BaseResource<Order> ordersRes) {
		System.out.println("Test List Order without filter-----");
		Collection<Order> orders = ordersRes.listAll();

		for (Order order : orders) {
			System.out.println("Customer ID:" + order.getCustomerId());
			System.out.println("Order ID:" + order.getId());
			System.out.println("Order Status:" + order.getStatus());

			System.out.println("---------------------");
		}
	}

	/**
	 * Test Orders with Filter
	 * 
	 * @param api
	 */
	public static void testListOrderWithFilter(BaseResource<Order> ordersRes) {
		System.out.println("Test List Order with min_id filter-----");

		// Filter parameters
		Filter filter = Filter.create();
		filter.add("min_id", "107");
		Collection<Order> orders = ordersRes.listAll(filter);

		for (Order order : orders) {
			System.out.println("Customer ID:" + order.getCustomerId());
			System.out.println("Order ID:" + order.getId());
			System.out.println("Order Status:" + order.getStatus());

			System.out.println("---------------------");
		}
	}

	/**
	 * Test Order update Status
	 * 
	 * @param api
	 */
	public static void testUpdateOrder(BaseResource<Order> ordersRes) {
		System.out.println("Test  Update Order-----");

		// Set ID of the record to be updated
		ordersRes.setId(107);

		// Form parameters
		Form form = Form.create();
		form.addProperty("status_id", 12);

		// Update
		Boolean status = ordersRes.update(form);

		System.out.println("Is Order Updated? " + status);
	}
	

	/**
	 * Test Order delete
	 * 
	 * @param api
	 */
	public static void testDeleteOrder(BaseResource<Order> ordersRes) {
		System.out.println("Test  Update Order-----");

		// Set ID of the record to be deleted
		ordersRes.setId(107);

		// Update
		Boolean status = ordersRes.delete();

		System.out.println("Is Order Deleted? " + status);
	}

}

@@ -34,219 +34,129 @@
 ort 
-static org.junit.Assert.*;%0A%0Aimport org.jmock.Mockery;%0Aimport org.junit.Test;%0Aimport org.w3c.dom.Element;%0A%0A/**%0A * A simple test that serves as an example and starting point for building out%0A * the test suite.%0A */
+java.util.Collection;%0A%0Aimport com.bigcommerce.api.resources.BaseResource;%0Aimport com.bigcommerce.api.resources.Resource;%0A
 %0Apub
@@ -180,17 +180,16 @@
 eTest %7B%0A
-%09
 %0A%09public
@@ -256,24 +256,47 @@
 s://
-examplestore.com
+store-nhze6w2d.mybigcommerce.com/api/v2
 %22;%0A%09
@@ -310,17 +310,19 @@
  use
-%09= %22admin
+r = %22webops
 %22;%0A%09
@@ -343,35 +343,48 @@
  = %22
-akjfalksjflksjflaskdjflasdk
+5fd83d1753c6dbd125da6b0433d1ec6620c5b2bf
 %22;%0A%0A
@@ -554,20 +554,16 @@
 rs%22);%0A%09%09
-Base
 Resource
@@ -586,19 +586,19 @@
 s = api.
-new
+get
 Resource
@@ -781,24 +781,26 @@
 dersRes);%0A%09%09
+//
 testDeleteOr
@@ -870,28 +870,24 @@
 tGetAnOrder(
-Base
 Resource%3COrd
@@ -1165,28 +1165,24 @@
 ithNoFilter(
-Base
 Resource%3COrd
@@ -1675,20 +1675,16 @@
 hFilter(
-Base
 Resource
@@ -2266,36 +2266,32 @@
 testUpdateOrder(
-Base
 Resource%3COrder%3E 

Update ResourceTest.java