### Question:
DatabaseVendorUtil { public Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl) { for (DatabaseVendor databaseVendor : DatabaseVendor.values()) { if (jdbcUrl.startsWith(String.format("jdbc:%s:", databaseVendor.jdbcUrlDriverId()))) { return Optional.of(databaseVendor); } } return Optional.empty(); }  Optional<DatabaseVendor> getVendorByJdbcUrl(String jdbcUrl);  }### Answer:
@Test public void testValidUrls() { for (DatabaseVendor databaseVendor : TO_TEST) { String jdbcUrl = "jdbc:" + databaseVendor.jdbcUrlDriverId() + ":etc"; Optional<DatabaseVendor> foundVendor = underTest.getVendorByJdbcUrl(jdbcUrl); assertFalse(foundVendor.isEmpty()); assertEquals("Expected " + databaseVendor + " but got " + foundVendor.get(), databaseVendor, foundVendor.get()); } }
@Test public void testUnrecognizedUrl() { assertTrue(underTest.getVendorByJdbcUrl("unrecognized").isEmpty()); }