/*
 * Copyright 2012-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.boot.system;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Tests for {@link JavaVersion}.
 *
 * @author Stephane Nicoll
 */
class JavaVersionTests {

	@Test
	void getJavaVersionShouldBeAvailable() {
		assertThat(JavaVersion.getJavaVersion()).isNotNull();
	}

	@Test
	void compareToWhenComparingSmallerToGreaterShouldBeLessThanZero() {
		assertThat(JavaVersion.EIGHT.compareTo(JavaVersion.NINE)).isLessThan(0);
	}

	@Test
	void compareToWhenComparingGreaterToSmallerShouldBeGreaterThanZero() {
		assertThat(JavaVersion.NINE.compareTo(JavaVersion.EIGHT)).isGreaterThan(0);
	}

	@Test
	void compareToWhenComparingSameShouldBeZero() {
		assertThat(JavaVersion.EIGHT.compareTo(JavaVersion.EIGHT)).isEqualTo(0);
	}

	@Test
	void isEqualOrNewerThanWhenComparingSameShouldBeTrue() {
		assertThat(JavaVersion.EIGHT.isEqualOrNewerThan(JavaVersion.EIGHT)).isTrue();
	}

	@Test
	void isEqualOrNewerThanWhenSmallerToGreaterShouldBeFalse() {
		assertThat(JavaVersion.EIGHT.isEqualOrNewerThan(JavaVersion.NINE)).isFalse();
	}

	@Test
	void isEqualOrNewerThanWhenGreaterToSmallerShouldBeTrue() {
		assertThat(JavaVersion.NINE.isEqualOrNewerThan(JavaVersion.EIGHT)).isTrue();
	}

	@Test
	void isOlderThanThanWhenComparingSameShouldBeFalse() {
		assertThat(JavaVersion.EIGHT.isOlderThan(JavaVersion.EIGHT)).isFalse();
	}

	@Test
	void isOlderThanWhenSmallerToGreaterShouldBeTrue() {
		assertThat(JavaVersion.EIGHT.isOlderThan(JavaVersion.NINE)).isTrue();
	}

	@Test
	void isOlderThanWhenGreaterToSmallerShouldBeFalse() {
		assertThat(JavaVersion.NINE.isOlderThan(JavaVersion.EIGHT)).isFalse();
	}

}

@@ -692,16 +692,113 @@
 pi.Test;
+%0Aimport org.junit.jupiter.api.condition.EnabledOnJre;%0Aimport org.junit.jupiter.api.condition.JRE;
 %0A%0Aimport
@@ -2378,10 +2378,888 @@
 ();%0A%09%7D%0A%0A
+%09@Test%0A%09@EnabledOnJre(JRE.JAVA_8)%0A%09void currentJavaVersionEight() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.EIGHT);%0A%09%7D%0A%0A%09@Test%0A%09@EnabledOnJre(JRE.JAVA_9)%0A%09void currentJavaVersionNine() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.NINE);%0A%09%7D%0A%0A%09@Test%0A%09@EnabledOnJre(JRE.JAVA_10)%0A%09void currentJavaVersionTen() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TEN);%0A%09%7D%0A%0A%09@Test%0A%09@EnabledOnJre(JRE.JAVA_11)%0A%09void currentJavaVersionEleven() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.ELEVEN);%0A%09%7D%0A%0A%09@Test%0A%09@EnabledOnJre(JRE.JAVA_12)%0A%09void currentJavaVersionTwelve() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.TWELVE);%0A%09%7D%0A%0A%09@Test%0A%09@EnabledOnJre(JRE.JAVA_13)%0A%09void currentJavaVersionThirteen() %7B%0A%09%09assertThat(JavaVersion.getJavaVersion()).isEqualTo(JavaVersion.THIRTEEN);%0A%09%7D%0A%0A
 %7D%0A

Extend JavaVersion tests