aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/CompileVersionMojoTest.java
blob: ebb91934470422ab877073fd8b08f7a38dbbfb40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package ai.vespa.hosted.plugin;

import org.junit.jupiter.api.Test;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.OptionalInt;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
 * @author mpolden
 */
class CompileVersionMojoTest {

    @Test
    public void allow_major() {
        assertMajorVersion(OptionalInt.empty(), Paths.get("non-existent-deployment.xml"));
        assertMajorVersion(OptionalInt.empty(), Paths.get("src/test/resources/deployment.xml"));
        assertMajorVersion(OptionalInt.of(8), Paths.get("src/test/resources/deployment-with-major.xml"));
    }

    private void assertMajorVersion(OptionalInt expected, Path deploymentXml) {
        OptionalInt allowMajor = CompileVersionMojo.majorVersion(deploymentXml);
        assertEquals(expected, allowMajor);
    }

}