1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-14 11:03:09 +02:00
sap-jenkins-library/test/groovy/com/sap/piper/versioning/MavenArtifactVersioningTest.groovy

59 lines
2.0 KiB
Groovy
Raw Normal View History

package com.sap.piper.versioning
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
2018-05-30 12:58:52 +02:00
import util.BasePiperTest
import util.JenkinsReadMavenPomRule
import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.Rules
import static org.junit.Assert.assertEquals
2018-05-30 12:58:52 +02:00
class MavenArtifactVersioningTest extends BasePiperTest{
Map dockerParameters
def commonPipelineEnvironment
MavenArtifactVersioning av
2019-01-22 10:19:28 +02:00
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
@Rule
2018-05-30 12:58:52 +02:00
public RuleChain ruleChain = Rules
.getCommonRules(this)
.around(new JenkinsReadYamlRule(this))
2019-01-22 10:19:28 +02:00
.around(shellRule)
.around(new JenkinsReadMavenPomRule(this, 'test/resources/versioning/MavenArtifactVersioning'))
@Before
void init() {
dockerParameters = [:]
helper.registerAllowedMethod("dockerExecute", [Map.class, Closure.class],
{ parameters, closure ->
dockerParameters = parameters
closure()
})
}
@Test
void testVersioning() {
2018-05-30 12:58:52 +02:00
av = new MavenArtifactVersioning(nullScript, [filePath: 'pom.xml'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
2019-01-22 10:19:28 +02:00
assertEquals('mvn --file \'pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101 -DgenerateBackupPoms=false', shellRule.shell[0])
}
@Test
void testVersioningCustomFilePathSnapshot() {
2018-05-30 12:58:52 +02:00
av = new MavenArtifactVersioning(nullScript, [filePath: 'snapshot/pom.xml'])
assertEquals('1.2.3', av.getVersion())
av.setVersion('1.2.3-20180101')
2019-01-22 10:19:28 +02:00
assertEquals('mvn --file \'snapshot/pom.xml\' --batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn versions:set -DnewVersion=1.2.3-20180101 -DgenerateBackupPoms=false', shellRule.shell[0])
}
}