package com.alexrnl.commons.arguments;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;

import java.io.PrintStream;

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

/**
 * Test suite for the {@link Arguments} class.
 * @author Alex
 */
public class ArgumentsTest {
	/** The arguments to test */
	private Arguments	arguments;
	/** The target for the parameters */
	private Target		target;
	
	/**
	 * A class representing the target for the argument parsing.
	 * @author Alex
	 */
	private static class Target {
		/** If the feature is used. */
		@Param(names = {"-u","--used"}, description = "if the feature should be used", required = false)
		private boolean isUsed;
		
		/**
		 * Constructor #1.<br />
		 * Default constructor.
		 */
		private Target () {
			super();
		}
		
		/**
		 * Return the attribute isUsed.
		 * @return the attribute isUsed.
		 */
		public boolean isUsed () {
			return isUsed;
		}
		
		/**
		 * Set the attribute isUsed.
		 * @param isUsed the attribute isUsed.
		 */
		public void setUsed (final boolean isUsed) {
			this.isUsed = isUsed;
		}
	}
	
	/**
	 * Set up test attributes.
	 */
	@Before
	public void setUp () {
		target = new Target();
		arguments = new Arguments("manLau", target);
	}
	
	/**
	 * Test method for {@link Arguments#parse(String[])}.
	 */
	@Test
	public void testParseStringArray () {
		fail("Not yet implemented"); // TODO
	}
	
	/**
	 * Test method for {@link Arguments#parse(Iterable)}.
	 */
	@Test
	public void testParseIterableOfString () {
		fail("Not yet implemented"); // TODO
	}
	
	/**
	 * Test method for {@link Arguments#usage(PrintStream)}.
	 */
	@Test
	public void testUsagePrintStream () {
		final PrintStream out = mock(PrintStream.class);
		arguments.usage(out);
		verify(out).println(anyObject());
	}
	
	/**
	 * Test method for {@link Arguments#usage()}.
	 */
	@Test
	public void testUsage () {
		arguments.usage();
	}
	
	/**
	 * Test method for {@link Arguments#toString()}.
	 */
	@Test
	public void testToString () {
		assertEquals("manLau usage as follow:\n" +
				"\t[  -u, --used\t\t\t\tif the feature should be used  ]",
				arguments.toString());
	}
}

@@ -699,13 +699,12 @@
 used
-.
  */%0A
+
 %09%09@P
@@ -824,16 +824,146 @@
 isUsed;%0A
+%09%09/** The name to use */%0A%09%09@Param(names = %7B%22-n%22%7D, description = %22the name of the object%22, required = true)%0A%09%09private String%09name;%0A
 %09%09%0A%09%09/**
@@ -1357,16 +1357,291 @@
 sed;%0A%09%09%7D
+%0A%0A%09%09/**%0A%09%09 * Return the attribute name.%0A%09%09 * @return the attribute name.%0A%09%09 */%0A%09%09public String getName () %7B%0A%09%09%09return name;%0A%09%09%7D%0A%0A%09%09/**%0A%09%09 * Set the attribute name.%0A%09%09 * @param name the attribute name.%0A%09%09 */%0A%09%09public void setName (final String name) %7B%0A%09%09%09this.name = name;%0A%09%09%7D
 %0A%09%7D%0A%09%0A%09/
@@ -2547,16 +2547,16 @@
 ng () %7B%0A
-
 %09%09assert
@@ -2592,16 +2592,64 @@
 w:%5Cn%22 +%0A
+%09%09%09%09%22%5Ct   -n%5Ct%5Ct%5Ct%5Ctthe name of the object%5Cn%22 +%0A
 %09%09%09%09%22%5Ct%5B

Add a required parameter for the tests of Arguments