@@ -34,6 +34,7 @@ public void testSnapshotDeveloperVersion() throws Exception {
3434 final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .snapshot );
3535
3636 assertThat (ProjectVersion .isDeveloperBuild ()).isTrue ();
37+ assertThat (ProjectVersion .isCIBuild ()).isFalse ();
3738 assertThat (version .getMajorVersion ()).isEqualTo (1 );
3839 assertThat (version .getMinorVersion ()).isEqualTo (2 );
3940 assertThat (version .getPatchVersion ()).isEqualTo (3 );
@@ -56,6 +57,30 @@ public void testSnapshotDeveloperVersion() throws Exception {
5657 final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .snapshot );
5758
5859 assertThat (ProjectVersion .isDeveloperBuild ()).isTrue ();
60+ assertThat (ProjectVersion .isCIBuild ()).isFalse ();
61+ assertThat (version .getMajorVersion ()).isEqualTo (1 );
62+ assertThat (version .getMinorVersion ()).isEqualTo (2 );
63+ assertThat (version .getPatchVersion ()).isEqualTo (3 );
64+ assertThat (version .getSemanticVersion ()).isEqualTo ("1.2.3-0" );
65+ assertThat (version .getCoreVersion ()).isEqualTo ("1.2.3" );
66+ assertThat (version .getBuildNumber ()).isEqualTo ("0" );
67+ assertThat (version .getBuildType ()).isEqualTo (BuildType .snapshot );
68+ assertThat (version .isReleaseBuild ()).isFalse ();
69+ assertThat (version .isSnapshotBuild ()).isTrue ();
70+ assertThat (version .getBuildDate ()).matches ("^\\ d{4}-\\ d{2}-\\ d{2}T\\ d{2}:\\ d{2}:\\ d{2}Z$" );
71+ assertThat (version .getBuildDateMillis ()).isGreaterThan (0L );
72+ assertThat (version .getBranch ()).isEqualTo ("unknown" );
73+ assertThat (version .getCommit ()).isEqualTo ("unknown" );
74+ assertThat (version .toString ()).isEqualTo ("1.2.3-0" );
75+ });
76+ withEnvironmentVariable ("CTHING_CI" , "false" )
77+ .and ("GIT_BRANCH" , "" )
78+ .and ("GIT_COMMIT" , " " )
79+ .execute (() -> {
80+ final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .snapshot );
81+
82+ assertThat (ProjectVersion .isDeveloperBuild ()).isTrue ();
83+ assertThat (ProjectVersion .isCIBuild ()).isFalse ();
5984 assertThat (version .getMajorVersion ()).isEqualTo (1 );
6085 assertThat (version .getMinorVersion ()).isEqualTo (2 );
6186 assertThat (version .getPatchVersion ()).isEqualTo (3 );
@@ -82,6 +107,30 @@ public void testSnapshotCIVersion() throws Exception {
82107 final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .snapshot );
83108
84109 assertThat (ProjectVersion .isDeveloperBuild ()).isFalse ();
110+ assertThat (ProjectVersion .isCIBuild ()).isTrue ();
111+ assertThat (version .getMajorVersion ()).isEqualTo (1 );
112+ assertThat (version .getMinorVersion ()).isEqualTo (2 );
113+ assertThat (version .getPatchVersion ()).isEqualTo (3 );
114+ assertThat (version .getSemanticVersion ()).matches ("1\\ .2\\ .3-\\ d{2,}" );
115+ assertThat (version .getCoreVersion ()).isEqualTo ("1.2.3" );
116+ assertThat (version .getBuildNumber ()).isNotEqualTo ("0" );
117+ assertThat (version .getBuildType ()).isEqualTo (BuildType .snapshot );
118+ assertThat (version .isReleaseBuild ()).isFalse ();
119+ assertThat (version .isSnapshotBuild ()).isTrue ();
120+ assertThat (version .getBuildDate ()).matches ("^\\ d{4}-\\ d{2}-\\ d{2}T\\ d{2}:\\ d{2}:\\ d{2}Z$" );
121+ assertThat (version .getBuildDateMillis ()).isGreaterThan (0L );
122+ assertThat (version .getBranch ()).isEqualTo ("master" );
123+ assertThat (version .getCommit ()).isEqualTo ("a5b7f46" );
124+ assertThat (version .toString ()).matches ("1\\ .2\\ .3-\\ d{2,}" );
125+ });
126+ withEnvironmentVariable ("CTHING_CI" , "TRUE" )
127+ .and ("GIT_BRANCH" , "master" )
128+ .and ("GIT_COMMIT" , "a5b7f46" )
129+ .execute (() -> {
130+ final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .snapshot );
131+
132+ assertThat (ProjectVersion .isDeveloperBuild ()).isFalse ();
133+ assertThat (ProjectVersion .isCIBuild ()).isTrue ();
85134 assertThat (version .getMajorVersion ()).isEqualTo (1 );
86135 assertThat (version .getMinorVersion ()).isEqualTo (2 );
87136 assertThat (version .getPatchVersion ()).isEqualTo (3 );
@@ -108,6 +157,7 @@ public void testReleaseDeveloperVersion() throws Exception {
108157 final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .release );
109158
110159 assertThat (ProjectVersion .isDeveloperBuild ()).isTrue ();
160+ assertThat (ProjectVersion .isCIBuild ()).isFalse ();
111161 assertThat (version .getMajorVersion ()).isEqualTo (1 );
112162 assertThat (version .getMinorVersion ()).isEqualTo (2 );
113163 assertThat (version .getPatchVersion ()).isEqualTo (3 );
@@ -134,6 +184,7 @@ public void testReleaseCIVersion() throws Exception {
134184 final ProjectVersion version = new ProjectVersion ("1.2.3" , BuildType .release );
135185
136186 assertThat (ProjectVersion .isDeveloperBuild ()).isFalse ();
187+ assertThat (ProjectVersion .isCIBuild ()).isTrue ();
137188 assertThat (version .getMajorVersion ()).isEqualTo (1 );
138189 assertThat (version .getMinorVersion ()).isEqualTo (2 );
139190 assertThat (version .getPatchVersion ()).isEqualTo (3 );
@@ -200,7 +251,7 @@ public void testSerialize() throws Exception {
200251
201252 @ Test
202253 public void testOrder () throws Exception {
203- withEnvironmentVariable ("CTHING_CI" , "true " )
254+ withEnvironmentVariable ("CTHING_CI" , "True " )
204255 .and ("GIT_BRANCH" , "master" )
205256 .and ("GIT_COMMIT" , "a5b7f46" )
206257 .execute (() -> {
0 commit comments