Search in sources :

Example 1 with VersionFormatException

use of com.thoughtworks.go.domain.exception.VersionFormatException in project gocd by gocd.

the class ServerVersionInfoBuilder method installedVersion.

private GoVersion installedVersion() {
    GoVersion version = null;
    String installedVersion = serverVersion.version();
    try {
        version = new GoVersion(installedVersion);
    } catch (VersionFormatException e) {
        LOGGER.error("[Go Update Check] Server Version: {} format is Invalid.", installedVersion);
    }
    return version;
}
Also used : VersionFormatException(com.thoughtworks.go.domain.exception.VersionFormatException) GoVersion(com.thoughtworks.go.domain.GoVersion)

Example 2 with VersionFormatException

use of com.thoughtworks.go.domain.exception.VersionFormatException in project gocd by gocd.

the class GoVersion method parse.

private void parse(String version) {
    Matcher matcher = matcherFor(version);
    if (matcher == null)
        throw new VersionFormatException(format("Invalid version format [%s]", version));
    this.major = parseInt(matcher.group(1));
    this.minor = parseInt(matcher.group(2));
    this.patches = parseInt(matcher.group(3));
    this.modifications = parseInt(matcher.group(4));
}
Also used : VersionFormatException(com.thoughtworks.go.domain.exception.VersionFormatException) Matcher(java.util.regex.Matcher)

Example 3 with VersionFormatException

use of com.thoughtworks.go.domain.exception.VersionFormatException in project gocd by gocd.

the class VersionInfoServiceTest method shouldAddErrorToResultIfVersionFormatIsInValid.

@Test
public void shouldAddErrorToResultIfVersionFormatIsInValid() {
    ServerVersionInfoManager versionInfoManager = mock(ServerVersionInfoManager.class);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    when(versionInfoManager.updateLatestVersion("16.1.0-123")).thenThrow(new VersionFormatException("fail"));
    new VersionInfoService(versionInfoManager).updateServerLatestVersion("16.1.0-123", result);
    assertFalse(result.isSuccessful());
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) VersionFormatException(com.thoughtworks.go.domain.exception.VersionFormatException) Test(org.junit.Test)

Aggregations

VersionFormatException (com.thoughtworks.go.domain.exception.VersionFormatException)3 GoVersion (com.thoughtworks.go.domain.GoVersion)1 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)1 Matcher (java.util.regex.Matcher)1 Test (org.junit.Test)1