Merge pull request #26 from kemitix/jdk-9-compatible
Compile with Java 9 Compatibility
This commit is contained in:
commit
b4d42447dc
5 changed files with 28 additions and 12 deletions
|
@ -30,6 +30,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Java 9') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
||||||
|
sh 'mvn clean install'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test Results') {
|
stage('Test Results') {
|
||||||
|
|
1
pom.xml
1
pom.xml
|
@ -10,6 +10,7 @@
|
||||||
<version>5.1.0</version>
|
<version>5.1.0</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
<groupId>net.kemitix</groupId>
|
||||||
<artifactId>mon</artifactId>
|
<artifactId>mon</artifactId>
|
||||||
<version>0.6.0-SNAPSHOT</version>
|
<version>0.6.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
|
|
@ -118,17 +118,8 @@ public class Mon<T> implements Functor<T, Mon<?>> {
|
||||||
* @return true if they are the same
|
* @return true if they are the same
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("npathcomplexity")
|
|
||||||
public boolean equals(final Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) {
|
return this == o || o != null && getClass() == o.getClass() && value.equals(((Mon<?>) o).value);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (o == null || getClass() != o.getClass()) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Mon<?> mon = (Mon<?>) o;
|
|
||||||
|
|
||||||
return value.equals(mon.value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,6 +93,7 @@ public class MonTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public void factoryRequiresValidator() {
|
public void factoryRequiresValidator() {
|
||||||
assertThatNullPointerException().isThrownBy(
|
assertThatNullPointerException().isThrownBy(
|
||||||
() -> Mon.factory(null, Optional::of, Optional::empty))
|
() -> Mon.factory(null, Optional::of, Optional::empty))
|
||||||
|
@ -100,6 +101,7 @@ public class MonTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public void factoryRequiresOnValid() {
|
public void factoryRequiresOnValid() {
|
||||||
assertThatNullPointerException().isThrownBy(
|
assertThatNullPointerException().isThrownBy(
|
||||||
() -> Mon.factory(v -> true, null, Optional::empty))
|
() -> Mon.factory(v -> true, null, Optional::empty))
|
||||||
|
@ -107,12 +109,27 @@ public class MonTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
public void factoryRequiresOnInvalid() {
|
public void factoryRequiresOnInvalid() {
|
||||||
assertThatNullPointerException().isThrownBy(
|
assertThatNullPointerException().isThrownBy(
|
||||||
() -> Mon.factory(v -> true, Optional::of, null))
|
() -> Mon.factory(v -> true, Optional::of, null))
|
||||||
.withMessage("onInvalid");
|
.withMessage("onInvalid");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void factory() {
|
||||||
|
//given
|
||||||
|
final Function<Integer, Optional<?>> evenMonFactory =
|
||||||
|
Mon.factory((Integer v) -> v % 2 == 0, Optional::of, Optional::empty);
|
||||||
|
//when
|
||||||
|
final Optional<?> oddResult = evenMonFactory.apply(1);
|
||||||
|
final Optional<?> evenResult = evenMonFactory.apply(2);
|
||||||
|
//then
|
||||||
|
assertThat(oddResult).isEmpty();// because 1 % 2 != 0
|
||||||
|
assertThat(evenResult).isNotEmpty(); // because 2 % 2 == 0
|
||||||
|
evenResult.ifPresent(value -> assertThat(value).isEqualTo(Mon.of(2)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldGetInvalidResultWhenFactoryApplyWithNull() {
|
public void shouldGetInvalidResultWhenFactoryApplyWithNull() {
|
||||||
//given
|
//given
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class TypeAliasTest {
|
||||||
final String value = "value";
|
final String value = "value";
|
||||||
final AnAlias anAlias = AnAlias.of(value);
|
final AnAlias anAlias = AnAlias.of(value);
|
||||||
//then
|
//then
|
||||||
assertThat(anAlias.hashCode()).isEqualTo(value.hashCode());
|
assertThat(anAlias).hasSameHashCodeAs(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in a new issue