package com.alexrnl.commons.translation;

import static org.junit.Assert.assertEquals;

import java.net.URISyntaxException;
import java.nio.file.Paths;

import org.junit.Before;
import org.junit.Test;

/**
 * Test suite for the {@link Translator} class.
 * @author Alex
 */
public class TranslatorTest {
	/** The translator to test */
	private Translator translator;
	
	/**
	 * Set up attributes.
	 * @throws URISyntaxException
	 *         if the path to the test translation file is not valid.
	 */
	@Before
	public void setUp () throws URISyntaxException {
		translator = new Translator(Paths.get(getClass().getResource("/locale.xml").toURI()));
	}
	
	/**
	 * Test method for {@link Translator#get(String)}.
	 */
	@Test
	public void testGetString () {
		assertEquals("aba.ldr", translator.get("aba.ldr"));
		assertEquals("The Name", translator.get("commons.test.name"));
		assertEquals("Hey, this has The Name, isn't that cool?", translator.get("commons.test.include"));
		assertEquals("Hey, this has The Name", translator.get("commons.test.includeEnd"));
		assertEquals("Hey, this has commons.test.missing", translator.get("commons.test.includeFake"));
	}
	
	/**
	 * Test method for {@link Translator#get(java.lang.String, Object[])}.
	 */
	@Test
	public void testGetStringObjectArray () {
		assertEquals("aba.ldr", translator.get("aba.ldr", (Object[]) null));
		assertEquals("The Name", translator.get("commons.test.name", (Object[]) null));
		assertEquals("The Name", translator.get("commons.test.name", new Object[0]));
		assertEquals("My parameter LDR", translator.get("commons.test.parameter", "LDR"));
		assertEquals("This LDR is really ABA!", translator.get("commons.test.parameters", "LDR", "ABA"));
		assertEquals("This LDR is really ABA!", translator.get("commons.test.parameters", "LDR", "ABA", "XXX"));
	}
	
}

@@ -1816,10 +1816,450 @@
 );%0A%09%7D%0A%09%0A
+%09/**%0A%09 * Test method for %7B@link Translator#get(ParametrableTranslation)%7D.%0A%09 */%0A%09@Test%0A%09public void testGetParametrableTranslation () %7B%0A%09%09assertEquals(%22This LDR is really ABA!%22, translator.get(new ParametrableTranslation() %7B%0A%09%09%09@Override%0A%09%09%09public String getTranslationKey () %7B%0A%09%09%09%09return %22commons.test.parameters%22;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public Object%5B%5D getParameters () %7B%0A%09%09%09%09return new String %5B%5D %7B%22LDR%22, %22ABA%22, %22XXX%22%7D;%0A%09%09%09%7D%0A%09%09%7D));%0A%09%7D%0A%09%0A
 %7D%0A

Add unit test for Translator.get(ParametrableTranslation)