### Question:
DatabaseProduct { public static DatabaseProduct toProduct(String productNameOrJDBCScheme) { DatabaseProduct product; if (matches(productNameOrJDBCScheme, ORACLE)) { product = ORACLE; } else if (matches(productNameOrJDBCScheme, DERBY)) { product = DERBY; } else if (matches(productNameOrJDBCScheme, HSQLDB)) { product = HSQLDB; } else if (matches(productNameOrJDBCScheme, H2)) { product = H2; } else if (productNameOrJDBCScheme.startsWith(DB2.getProductName()) || DB2.jdbcScheme.equalsIgnoreCase(productNameOrJDBCScheme)) { product = DB2; } else if (isMySQL(productNameOrJDBCScheme)) { product = MYSQL; } else if (matches(productNameOrJDBCScheme, POSTGRESQL)) { product = POSTGRESQL; } else if (matches(productNameOrJDBCScheme, MSSQL)) { product = MSSQL; } else { product = UNKNOWN; } return product; } private  DatabaseProduct(String productName, String jdbcScheme); String getProductName(); @Override boolean equals(Object object); static DatabaseProduct toProduct(String productNameOrJDBCScheme); @Override int hashCode(); @Override String toString(); static final DatabaseProduct ORACLE; static final DatabaseProduct DERBY; static final DatabaseProduct HSQLDB; static final DatabaseProduct DB2; static final DatabaseProduct MYSQL; static final DatabaseProduct POSTGRESQL; static final DatabaseProduct MSSQL; static final DatabaseProduct H2; static final DatabaseProduct UNKNOWN; }### Answer:
@Test void toProductEquality() { DatabaseProduct product = DatabaseProduct.toProduct("Oracle"); assertEquals(DatabaseProduct.ORACLE, product); assertSame(DatabaseProduct.ORACLE, product); product = DatabaseProduct.toProduct("oracle"); assertEquals(DatabaseProduct.ORACLE, product); assertSame(DatabaseProduct.ORACLE, product); product = DatabaseProduct.toProduct("MySQL"); assertEquals(DatabaseProduct.MYSQL, product); assertSame(DatabaseProduct.MYSQL, product); product = DatabaseProduct.toProduct("mysql"); assertEquals(DatabaseProduct.MYSQL, product); assertSame(DatabaseProduct.MYSQL, product); product = DatabaseProduct.toProduct("MariaDB"); assertEquals(DatabaseProduct.MYSQL, product); assertSame(DatabaseProduct.MYSQL, product); product = DatabaseProduct.toProduct("mariadb"); assertEquals(DatabaseProduct.MYSQL, product); assertSame(DatabaseProduct.MYSQL, product); product = DatabaseProduct.toProduct("Apache Derby"); assertEquals(DatabaseProduct.DERBY, product); assertSame(DatabaseProduct.DERBY, product); product = DatabaseProduct.toProduct("derby"); assertEquals(DatabaseProduct.DERBY, product); assertSame(DatabaseProduct.DERBY, product); product = DatabaseProduct.toProduct("HSQL Database Engine"); assertEquals(DatabaseProduct.HSQLDB, product); assertSame(DatabaseProduct.HSQLDB, product); product = DatabaseProduct.toProduct("hsqldb"); assertEquals(DatabaseProduct.HSQLDB, product); assertSame(DatabaseProduct.HSQLDB, product); product = DatabaseProduct.toProduct("DB2/LINUXX8664"); assertEquals(DatabaseProduct.DB2, product); assertSame(DatabaseProduct.DB2, product); product = DatabaseProduct.toProduct("db2"); assertEquals(DatabaseProduct.DB2, product); assertSame(DatabaseProduct.DB2, product); product = DatabaseProduct.toProduct("H2"); assertEquals(DatabaseProduct.H2, product); assertSame(DatabaseProduct.H2, product); product = DatabaseProduct.toProduct("h2"); assertEquals(DatabaseProduct.H2, product); assertSame(DatabaseProduct.H2, product); product = DatabaseProduct.toProduct("Unknown"); assertEquals(DatabaseProduct.UNKNOWN, product); assertSame(DatabaseProduct.UNKNOWN, product); product = DatabaseProduct.toProduct("unknown"); assertEquals(DatabaseProduct.UNKNOWN, product); assertSame(DatabaseProduct.UNKNOWN, product); }
@Test void toProductDifference() { DatabaseProduct product = DatabaseProduct.toProduct("Oracle"); assertTrue(product != DatabaseProduct.DERBY); assertNotSame(DatabaseProduct.DERBY, product); }
@Test void toProductUnknown() { DatabaseProduct product = DatabaseProduct.toProduct("whatever"); assertSame(DatabaseProduct.UNKNOWN, product); }