当前位置: 首页>>代码示例>>Java>>正文


Java Result类代码示例

本文整理汇总了Java中com.thoughtworks.go.plugin.api.response.Result的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Result类属于com.thoughtworks.go.plugin.api.response包,在下文中一共展示了Result类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkConnectionToRepository

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
public Result checkConnectionToRepository(RepositoryConfiguration repoConfigs) {
    Result response = new Result();
    NpmRepoConfig npmRepoConfig = new NpmRepoConfig(repoConfigs);
    RepoUrl repoUrl = npmRepoConfig.getRepoUrl();
    if (repoUrl.isHttp()) {
        try {
            repoUrl.checkConnection(((HttpRepoURL) repoUrl).getUrlStrWithTrailingSlash());
        } catch (Exception e) {
            response.withErrorMessages(e.getMessage());
        }
    } else {
        repoUrl.checkConnection();
    }
    LOGGER.info(response.getMessagesForDisplay());
    return response;
}
 
开发者ID:varchev,项目名称:go-npm-poller,代码行数:18,代码来源:NpmPoller.java

示例2: checkConnectionToRepository

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
/**
 * Check the validation of the fields and then check the real connection
 *
 * @param repositoryConfiguration
 * @return
 */
@Override
public Result checkConnectionToRepository(
        final RepositoryConfiguration repositoryConfiguration) {

    Result result = this.validateRepository(repositoryConfiguration);
    if (!result.isSuccessful()) {
        return result;
    }

    DockerRegistry instance = DockerRegistry.getInstance(repositoryConfiguration);

    try {
        instance.checkConnection();
        result = new Result().withSuccessMessages(String.format("Successfully connected to %s", instance.getUrl()));
    } catch (Exception e) {
        LOG.warn(String.format("Check connection for %s failed with exception - %s", instance.getUrl(), e));
        result = new Result().withErrorMessages(String.format("Check connection failed for %s", instance.getUrl()));
    }

    return result;
}
 
开发者ID:decoomanj,项目名称:gocd-docker-material-poller,代码行数:28,代码来源:DockerMaterialPoller.java

示例3: checkConnectionToPackage

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
/**
 * Check if the package is valid.
 *
 * @param packageConfiguration
 * @param repositoryConfiguration
 * @return
 */
@Override
public Result checkConnectionToPackage(
        final PackageConfiguration packageConfiguration, 
        final RepositoryConfiguration repositoryConfiguration) {
    
    Result checkConnectionResult = this.checkConnectionToRepository(repositoryConfiguration);
    if (!checkConnectionResult.isSuccessful()) {
        return checkConnectionResult;
    }

    try {
        Result packageConfigurationValidationResult = packageValidation(packageConfiguration, repositoryConfiguration);
        if (!packageConfigurationValidationResult.isSuccessful()) {
            return packageConfigurationValidationResult;
        }

        PackageRevision latestRevision = this.getLatestRevision(packageConfiguration, repositoryConfiguration);
        return new Result().withSuccessMessages(String.format("Found package '%s'.", latestRevision.getRevision()));
    } catch (Exception e) {
        String message = String.format("Could not find any package that matched '%s'.", packageConfiguration.get(Constants.REPOSITORY).getValue());
        LOG.warn(message);
        return new Result().withErrorMessages(message);
    }
}
 
开发者ID:decoomanj,项目名称:gocd-docker-material-poller,代码行数:32,代码来源:DockerMaterialPoller.java

示例4: checkConnectionToRepository

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
public Result checkConnectionToRepository(RepositoryConfiguration repoConfigs) {
    Result response = new Result();
    GenericArtifactoryRepoConfig genericArtifactoryRepoConfig = new GenericArtifactoryRepoConfig(repoConfigs);
    RepoUrl repoUrl = genericArtifactoryRepoConfig.getRepoUrl();
    if (repoUrl.isHttp()) {
        try {
            repoUrl.checkConnection(((HttpRepoURL) repoUrl).getUrlStrWithTrailingSlash());
        } catch (Exception e) {
            response.withErrorMessages(e.getMessage());
        }
    } else {
        repoUrl.checkConnection();
    }
    LOGGER.info(response.getMessagesForDisplay());
    return response;
}
 
