Search in sources :

Example 1 with MatchedRevision

use of com.thoughtworks.go.domain.materials.MatchedRevision in project gocd by gocd.

the class MaterialSearchController method search.

public String search(Request request, Response response) throws IOException {
    String pipelineName = request.queryParams("pipeline_name");
    String fingerprint = request.queryParams("fingerprint");
    String searchText = request.queryParamOrDefault("search_text", "");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MatchedRevision> matchedRevisions = materialService.searchRevisions(pipelineName, fingerprint, searchText, currentUsername(), result);
    if (result.isSuccessful()) {
        return writerForTopLevelArray(request, response, outputListWriter -> MatchedRevisionRepresenter.toJSON(outputListWriter, matchedRevisions));
    } else {
        return renderHTTPOperationResult(result, request, response);
    }
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) MatchedRevision(com.thoughtworks.go.domain.materials.MatchedRevision)

Example 2 with MatchedRevision

use of com.thoughtworks.go.domain.materials.MatchedRevision in project gocd by gocd.

the class MaterialSearchControllerDelegate method search.

public String search(Request request, Response response) throws IOException {
    String pipelineName = request.queryParams("pipeline_name");
    String fingerprint = request.queryParams("fingerprint");
    String searchText = request.queryParamOrDefault("search_text", "");
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    List<MatchedRevision> matchedRevisions = materialService.searchRevisions(pipelineName, fingerprint, searchText, currentUsername(), result);
    if (result.isSuccessful()) {
        return writerForTopLevelArray(request, response, outputListWriter -> MatchedRevisionRepresenter.toJSON(outputListWriter, matchedRevisions));
    } else {
        return renderHTTPOperationResult(result, request, response, localizer);
    }
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) MatchedRevision(com.thoughtworks.go.domain.materials.MatchedRevision)

Example 3 with MatchedRevision

use of com.thoughtworks.go.domain.materials.MatchedRevision in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldReturnMatchedRevisionForPluggableSCMMaterial.

@Test
void shouldReturnMatchedRevisionForPluggableSCMMaterial() {
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    Date timestamp = new Date();
    MatchedRevision matchedRevision = material.createMatchedRevision(new Modification("go", "comment", null, timestamp, "rev123"), "rev");
    assertThat(matchedRevision.getShortRevision()).isEqualTo("rev123");
    assertThat(matchedRevision.getLongRevision()).isEqualTo("rev123");
    assertThat(matchedRevision.getCheckinTime()).isEqualTo(timestamp);
    assertThat(matchedRevision.getUser()).isEqualTo("go");
    assertThat(matchedRevision.getComment()).isEqualTo("comment");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MatchedRevision(com.thoughtworks.go.domain.materials.MatchedRevision) SCM(com.thoughtworks.go.domain.scm.SCM) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 4 with MatchedRevision

use of com.thoughtworks.go.domain.materials.MatchedRevision in project gocd by gocd.

the class PackageMaterialTest method shouldReturnMatchedRevisionForPackageMaterial.

@Test
void shouldReturnMatchedRevisionForPackageMaterial() {
    PackageMaterial material = new PackageMaterial();
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    material.setPackageDefinition(PackageDefinitionMother.create("p-id", "package-name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository));
    Date timestamp = new Date();
    MatchedRevision matchedRevision = material.createMatchedRevision(new Modification("go", "comment", null, timestamp, "rev123"), "rev");
    assertThat(matchedRevision.getShortRevision()).isEqualTo("rev123");
    assertThat(matchedRevision.getLongRevision()).isEqualTo("rev123");
    assertThat(matchedRevision.getCheckinTime()).isEqualTo(timestamp);
    assertThat(matchedRevision.getUser()).isEqualTo("go");
    assertThat(matchedRevision.getComment()).isEqualTo("comment");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MatchedRevision(com.thoughtworks.go.domain.materials.MatchedRevision) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

MatchedRevision (com.thoughtworks.go.domain.materials.MatchedRevision)4 Modification (com.thoughtworks.go.domain.materials.Modification)2 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)2 Date (java.util.Date)2 Test (org.junit.jupiter.api.Test)2 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)1 SCM (com.thoughtworks.go.domain.scm.SCM)1