// Path: src/main/java/com/apresa/restflow/fsm/Event.java
// public class Event {
// 
// 	private String name;
// 	private Map<String, Object> params = new HashMap<>();
// 
// 	public Event(Object name) {
// 		this.name = name.toString();
// 	}
// 
// 	public static Event build(Object name) {
// 		return new Event(name);
// 	}
// 
// 	public Event param(String name, Object value) {
// 		this.params.put(name, value);
// 		return this;
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	public <T> T getParameter(String name) {
// 		return (T) params.get(name);
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// }
// 
// Path: src/test/java/com/apresa/restflow/samples/order/flow/Order.java
// public class Order {
// 	@StateReference
// 	public OrderStatus status = OrderStatus.INITIAL;
// 	public Object[] products;
// 	public Float price;
// 	public Object customer;
// 	public Object track;
// 	public String check = "";
// }
// 
// Path: src/test/java/com/apresa/restflow/samples/order/flow/OrderFlow.java
// @Flow(OrderStatus.class)
// @Transitions({
// 		@Transition(event = "PLACE", from="INITIAL", to = "PLACED"),
// 		@Transition(event = "PAY", from="PLACED", to = "PAYED"),
// 		@Transition(event = "SEND", from="PAYED", to = "SENT")
// })
// public class OrderFlow extends AbstractBeanFlow<Order> {
// 
// 
// 	@Guard("PLACE")
// 	public boolean orderCheck(Order order) {
// 		order.check += "3";
// 		return true;
// 	}
// 
// 	@Guard(value="PLACE", order=2)
// 	public boolean checkParams(Order order, @EventParam("products") Object[] products, @EventParam("customer") Object customer){
// 		order.check += "2";
// 		return products != null && customer != null;
// 	}
// 
// 	@Guard(value="PLACE", order=1)
// 	public boolean firstCheck(Order order) {
// 		order.check += "1";
// 		return true;
// 	}
// 
// 	@On("PLACE")
// 	private void checkPlace(Order order) {
// 		order.check += "5";
// 	}
// 
// 	@On(value="PLACE", order=1)
// 	private void fillOrderData(Order order, @EventParam("products") Object[] products, @EventParam("customer") Object customer){
// 		order.check += "4";
// 		order.products = products;
// 		order.customer = customer;
// 	}
// 
// 	@OnState("PLACED")
// 	private void calculatePrice(Order order){
// 		order.check += "7";
// 		order.price = 10f; //this should be calculated depending on the products
// 	}
// 
// 	@OnState(value="PLACED", order=1)
// 	private void doPlaced(Order order){
// 		order.check += "6";
// 	}
// 
// 	@Guard("PAY")
// 	private boolean checkPayment(Order order, @EventParam("payment") String recipe){
// 		return recipe != null;
// 	}
// 
// 	@Guard("SEND")
// 	private boolean checkPayment(Order order, @EventParam("tracking") Object track){
// 		return track != null;
// 	}
// 
// 	@On("SEND")
// 	private void fillOrderTracking(Order order, @EventParam("tracking") Object track){
// 		order.track = track;
// 	}
// 
// 	@OnState()
// 	private void notifyStateChange(Order order) {
// 		System.out.println(order.status);
// 	}
// 
// 	public static final void main(String[] args) throws StateMachineException {
// 		Order o = new Order();
// 
// 		OrderFlow flow = new OrderFlow();
// 
// 		flow.raise(Event.build("PLACE").param("products", new Object[]{"pid"}).param("customer", "customer"), o);
// 		flow.raise(Event.build("PAY").param("payment", "123"), o);
// 		flow.raise(Event.build("SEND").param("trancking", "UPS-ABC"), o);
// 	}
// }


import com.apresa.restflow.fsm.Event;
import com.apresa.restflow.samples.order.flow.Order;
import com.apresa.restflow.samples.order.flow.OrderFlow;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package com.apresa.restflow.samples.order;



public class OrderFlowTests {

	@Test
	public void itShouldInvokeMethodsInOrder() throws Exception {

		for(int i = 0; i < 10; i++) {
			final Order o = new Order();

			final OrderFlow flow = new OrderFlow();

			final Object[] products = new Object[]{"pid"};
			final String customer = "customer";
// Path: src/main/java/com/apresa/restflow/fsm/Event.java
// public class Event {
// 
// 	private String name;
// 	private Map<String, Object> params = new HashMap<>();
// 
// 	public Event(Object name) {
// 		this.name = name.toString();
// 	}
// 
// 	public static Event build(Object name) {
// 		return new Event(name);
// 	}
// 
// 	public Event param(String name, Object value) {
// 		this.params.put(name, value);
// 		return this;
// 	}
// 
// 	@SuppressWarnings("unchecked")
// 	public <T> T getParameter(String name) {
// 		return (T) params.get(name);
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// }
// 
// Path: src/test/java/com/apresa/restflow/samples/order/flow/Order.java
// public class Order {
// 	@StateReference
// 	public OrderStatus status = OrderStatus.INITIAL;
// 	public Object[] products;
// 	public Float price;
// 	public Object customer;
// 	public Object track;
// 	public String check = "";
// }
// 
// Path: src/test/java/com/apresa/restflow/samples/order/flow/OrderFlow.java
// @Flow(OrderStatus.class)
// @Transitions({
// 		@Transition(event = "PLACE", from="INITIAL", to = "PLACED"),
// 		@Transition(event = "PAY", from="PLACED", to = "PAYED"),
// 		@Transition(event = "SEND", from="PAYED", to = "SENT")
// })
// public class OrderFlow extends AbstractBeanFlow<Order> {
// 
// 
// 	@Guard("PLACE")
// 	public boolean orderCheck(Order order) {
// 		order.check += "3";
// 		return true;
// 	}
// 
// 	@Guard(value="PLACE", order=2)
// 	public boolean checkParams(Order order, @EventParam("products") Object[] products, @EventParam("customer") Object customer){
// 		order.check += "2";
// 		return products != null && customer != null;
// 	}
// 
// 	@Guard(value="PLACE", order=1)
// 	public boolean firstCheck(Order order) {
// 		order.check += "1";
// 		return true;
// 	}
// 
// 	@On("PLACE")
// 	private void checkPlace(Order order) {
// 		order.check += "5";
// 	}
// 
// 	@On(value="PLACE", order=1)
// 	private void fillOrderData(Order order, @EventParam("products") Object[] products, @EventParam("customer") Object customer){
// 		order.check += "4";
// 		order.products = products;
// 		order.customer = customer;
// 	}
// 
// 	@OnState("PLACED")
// 	private void calculatePrice(Order order){
// 		order.check += "7";
// 		order.price = 10f; //this should be calculated depending on the products
// 	}
// 
// 	@OnState(value="PLACED", order=1)
// 	private void doPlaced(Order order){
// 		order.check += "6";
// 	}
// 
// 	@Guard("PAY")
// 	private boolean checkPayment(Order order, @EventParam("payment") String recipe){
// 		return recipe != null;
// 	}
// 
// 	@Guard("SEND")
// 	private boolean checkPayment(Order order, @EventParam("tracking") Object track){
// 		return track != null;
// 	}
// 
// 	@On("SEND")
// 	private void fillOrderTracking(Order order, @EventParam("tracking") Object track){
// 		order.track = track;
// 	}
// 
// 	@OnState()
// 	private void notifyStateChange(Order order) {
// 		System.out.println(order.status);
// 	}
// 
// 	public static final void main(String[] args) throws StateMachineException {
// 		Order o = new Order();
// 
// 		OrderFlow flow = new OrderFlow();
// 
// 		flow.raise(Event.build("PLACE").param("products", new Object[]{"pid"}).param("customer", "customer"), o);
// 		flow.raise(Event.build("PAY").param("payment", "123"), o);
// 		flow.raise(Event.build("SEND").param("trancking", "UPS-ABC"), o);
// 	}
// }


// Path: src/test/java/com/apresa/restflow/samples/order/OrderFlowTests.java
import com.apresa.restflow.fsm.Event;
import com.apresa.restflow.samples.order.flow.Order;
import com.apresa.restflow.samples.order.flow.OrderFlow;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

package com.apresa.restflow.samples.order;



public class OrderFlowTests {

	@Test
	public void itShouldInvokeMethodsInOrder() throws Exception {

		for(int i = 0; i < 10; i++) {
			final Order o = new Order();

			final OrderFlow flow = new OrderFlow();

			final Object[] products = new Object[]{"pid"};
			final String customer = "customer";
			final Event event = Event.build("PLACE")