package eu.ydp.empiria.player.client.module.object;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.runners.MockitoJUnitRunner;

import com.google.gwt.xml.client.Element;

@RunWith(MockitoJUnitRunner.class)
public class ObjectElementReaderTest {

	@InjectMocks
	private ObjectElementReader testObj;

	@Test
	public void shouldReturnType() {
		// given
		final String expected = "elementType";
		Element element = MockElementFluentBuilder.newNode().withName("any").withAttribute("type", expected).build();

		// when
		String actual = testObj.getElementType(element);

		// then
		assertEquals(expected, actual);
	}

	@Test
	public void shouldReturnAudioType() {
		// given
		final String expected = "audio";
		Element element = MockElementFluentBuilder.newNode().withName("audioPlayer").withAttribute("type", "any").build();

		// when
		String actual = testObj.getElementType(element);

		// then
		assertEquals(expected, actual);

	}

	@Test
	public void shouldReturnNarrationTexts() {
		// given
		Element text1 = MockElementFluentBuilder.newText("foo").build();
		Element text2 = MockElementFluentBuilder.newText("bar").build();

		Element narrationText1 = MockElementFluentBuilder.newNode().withChildren(text1, text2).build();

		Element text3 = MockElementFluentBuilder.newText("baz").build();
		Element text4 = MockElementFluentBuilder.newText("qux").build();

		Element narrationText2 = MockElementFluentBuilder.newNode().withChildren(text3, text4).build();

		Element input = MockElementFluentBuilder.newNode().withChildrenTags("narrationScript", narrationText1, narrationText2).build();

		// when
		String actual = testObj.getNarrationText(input);

		// then
		assertEquals("foo bar baz qux ", actual);

	}
}

@@ -46,16 +46,101 @@
 bject;%0A%0A
+import static eu.ydp.empiria.player.client.module.object.MockElementFluentBuilder.*;%0A
 import s
@@ -590,33 +590,8 @@
 t = 
-MockElementFluentBuilder.
 newN
@@ -880,33 +880,8 @@
 t = 
-MockElementFluentBuilder.
 newN
@@ -1055,17 +1055,16 @@
 ctual);%0A
-%0A
 %09%7D%0A%0A%09@Te
@@ -1143,33 +1143,8 @@
 1 = 
-MockElementFluentBuilder.
 newT
@@ -1185,33 +1185,8 @@
 2 = 
-MockElementFluentBuilder.
 newT
@@ -1197,33 +1197,32 @@
 %22bar%22).build();%0A
-%0A
 %09%09Element narrat
@@ -1236,33 +1236,8 @@
 1 = 
-MockElementFluentBuilder.
 newN
@@ -1301,33 +1301,8 @@
 3 = 
-MockElementFluentBuilder.
 newT
@@ -1343,33 +1343,8 @@
 4 = 
-MockElementFluentBuilder.
 newT
@@ -1355,33 +1355,32 @@
 %22qux%22).build();%0A
-%0A
 %09%09Element narrat
@@ -1394,33 +1394,8 @@
 2 = 
-MockElementFluentBuilder.
 newN
@@ -1459,33 +1459,8 @@
 t = 
-MockElementFluentBuilder.
 newN
@@ -1659,14 +1659,13 @@
 ctual);%0A
-%0A
 %09%7D%0A%7D%0A

Introduce static import in test