package com.admios.connector.watsonalchemylanguage.automation.functional;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.mule.tools.devkit.ctf.junit.AbstractTestCase;

import com.admios.connector.watsonalchemylanguage.WatsonAlchemyLanguageConnector;
import com.admios.connector.watsonalchemylanguage.handler.CommonHandler;

public class CommonHandlerTest extends
AbstractTestCase<WatsonAlchemyLanguageConnector>{

	public CommonHandlerTest() {
		super(WatsonAlchemyLanguageConnector.class);
	}

	@Before
	public void setup() {
		// TODO
	}

	@After
	public void tearDown() {
		// TODO
	}

	@Test
	public void verify() {
		java.lang.String expected = null;
		java.lang.String friend = null;
		assertEquals(getConnector().greet(friend), expected);
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void parameterInvalid(){
		
		CommonHandlerMock mock = new CommonHandlerMock();
		
		try{
			mock.addParam(null, "Invalid object");
			fail();
		} catch (IllegalArgumentException e){
			
		}
	}
	
	@Test(expected=IllegalArgumentException.class)
	public void parameterEmpty(){
		
		CommonHandlerMock mock = new CommonHandlerMock();
		
		try{
			mock.addParam("", "Invalid object");
			fail();
		} catch (IllegalArgumentException e){
			
		}
	}
	
	@Test
	public void parameterWithNullValue(){
		CommonHandlerMock mock = new CommonHandlerMock();
		assertEquals(1,mock.parametersSize().intValue());
		mock.addParam("maxTime", null);
		assertEquals(1,mock.parametersSize().intValue());
	}
}

final class CommonHandlerMock extends CommonHandler{
	
	public CommonHandlerMock(){
		super(null, "Test", "object");
	}
	
	@Override
	public Object execute(){
		// nothing to test here.
		return "";
	}
	
	@Override
	public CommonHandler addParam(String param, Object value){
		return super.addParam(param, value);
	}
	
}
@@ -172,701 +172,121 @@
 nit.
-After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mule.tools.devkit.ctf.junit.AbstractTestCase;%0A%0Aimport com.admios.connector.watsonalchemylanguage.WatsonAlchemyLanguageConnector;%0Aimport com.admios.connector.watsonalchemylanguage.handler.CommonHandler;%0A%0Apublic class CommonHandlerTest extends%0AAbstractTestCase%3CWatsonAlchemyLanguageConnector%3E%7B%0A%0A%09public CommonHandlerTest() %7B%0A%09%09super(WatsonAlchemyLanguageConnector.class);%0A%09%7D%0A%0A%09@Before%0A%09public void setup() %7B%0A%09%09// TODO%0A%09%7D%0A%0A%09@After%0A%09public void tearDown() %7B%0A%09%09// TODO%0A%09%7D%0A%0A%09@Test%0A%09public void verify() %7B%0A%09%09java.lang.String expected = null;%0A%09%09java.lang.String friend = null;%0A%09%09assertEquals(getConnector().greet(friend), expected);%0A%09%7D
+Test;%0A%0Aimport com.admios.connector.watsonalchemylanguage.handler.CommonHandler;%0A%0Apublic class CommonHandlerTest %7B
 %0A%09%0A%09
@@ -361,27 +361,24 @@
 rInvalid()%7B%0A
-%09%09%0A
 %09%09CommonHand
@@ -415,35 +415,24 @@
 erMock();%0A%09%09
-%0A%09%09try%7B%0A%09%09%09
 mock.addPara
@@ -456,33 +456,32 @@
 object%22);%0A%09%09
-%09
 fail();%0A
 %09%09%7D catch (I
@@ -472,56 +472,8 @@
 ();%0A
-%09%09%7D catch (IllegalArgumentException e)%7B%0A%09%09%09%0A%09%09%7D%0A
 %09%7D%0A%09
@@ -552,19 +552,16 @@
 mpty()%7B%0A
-%09%09%0A
 %09%09Common
@@ -610,19 +610,8 @@
 ;%0A%09%09
-%0A%09%09try%7B%0A%09%09%09
 mock
@@ -645,25 +645,24 @@
 ct%22);%0A%09%09
-%09
 fail();%0A
 %09%09%7D catc
@@ -657,56 +657,8 @@
 ();%0A
-%09%09%7D catch (IllegalArgumentException e)%7B%0A%09%09%09%0A%09%09%7D%0A
 %09%7D%0A%09

Refactor test, was not running properly.