Search in sources :

Example 1 with SCM

use of com.thoughtworks.go.domain.scm.SCM in project gocd by gocd.

the class PluggableScmServiceTest method shouldCheckConnectionToSCM.

@Test
public void shouldCheckConnectionToSCM() {
    Configuration configuration = new Configuration(ConfigurationPropertyMother.create("KEY1"));
    SCM modifiedSCM = new SCM("scm-id", new PluginConfiguration(pluginId, "1"), configuration);
    Result expectedResult = new Result();
    expectedResult.withSuccessMessages(Arrays.asList("message"));
    when(scmExtension.checkConnectionToSCM(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class))).thenReturn(expectedResult);
    Result gotResult = pluggableScmService.checkConnection(modifiedSCM);
    verify(scmExtension).checkConnectionToSCM(eq(modifiedSCM.getPluginConfiguration().getId()), any(SCMPropertyConfiguration.class));
    assertSame(expectedResult, gotResult);
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) Result(com.thoughtworks.go.plugin.api.response.Result) ValidationResult(com.thoughtworks.go.plugin.api.response.validation.ValidationResult) Test(org.junit.Test)

Example 2 with SCM

use of com.thoughtworks.go.domain.scm.SCM in project gocd by gocd.

the class SCMControllerV4 method destroy.

public String destroy(Request request, Response response) throws IOException {
    final String materialName = request.params(MATERIAL_NAME);
    SCM scm = fetchEntityFromConfig(materialName);
    haltIfEntityIsDefinedRemotely(scm);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    pluggableScmService.deletePluggableSCM(currentUsername(), scm, result);
    return renderHTTPOperationResult(result, request, response);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 3 with SCM

use of com.thoughtworks.go.domain.scm.SCM in project gocd by gocd.

the class SCMControllerV4 method update.

public String update(Request request, Response response) {
    final String materialName = request.params(MATERIAL_NAME);
    final SCM existingSCM = fetchEntityFromConfig(materialName);
    final SCM scmFromRequest = buildEntityFromRequestBody(request);
    if (isRenameAttempt(existingSCM.getId(), scmFromRequest.getId()) || isRenameAttempt(existingSCM.getName(), scmFromRequest.getName())) {
        throw haltBecauseRenameOfEntityIsNotSupported(getEntityType().getEntityNameLowerCase());
    }
    haltIfEntityIsDefinedRemotely(existingSCM);
    if (isPutRequestStale(request, existingSCM)) {
        throw haltBecauseEtagDoesNotMatch(getEntityType().getEntityNameLowerCase(), existingSCM.getId());
    }
    final HttpLocalizedOperationResult operationResult = new HttpLocalizedOperationResult();
    pluggableScmService.updatePluggableScmMaterial(currentUsername(), scmFromRequest, operationResult, getIfMatch(request));
    return handleCreateOrUpdateResponse(request, response, scmFromRequest, operationResult);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) SCM(com.thoughtworks.go.domain.scm.SCM)

Example 4 with SCM

use of com.thoughtworks.go.domain.scm.SCM in project gocd by gocd.

the class SCMControllerV4 method getUsages.

public String getUsages(Request request, Response response) throws IOException {
    String materialName = request.params(MATERIAL_NAME);
    SCM scm = fetchEntityFromConfig(materialName);
    Map<String, List<Pair<PipelineConfig, PipelineConfigs>>> allUsages = goConfigService.getCurrentConfig().getGroups().getPluggableSCMMaterialUsageInPipelines();
    List<Pair<PipelineConfig, PipelineConfigs>> scmUsageInPipelines = allUsages.getOrDefault(scm.getId(), emptyList());
    return writerForTopLevelObject(request, response, outputWriter -> ScmUsageRepresenter.toJSON(outputWriter, materialName, scmUsageInPipelines));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) PipelineConfigs(com.thoughtworks.go.config.PipelineConfigs) SCM(com.thoughtworks.go.domain.scm.SCM) Pair(com.thoughtworks.go.util.Pair)

Example 5 with SCM

use of com.thoughtworks.go.domain.scm.SCM in project gocd by gocd.

the class UpdateSCMConfigCommand method isRequestFresh.

private boolean isRequestFresh(CruiseConfig cruiseConfig) {
    SCM existingSCM = findSCM(cruiseConfig);
    boolean freshRequest = entityHashingService.hashForEntity(existingSCM).equals(digest);
    if (!freshRequest) {
        result.stale(EntityType.SCM.staleConfig(globalScmConfig.getName()));
    }
    return freshRequest;
}
Also used : SCM(com.thoughtworks.go.domain.scm.SCM)

Aggregations

SCM (com.thoughtworks.go.domain.scm.SCM)120 Test (org.junit.jupiter.api.Test)87 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)29 SCMs (com.thoughtworks.go.domain.scm.SCMs)29 Configuration (com.thoughtworks.go.domain.config.Configuration)26 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)20 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)17 PluggableSCMMaterialConfig (com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig)14 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)13 Modification (com.thoughtworks.go.domain.materials.Modification)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)10 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)8 Date (java.util.Date)8 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)7 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)6 Modifications (com.thoughtworks.go.domain.materials.Modifications)5 Result (com.thoughtworks.go.plugin.api.response.Result)5 Username (com.thoughtworks.go.server.domain.Username)5 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)5 HashMap (java.util.HashMap)5