Search in sources :

Example 1 with SCMBuildView

use of net.nemerosa.ontrack.extension.scm.model.SCMBuildView in project ontrack by nemerosa.

the class SVNChangeLogServiceImpl method getSCMBuildView.

protected SCMBuildView<SVNHistory> getSCMBuildView(SVNRepository svnRepository, ID buildId) {
    // Gets the build view
    BuildView buildView = getBuildView(buildId);
    // Gets the history for the build
    SVNHistory history = getBuildSVNHistory(svnRepository, buildView.getBuild());
    // OK
    return new SCMBuildView<>(buildView, history);
}
Also used : SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView)

Example 2 with SCMBuildView

use of net.nemerosa.ontrack.extension.scm.model.SCMBuildView in project ontrack by nemerosa.

the class SVNChangeLogTest method branch_low.

@Test
public void branch_low() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/branches/10", "http://server/project/branches/10", 110000, Time.now()), new SVNReference("/project/trunk", "http://server/project/trunk", 100000, Time.now())));
    SCMBuildView<SVNHistory> scmBuildTo = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("5", "Build 5"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 90000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildTo);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(2, references.size());
    Iterator<SVNChangeLogReference> iterator = references.iterator();
    SVNChangeLogReference referenceBranch = iterator.next();
    {
        assertEquals("/project/branches/10", referenceBranch.getPath());
        assertEquals(0, referenceBranch.getStart());
        assertEquals(110000, referenceBranch.getEnd());
    }
    SVNChangeLogReference referenceTrunk = iterator.next();
    {
        assertEquals("/project/trunk", referenceTrunk.getPath());
        assertEquals(90000, referenceTrunk.getStart());
        assertEquals(100000, referenceTrunk.getEnd());
    }
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 3 with SCMBuildView

use of net.nemerosa.ontrack.extension.scm.model.SCMBuildView in project ontrack by nemerosa.

the class SVNChangeLogTest method simple.

@Test
public void simple() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 110000, Time.now())));
    SCMBuildView<SVNHistory> scmBuildTo = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("20", "Build 20"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 120000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildTo);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(1, references.size());
    SVNChangeLogReference reference = references.iterator().next();
    assertEquals("/project/trunk", reference.getPath());
    assertEquals(110000, reference.getStart());
    assertEquals(120000, reference.getEnd());
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 4 with SCMBuildView

use of net.nemerosa.ontrack.extension.scm.model.SCMBuildView in project ontrack by nemerosa.

the class SVNChangeLogTest method none.

@Test
public void none() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 100000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildFrom);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(1, references.size());
    assertTrue(references.iterator().next().isNone());
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 5 with SCMBuildView

use of net.nemerosa.ontrack.extension.scm.model.SCMBuildView in project ontrack by nemerosa.

the class GitChangeLogResourceDecoratorTest method gitChangeLogWithoutIssues.

