package com.nosolojava.fsm.parser;

import java.io.IOException;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import com.nosolojava.fsm.impl.runtime.executable.action.AssertEqualsAction;
import com.nosolojava.fsm.impl.runtime.executable.action.AssertNullAction;
import com.nosolojava.fsm.runtime.executable.CustomAction;

public class AssertCustomActionParser implements XppActionParser {

	private static final String ASSERT_NULL = "assertNull";
	private static final String ASSERT_EQUALS = "assertEquals";
	public static final String NS = "http://nosolojava.com/customActions/assert";

	@Override
	public String getNamespace() {
		return NS;
	}

	@Override
	public CustomAction parseAction(XmlPullParser xpp)
			throws XmlPullParserException, IOException {

		CustomAction action = null;

		String tagName = xpp.getName();
		if (tagName.equals(ASSERT_EQUALS)) {
			String expectedExp = xpp.getAttributeValue(null, "expectedExpr");
			String currentExp = xpp.getAttributeValue(null, "currentExpr");
			action = new AssertEqualsAction(expectedExp, currentExp);
		} else if (tagName.equals(ASSERT_NULL)) {
			String currentExp = xpp.getAttributeValue(null, "currentExpr");
			action = new AssertNullAction(currentExp);

		}

		return action;
	}

}

@@ -422,16 +422,180 @@
 rser %7B%0A%0A
+%09private static final String CURRENT_EXPR = %22currentExpr%22;%0A%09private static final String EXPECTED_EXPR = %22expectedExpr%22;%0A%09private static final String EXPR = %22expr%22;%0A
 %09private
@@ -1112,30 +1112,29 @@
 e(null, 
-%22expectedExpr%22
+EXPECTED_EXPR
 );%0A%09%09%09St
@@ -1175,37 +1175,36 @@
 Value(null, 
-%22currentExpr%22
+CURRENT_EXPR
 );%0A%09%09%09action
@@ -1350,29 +1350,20 @@
 e(null, 
-%22currentExpr%22
+EXPR
 );%0A%09%09%09ac

change null assert att