### Question:
JavaAliasConverter { public static String toAlias(String javaType) { for (Map.Entry<String, JavaAliasType> type : map.entrySet()) { if (type.getValue().getTypes().contains(javaType)) { return type.getKey(); } } throw new IllegalArgumentException("Can not find alias for java type: " + javaType); }  static String toAlias(String javaType); static String toJavaType(String alias); static Map<String, JavaAliasType> map; }### Answer:
@Test public void shouldConvertJavaTypeToAlias() { Assert.assertEquals(toAlias(Boolean.class.getName()), BOOLEAN); Assert.assertEquals(toAlias(String.class.getName()), STRING); Assert.assertEquals(toAlias(Byte.class.getName()), BYTE); Assert.assertEquals(toAlias(Short.class.getName()), SHORT); Assert.assertEquals(toAlias(Integer.class.getName()), INTEGER); Assert.assertEquals(toAlias(Long.class.getName()), LONG); Assert.assertEquals(toAlias(BigInteger.class.getName()), BIG_INTEGER); Assert.assertEquals(toAlias(Float.class.getName()), FLOAT); Assert.assertEquals(toAlias(Double.class.getName()), DOUBLE); Assert.assertEquals(toAlias(BigDecimal.class.getName()), BIG_DECIMAL); Assert.assertEquals(toAlias(java.util.Date.class.getName()), DATE); Assert.assertEquals(toAlias(java.sql.Date.class.getName()), DATE); Assert.assertEquals(toAlias(Time.class.getName()), TIME); Assert.assertEquals(toAlias(Timestamp.class.getName()), TIMESTAMP); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionForInvalidJavaType() { toAlias("invalidType"); }