开发者ID:varchev,项目名称:go-generic-artifactory-poller,代码行数:18,代码来源:GenericArtifactoryPoller.java

示例5: shouldPerformCheckConnectionOnPlugin

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Test
public void shouldPerformCheckConnectionOnPlugin() throws Exception {
    String pluginId = "yum";
    PackageRepository packageRepository = packageRepository(pluginId);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();

    PackageRepositoryService service = new PackageRepositoryService(pluginManager, packageRepositoryExtension, goConfigService, securityService, entityHashingService, localizer);

    ArgumentCaptor<RepositoryConfiguration> argumentCaptor = ArgumentCaptor.forClass(RepositoryConfiguration.class);
    when(packageRepositoryExtension.checkConnectionToRepository(eq(pluginId), argumentCaptor.capture())).thenReturn(new Result().withSuccessMessages("Accessed Repo File!!!"));

    service.checkConnection(packageRepository, result);

    RepositoryConfiguration packageConfigurations = argumentCaptor.getValue();
    PackageMaterialTestHelper.assertPackageConfiguration(packageConfigurations.list(), packageRepository.getConfiguration());
    assertThat(result.isSuccessful(), is(true));
    when(localizer.localize("CONNECTION_OK", "Accessed Repo File!!!")).thenReturn("success_msg");
    assertThat(result.message(localizer), is("success_msg"));
    verify(packageRepositoryExtension).checkConnectionToRepository(eq(pluginId),any(RepositoryConfiguration.class));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:PackageRepositoryServiceTest.java

示例6: shouldPopulateErrorsForCheckConnectionOnPlugin

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Test
public void shouldPopulateErrorsForCheckConnectionOnPlugin() throws Exception {
    String pluginId = "yum";
    PackageRepository packageRepository = packageRepository(pluginId);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    PackageRepositoryService service = new PackageRepositoryService(pluginManager, packageRepositoryExtension, goConfigService, securityService, entityHashingService, localizer);

    ArgumentCaptor<RepositoryConfiguration> argumentCaptor = ArgumentCaptor.forClass(RepositoryConfiguration.class);

    when(packageRepositoryExtension.checkConnectionToRepository(eq(pluginId),argumentCaptor.capture())).thenReturn(new Result().withErrorMessages("Repo invalid!!", "Could not connect"));
    service.checkConnection(packageRepository, result);

    RepositoryConfiguration packageConfigurations = argumentCaptor.getValue();
    PackageMaterialTestHelper.assertPackageConfiguration(packageConfigurations.list(), packageRepository.getConfiguration());
    assertThat(result.isSuccessful(), is(false));

    when(localizer.localize("CHECK_CONNECTION_FAILED", "package repository","Repo invalid!!\nCould not connect")).thenReturn("error_msg");
    assertThat(result.message(localizer), is("error_msg"));
    verify(packageRepositoryExtension).checkConnectionToRepository(eq(pluginId),any(RepositoryConfiguration.class));

}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:PackageRepositoryServiceTest.java

示例7: shouldNotifyInterestedPluginsCorrectly

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Test
public void shouldNotifyInterestedPluginsCorrectly() throws Exception {
    Result result = new Result();
    result.withSuccessMessages("success message");
    when(notificationPluginRegistry.getPluginsInterestedIn(PIPELINE_STATUS)).thenReturn(new LinkedHashSet<>(asList(PLUGIN_ID_1, PLUGIN_ID_2)));
    when(notificationPluginRegistry.getPluginsInterestedIn(STAGE_STATUS)).thenReturn(new LinkedHashSet<>(asList(PLUGIN_ID_3)));

    when(notificationExtension.notify(PLUGIN_ID_1, PIPELINE_STATUS, REQUEST_BODY)).thenReturn(result);
    when(notificationExtension.notify(PLUGIN_ID_2, PIPELINE_STATUS, REQUEST_BODY)).thenReturn(result);

    PluginNotificationService pluginNotificationService = new PluginNotificationService(notificationExtension, notificationPluginRegistry, serverHealthService);
    pluginNotificationService.notifyPlugins(new PluginNotificationMessage(PIPELINE_STATUS, REQUEST_BODY));

    verify(notificationExtension).notify(PLUGIN_ID_1, PIPELINE_STATUS, REQUEST_BODY);
    verify(notificationExtension).notify(PLUGIN_ID_2, PIPELINE_STATUS, REQUEST_BODY);
    verify(notificationExtension, never()).notify(PLUGIN_ID_3, PIPELINE_STATUS, REQUEST_BODY);
    verify(serverHealthService, times(2)).removeByScope(any(HealthStateScope.class));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:PluginNotificationServiceTest.java

示例8: shouldHandleErrorDuringPluginNotificationCorrectly

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Test
public void shouldHandleErrorDuringPluginNotificationCorrectly() throws Exception {
    Result result = new Result();
    result.withErrorMessages(asList(new String[]{"message 1", "message 2"}));

    when(notificationPluginRegistry.getPluginsInterestedIn(PIPELINE_STATUS)).thenReturn(new LinkedHashSet<>(asList(PLUGIN_ID_1)));

    when(notificationExtension.notify(PLUGIN_ID_1, PIPELINE_STATUS, REQUEST_BODY)).thenReturn(result);
    when(serverHealthService.update(serverHealthState.capture())).thenReturn(null);

    PluginNotificationService pluginNotificationService = new PluginNotificationService(notificationExtension, notificationPluginRegistry, serverHealthService);
    pluginNotificationService.notifyPlugins(new PluginNotificationMessage(PIPELINE_STATUS, REQUEST_BODY));

    verify(notificationExtension).notify(PLUGIN_ID_1, PIPELINE_STATUS, REQUEST_BODY);
    assertThat(serverHealthState.getValue().getMessage(), is("Notification update failed for plugin: plugin-id-1"));
    assertThat(serverHealthState.getValue().getDescription(), is("message 1, message 2"));
    verify(serverHealthService, never()).removeByScope(any(HealthStateScope.class));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:PluginNotificationServiceTest.java

示例9: checkConnection

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
public void checkConnection(final PackageDefinition packageDefinition, final LocalizedOperationResult result) {
    try {
        String pluginId = packageDefinition.getRepository().getPluginConfiguration().getId();


        Result checkConnectionResult = packageRepositoryExtension.checkConnectionToPackage(pluginId, buildPackageConfigurations(packageDefinition), buildRepositoryConfigurations(packageDefinition.getRepository()));
        String messages = checkConnectionResult.getMessagesForDisplay();
        if (!checkConnectionResult.isSuccessful()) {
            result.connectionError(LocalizedMessage.string("PACKAGE_CHECK_FAILED", messages));
            return;
        }
        result.setMessage(LocalizedMessage.string("PACKAGE_CHECK_OK", messages));
        return;
    } catch (Exception e) {
        result.internalServerError(LocalizedMessage.string("PACKAGE_CHECK_FAILED", e.getMessage()));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:PackageDefinitionService.java

示例10: checkConnectionToPackage

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
public Result checkConnectionToPackage(PackageConfiguration packageConfigurations, RepositoryConfiguration repositoryPackageConfigurations) {
    Result checkConnectionResult = checkConnectionToRepository(repositoryPackageConfigurations);
    if (!checkConnectionResult.isSuccessful()) {
        return checkConnectionResult;
    }
    try {
        Result packageConfigurationValidationResult = packageValidation(packageConfigurations, repositoryPackageConfigurations);
        if (!packageConfigurationValidationResult.isSuccessful()) {
            return packageConfigurationValidationResult;
        }
        PackageRevision latestRevision = getLatestRevision(packageConfigurations, repositoryPackageConfigurations);
        return new Result().withSuccessMessages(String.format("Found package '%s'.", latestRevision.getRevision()));
    } catch (Exception e) {
        LOGGER.warn(String.format("[Deb Repo Check Connection] Check connection to package failed with exception - %s", e));
        return new Result().withErrorMessages("Could not find any package that matched requirements.");
    }
}
 
开发者ID:gocd-contrib,项目名称:deb-repo-poller,代码行数:18,代码来源:DebRepositoryPoller.java

示例11: checkConnectionToPackage

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
public Result checkConnectionToPackage(PackageConfiguration packageConfiguration, RepositoryConfiguration repositoryConfiguration) {
    CloudFoundryClient client = getClient(repositoryConfiguration);

    Result result = new Result();

    final String appNamePrefix = packageConfiguration.get("APP_NAME").getValue();
        if (lookupAppNames(client, appNamePrefix).isEmpty()) {
            LOGGER.warn("No app found.");
            result = ExecutionResult.failure("No such app found in CloudFoundry.");
        }

    return result;
}
 
开发者ID:Sounie,项目名称:springer-gocd-cloudfoundry-plugin,代码行数:15,代码来源:CloudFoundryPoller.java

示例12: checkConnectionToPackage

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
public Result checkConnectionToPackage(PackageConfiguration packageConfigs, RepositoryConfiguration repoConfigs) {
    Result response = checkConnectionToRepository(repoConfigs);
    if (!response.isSuccessful()) {
        LOGGER.info(response.getMessagesForDisplay());
        return response;
    }
    PackageRevision packageRevision = getLatestRevision(packageConfigs, repoConfigs);
    response.withSuccessMessages("Found " + packageRevision.getRevision());
    return response;
}
 
开发者ID:varchev,项目名称:go-npm-poller,代码行数:12,代码来源:NpmPoller.java

示例13: checkConnectionToRepository

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
@EntryPoint
public Result checkConnectionToRepository(RepositoryConfiguration repositoryConfiguration) {
    Forge forge = forgeFactory.build(repositoryConfiguration);
    LOG.info("Checking connection to forge at %s", forge);

    try {
        forge.ping();
        return success();
    } catch (Forge.PingFailure pingFailure) {
        return error(pingFailure);
    }
}
 
开发者ID:drrb,项目名称:go-puppet-forge-poller,代码行数:14,代码来源:ForgePoller.java

示例14: checkConnectionToPackage

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Override
@EntryPoint
public Result checkConnectionToPackage(PackageConfiguration packageConfiguration, RepositoryConfiguration repositoryConfiguration) {
    ModuleSpec moduleSpec = moduleSpecFactory.build(packageConfiguration);
    Forge forge = forgeFactory.build(repositoryConfiguration);
    LOG.info("Checking connection to module %s in forge at %s", moduleSpec, forge);

    try {
        forge.ping(moduleSpec);
        return success("Found %s.", moduleSpec.getName());
    } catch (Forge.PingFailure pingFailure) {
        return error(pingFailure);
    }
}
 
开发者ID:drrb,项目名称:go-puppet-forge-poller,代码行数:15,代码来源:ForgePoller.java

示例15: shouldReturnFailureWhenForgeConnectionFails

import com.thoughtworks.go.plugin.api.response.Result; //导入依赖的package包/类
@Test
public void shouldReturnFailureWhenForgeConnectionFails() throws Exception {
    doThrow(new PingFailure("Connection refused")).when(forge).ping();

    Result result = poller.checkConnectionToRepository(repoConfig);

    assertThat(result.isSuccessful(), is(false));
    assertThat(result.getMessages(), hasItem(containsString("Connection refused")));
}
 
开发者ID:drrb,项目名称:go-puppet-forge-poller,代码行数:10,代码来源:ForgePollerTest.java


注:本文中的com.thoughtworks.go.plugin.api.response.Result类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。