@Test
public void gitChangeLogWithoutIssues() throws JsonProcessingException {
    Signature signature = Signature.of(LocalDateTime.of(2014, 12, 5, 21, 53), "user");
    Project project = Project.of(nd("P", "Project")).withId(ID.of(1)).withSignature(signature);
    Branch branch = Branch.of(project, nd("B", "Branch")).withId(ID.of(10)).withSignature(signature);
    List<BuildView> buildView = Stream.of(1, 2).map(it -> BuildView.of(Build.of(branch, nd(String.valueOf(it), "Build " + it), signature).withId(ID.of(it)))).collect(Collectors.toList());
    GitChangeLog changeLog = new GitChangeLog("uuid", project, new SCMBuildView<>(buildView.get(0), GitBuildInfo.INSTANCE), new SCMBuildView<>(buildView.get(1), GitBuildInfo.INSTANCE), false);
    when(gitService.getProjectConfiguration(project)).thenReturn(Optional.of(new BasicGitActualConfiguration(BasicGitConfiguration.empty().withName("MyConfig").withIssueServiceConfigurationIdentifier("mock:MyTest"), null)));
    ObjectNode signatureObject = object().with("time", "2014-12-05T21:53:00Z").with("user", object().with("name", "user").end()).end();
    assertResourceJson(mapper, object().with("project", object().with("id", 1).with("name", "P").with("description", "Project").with("disabled", false).with("signature", signatureObject).end()).with("scmBuildFrom", object().with("buildView", object().with("build", object().with("id", 1).with("name", "1").with("description", "Build 1").with("signature", signatureObject).with("branch", object().with("id", 10).with("name", "B").with("description", "Branch").with("disabled", false).with("type", "CLASSIC").with("signature", signatureObject).end()).end()).with("decorations", array().end()).with("promotionRuns", array().end()).with("validationStampRunViews", array().end()).end()).with("scm", object().with("placeholder", "").end()).end()).with("scmBuildTo", object().with("buildView", object().with("build", object().with("id", 2).with("name", "2").with("description", "Build 2").with("signature", signatureObject).with("branch", object().with("id", 10).with("name", "B").with("description", "Branch").with("disabled", false).with("type", "CLASSIC").with("signature", signatureObject).end()).end()).with("decorations", array().end()).with("promotionRuns", array().end()).with("validationStampRunViews", array().end()).end()).with("scm", object().with("placeholder", "").end()).end()).with("syncError", false).with("uuid", "uuid").with("_commits", "urn:test:net.nemerosa.ontrack.extension.git.GitController#changeLogCommits:uuid").with("_files", "urn:test:net.nemerosa.ontrack.extension.git.GitController#changeLogFiles:uuid").with("_changeLogFileFilters", "urn:test:net.nemerosa.ontrack.extension.scm.SCMController#getChangeLogFileFilters:1").with("_diff", "urn:test:net.nemerosa.ontrack.extension.git.GitController#diff:").with("_exportFormats", "urn:test:net.nemerosa.ontrack.extension.git.GitController#changeLogExportFormats:1").with("_exportIssues", "urn:test:net.nemerosa.ontrack.extension.git.GitController#changeLog:IssueChangeLogExportRequest%28format%3Dtext%2C+grouping%3D%2C+exclude%3D%2C+altGroup%3DOther%29").with("_page", "urn:test:#:extension/git/changelog?from=1&to=2").end(), changeLog);
}
Also used : MockIssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.support.MockIssueServiceConfiguration) LocalDateTime(java.time.LocalDateTime) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ResourceObjectMapper(net.nemerosa.ontrack.ui.resource.ResourceObjectMapper) BasicGitActualConfiguration(net.nemerosa.ontrack.extension.git.model.BasicGitActualConfiguration) NameDescription.nd(net.nemerosa.ontrack.model.structure.NameDescription.nd) JsonNode(com.fasterxml.jackson.databind.JsonNode) ResourceObjectMapperFactory(net.nemerosa.ontrack.ui.resource.ResourceObjectMapperFactory) BasicGitConfiguration(net.nemerosa.ontrack.extension.git.model.BasicGitConfiguration) Before(org.junit.Before) GitChangeLog(net.nemerosa.ontrack.extension.git.model.GitChangeLog) GitService(net.nemerosa.ontrack.extension.git.service.GitService) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) MockURIBuilder(net.nemerosa.ontrack.ui.controller.MockURIBuilder) DefaultResourceContext(net.nemerosa.ontrack.ui.resource.DefaultResourceContext) GitBuildInfo(net.nemerosa.ontrack.extension.git.model.GitBuildInfo) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) List(java.util.List) Stream(java.util.stream.Stream) net.nemerosa.ontrack.model.structure(net.nemerosa.ontrack.model.structure) Optional(java.util.Optional) JsonUtils.array(net.nemerosa.ontrack.json.JsonUtils.array) Assert.assertEquals(org.junit.Assert.assertEquals) JsonUtils.object(net.nemerosa.ontrack.json.JsonUtils.object) Mockito.mock(org.mockito.Mockito.mock) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) BasicGitActualConfiguration(net.nemerosa.ontrack.extension.git.model.BasicGitActualConfiguration) GitChangeLog(net.nemerosa.ontrack.extension.git.model.GitChangeLog) Test(org.junit.Test)

Aggregations

SCMBuildView (net.nemerosa.ontrack.extension.scm.model.SCMBuildView)6 Test (org.junit.Test)5 SVNRepository (net.nemerosa.ontrack.extension.svn.db.SVNRepository)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 LocalDateTime (java.time.LocalDateTime)2 List (java.util.List)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 Stream (java.util.stream.Stream)2 BasicGitActualConfiguration (net.nemerosa.ontrack.extension.git.model.BasicGitActualConfiguration)2 BasicGitConfiguration (net.nemerosa.ontrack.extension.git.model.BasicGitConfiguration)2 GitBuildInfo (net.nemerosa.ontrack.extension.git.model.GitBuildInfo)2 GitChangeLog (net.nemerosa.ontrack.extension.git.model.GitChangeLog)2 GitService (net.nemerosa.ontrack.extension.git.service.GitService)2 MockIssueServiceConfiguration (net.nemerosa.ontrack.extension.issues.support.MockIssueServiceConfiguration)2 JsonUtils.array (net.nemerosa.ontrack.json.JsonUtils.array)2 JsonUtils.object (net.nemerosa.ontrack.json.JsonUtils.object)2 SecurityService (net.nemerosa.ontrack.model.security.SecurityService)2