package de.terrestris.shogun2.util.naming;

import static org.junit.Assert.assertEquals;

import org.hibernate.boot.model.naming.EntityNaming;
import org.junit.Test;

/**
 * @author Nils Bühner
 *
 */
public class ImplicitNamingStrategyShogun2Test {

	private final ImplicitNamingStrategyShogun2 namingStrategy = new ImplicitNamingStrategyShogun2();

	/**
	 * Tests whether the default plural form (with suffix "s") is being created.
	 */
	@Test
	public void testDefaultPluralForm() {
		String singularClassName = "Boat";
		String expectedPluralForm = "Boats";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "es") is being
	 * created, if the singular form ends with "s".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithS() {
		String singularClassName = "Bus";
		String expectedPluralForm = "Buses";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "es") is being
	 * created, if the singular form ends with "x".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithX() {
		String singularClassName = "Box";
		String expectedPluralForm = "Boxes";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "es") is being
	 * created, if the singular form ends with "z".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithZ() {
		String singularClassName = "Buzz";
		String expectedPluralForm = "Buzzes";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "es") is being
	 * created, if the singular form ends with "sh".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithSh() {
		String singularClassName = "Wish";
		String expectedPluralForm = "Wishes";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "es") is being
	 * created, if the singular form ends with "ch".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithCh() {
		String singularClassName = "Pitch";
		String expectedPluralForm = "Pitches";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Tests whether the correct plural form (with suffix "ies") is being
	 * created, if the singular form ends with "y".
	 */
	@Test
	public void testEntityNamePluralForm_SingularEndsWithY() {
		String singularClassName = "City";
		String expectedPluralForm = "Cities";

		assertCorrectPluralForm(singularClassName, expectedPluralForm);
	}

	/**
	 * Helper method to assert that the correct plural form is being generated.
	 *
	 * @param singularClassName
	 * @param expectedPluralForm
	 */
	private void assertCorrectPluralForm(String singularClassName, String expectedPluralForm) {
		EntityNaming entityName = new EntityNaming() {

			@Override
			public String getJpaEntityName() {
				return singularClassName;
			}

			@Override
			public String getEntityName() {
				return singularClassName;
			}

			@Override
			public String getClassName() {
				return singularClassName;
			}
		};

		String actualPluralForm = namingStrategy.transformEntityName(entityName);
		assertEquals(expectedPluralForm, actualPluralForm);
	}

}

@@ -2880,16 +2880,22 @@
 ralForm(
+final 
 String s

Make variable final (to hopefully fix build)