package com.exedio.copernica;

import net.sourceforge.jwebunit.WebTestCase;

public class WebTest extends WebTestCase
{

	public WebTest(String name)
	{
		super(name);
	}

	String someNotNullString;
	String someNotNullInteger;
	String someBoolean;

	public void setUp() throws Exception
	{
		super.setUp();
		getTestContext().setBaseUrl("http://localhost:8080/copernicatest/");
		someNotNullString = "running100";
		someNotNullInteger = "107";
		someBoolean = "NULL";
	}
	
	private void assertItemForm()
	{
		assertFormElementEquals("someNotNullString", someNotNullString);
		assertFormElementEquals("someNotNullInteger", someNotNullInteger);
		assertFormElementEquals("someBoolean", someBoolean);
	}

	public void testSearch()
	{
		beginAt("copernica.jsp");
		assertTitleEquals("Copernica");
		assertLinkPresentWithText("de");

		clickLinkWithText("Attribute Item");
		assertTitleEquals("Attribute Item");
		assertTextPresent("Attribute Item");
		
		assertLinkPresentWithText("50");
		clickLinkWithText("50");
		assertTitleEquals("Attribute Item");
		assertLinkNotPresentWithText("50");

		clickLinkWithText("[X]");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullString", "running100changed"); someNotNullString = "running100changed";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullInteger", "1077"); someNotNullInteger = "1077";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someBoolean", "TRUE"); someBoolean = "TRUE";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someBoolean", "FALSE"); someBoolean = "FALSE";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();

		setFormElement("someNotNullString", "running100"); someNotNullString = "running100";
		setFormElement("someNotNullInteger", "107"); someNotNullInteger = "107";
		setFormElement("someBoolean", "NULL"); someBoolean = "NULL";
		submit("SAVE");
		assertTitleEquals("AttributeItem.103");
		assertItemForm();
	}
}

@@ -240,16 +240,45 @@
 Boolean;
+%0A%09boolean someNotNullBoolean;
 %0A%0A%09publi
@@ -490,16 +490,45 @@
 %22NULL%22;%0A
+%09%09someNotNullBoolean = true;%0A
 %09%7D%0A%09%0A%09pr
@@ -694,16 +694,16 @@
 teger);%0A
-
 %09%09assert
@@ -749,16 +749,149 @@
 olean);%0A
+%09%09if(someNotNullBoolean)%0A%09%09%09assertCheckboxSelected(%22someNotNullBoolean%22);%0A%09%09else%0A%09%09%09assertCheckboxNotSelected(%22someNotNullBoolean%22);%0A
 %09%7D%0A%0A%09pub
@@ -1986,32 +1986,182 @@
 ertItemForm();%0A%0A
+%09%09uncheckCheckbox(%22someNotNullBoolean%22); someNotNullBoolean = false;%0A%09%09submit(%22SAVE%22);%0A%09%09assertTitleEquals(%22AttributeItem.103%22);%0A%09%09assertItemForm();%0A%0A
 %09%09setFormElement
@@ -2369,16 +2369,89 @@
 %22NULL%22;%0A
+%09%09setFormElement(%22someNotNullBoolean%22, %22on%22); someNotNullBoolean = true;%0A
 %09%09submit

test someNotNullBoolean