### Question:
BaseTask { public void validateVersion() { Matcher matcher = versionPattern.matcher(mySchemaVersion); if (!matcher.matches()) { throw new IllegalStateException("The version " + mySchemaVersion + " does not match the expected pattern " + MIGRATION_VERSION_PATTERN); } } protected  BaseTask(String theProductVersion, String theSchemaVersion); String getProductVersion(); String getSchemaVersion(); boolean isNoColumnShrink(); void setNoColumnShrink(boolean theNoColumnShrink); boolean isDryRun(); void setDryRun(boolean theDryRun); String getDescription(); @SuppressWarnings("unchecked") BaseTask setDescription(String theDescription); List<ExecutedStatement> getExecutedStatements(); int getChangesCount(); void executeSql(String theTableName, @Language("SQL") String theSql, Object... theArguments); DriverTypeEnum.ConnectionProperties getConnectionProperties(); BaseTask setConnectionProperties(DriverTypeEnum.ConnectionProperties theConnectionProperties); DriverTypeEnum getDriverType(); BaseTask setDriverType(DriverTypeEnum theDriverType); abstract void validate(); TransactionTemplate getTxTemplate(); JdbcTemplate newJdbcTemplate(); void execute(); void setFailureAllowed(boolean theFailureAllowed); String getFlywayVersion(); void validateVersion(); boolean isDoNothing(); BaseTask setDoNothing(boolean theDoNothing); @Override final int hashCode(); @Override final boolean equals(Object theObject); boolean initializedSchema(); static final String MIGRATION_VERSION_PATTERN; }### Answer:
@Test public void testValidateVersionCorrect() { DropTableTask task = new DropTableTask("1", "12345678.9"); task.validateVersion(); }
@Test public void testValidateVersionShort() { DropTableTask task = new DropTableTask("1", "123.4"); try { task.validateVersion(); fail(); } catch (IllegalStateException e) { assertEquals("The version 123.4 does not match the expected pattern " + BaseTask.MIGRATION_VERSION_PATTERN, e.getMessage()); } }
@Test public void testValidateVersionNoPeriod() { DropTableTask task = new DropTableTask("1", "123456789"); try { task.validateVersion(); fail(); } catch (IllegalStateException e) { assertEquals("The version 123456789 does not match the expected pattern " + BaseTask.MIGRATION_VERSION_PATTERN, e.getMessage()); } }
@Test public void testValidateVersionTooManyPeriods() { DropTableTask task = new DropTableTask("1", "12345678.9.1"); try { task.validateVersion(); fail(); } catch (IllegalStateException e) { assertEquals("The version 12345678.9.1 does not match the expected pattern " + BaseTask.MIGRATION_VERSION_PATTERN, e.getMessage()); } }