### Question:
Setup extends AbstractTask { public String determineDbName(String uri, String serverId) throws MojoExecutionException { String dbName = String.format(SDKConstants.DB_NAME_TEMPLATE, serverId); if (!uri.contains("@DBNAME@")) { int dbNameStart = uri.lastIndexOf("/"); if (dbNameStart < 0) { throw new MojoExecutionException("The uri is in a wrong format: " + uri); } int dbNameEnd = uri.indexOf("?"); dbName = dbNameEnd < 0 ? uri.substring(dbNameStart + 1) : uri.substring(dbNameStart + 1, dbNameEnd); if (!dbName.matches("^[A-Za-z0-9_\\-]+$")) { throw new MojoExecutionException("The db name is in a wrong format (allowed alphanumeric, dash and underscore signs): " + dbName); } } return dbName; } Setup();  Setup(AbstractTask other); String setup(Server server, boolean isCreatePlatform, boolean isCopyDependencies, DistroProperties distroProperties); String determineDbName(String uri, String serverId); void executeTask(); static final String SETTING_UP_A_NEW_SERVER; static final String SETUP_SERVERS_PROMPT; static final String ENABLE_DEBUGGING_DEFAULT_MESSAGE; }### Answer:
@Test public void determineDbName_shouldReturnDefaultNameIfVariableWasUsed() throws MojoExecutionException { Setup setupPlatform = new Setup(); String dbName = setupPlatform.determineDbName("jdbc:mysql: assertThat(dbName, is(equalTo("openmrs-my_server"))); }
@Test public void determineDbName_shouldReturnNameFromUriWithParams() throws MojoExecutionException { Setup setupPlatform = new Setup(); String dbName = setupPlatform.determineDbName("jdbc:mysql: assertThat(dbName, is(equalTo("open"))); }
@Test public void determineDbName_shouldReturnNameFromUriWithoutParams() throws MojoExecutionException { Setup setupPlatform = new Setup(); String dbName = setupPlatform.determineDbName("jdbc:mysql: assertThat(dbName, is(equalTo("open"))); }
@Test public void determineDbName_shouldFailIfNoNameInUri() throws MojoExecutionException { Setup setupPlatform = new Setup(); expectedException.expectMessage("The db name is in a wrong format (allowed "); setupPlatform.determineDbName("jdbc:mysql: }