package com.alexrnl.commons.database;

import static org.junit.Assert.assertEquals;

import java.util.Map;

import org.junit.Test;

/**
 * Test suite for the {@link NoIdError} class.
 * @author Alex
 */
public class NoIdErrorTest {
	
	/**
	 * Dummy entity for test purposes.
	 * @author Alex
	 */
	private static class Dummy extends Entity {
		/** Serial version UID */
		private static final long	serialVersionUID	= 1L;
		
		@Override
		public String getEntityName () {
			return "Dummy";
		}
		
		@Override
		protected void setEntityColumns () {}
		
		@Override
		public Map<? extends Enum<?>, Column> getEntityColumns () {
			return null;
		}
		
		@Override
		public String getID () {
			return null;
		}
		
	}
	/** Exception with no entity information */
	private final NoIdError	unknownException = new NoIdError();
	/** Exception with the entity that generated the problem */
	private final NoIdError	dummyException = new NoIdError(Dummy.class);
	
	/**
	 * Test method for {@link com.alexrnl.commons.database.NoIdError#getEntityClass()}.
	 */
	@Test
	public void testGetEntityClass () {
		assertEquals(Entity.class, unknownException.getEntityClass());
		assertEquals(Dummy.class, dummyException.getEntityClass());
	}
	
	/**
	 * Test method for {@link java.lang.Throwable#getMessage()}.
	 */
	@Test
	public void testGetMessage () {
		assertEquals("Could not find id column in entity Entity", unknownException.getMessage());
		assertEquals("Could not find id column in entity Dummy", dummyException.getMessage());
	}
}

@@ -78,16 +78,42 @@
 quals;%0A%0A
+import java.util.EnumMap;%0A
 import j
@@ -449,129 +449,667 @@
 %09%0A%09%09
-@Override%0A%09%09public String getEntityName () %7B%0A%09%09%09return %22Dummy%22;%0A%09%09%7D%0A%09%09%0A%09%09@Override%0A%09%09protected void setEntityColumns () %7B
+/** Map with the columns */%0A%09%09private EnumMap%3CDummyColumn, Column%3E map;%0A%09%09%0A%09%09@Override%0A%09%09public String getEntityName () %7B%0A%09%09%09return %22Dummy%22;%0A%09%09%7D%0A%09%09%0A%09%09/** Dummy columns enumeration */%0A%09%09public enum DummyColumn implements EntityColumn %7B%0A%09%09%09/** The id column */%0A%09%09%09ID,%0A%09%09%09/** The name column */%0A%09%09%09NAME;%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public String getFieldName () %7B%0A%09%09%09%09return this.name();%0A%09%09%09%7D%0A%09%09%09%0A%09%09%7D%0A%09%09%0A%09%09@Override%0A%09%09protected void setEntityColumns () %7B%0A%09%09%09// No synchronization for the tests%0A%09%09%09map = new EnumMap%3C%3E(DummyColumn.class);%0A%09%09%09map.put(DummyColumn.ID, new Column(Integer.class, %22id%22, true));%0A%09%09%09map.put(DummyColumn.NAME, new Column(String.class, %22name%22));%0A%09%09
 %7D%0A%09%09
@@ -1150,16 +1150,37 @@
 s Enum%3C?
+ extends EntityColumn
 %3E, Colum
@@ -1206,36 +1206,35 @@
  () %7B%0A%09%09%09return 
-null
+map
 ;%0A%09%09%7D%0A%09%09%0A%09%09@Over

Update test so that the Dummy class check the doability of the map