Search in sources :

Example 1 with BasicGitActualConfiguration

use of net.nemerosa.ontrack.extension.git.model.BasicGitActualConfiguration 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)

Example 2 with BasicGitActualConfiguration

use of net.nemerosa.ontrack.extension.git.model.BasicGitActualConfiguration in project ontrack by nemerosa.

the class GitChangeLogResourceDecoratorTest method gitChangeLogWithIssues.

@Test
public void gitChangeLogWithIssues() 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"), MockIssueServiceConfiguration.configuredIssueService("MyTest"))));
    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("_issues", "urn:test:net.nemerosa.ontrack.extension.git.GitController#changeLogIssues: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

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 SCMBuildView (net.nemerosa.ontrack.extension.scm.model.SCMBuildView)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 net.nemerosa.ontrack.model.structure (net.nemerosa.ontrack.model.structure)2 NameDescription.nd (net.nemerosa.ontrack.model.structure.NameDescription.nd)2