Skip to content

Commit

Permalink
Merge pull request #1014 from cdk/Java21
Browse files Browse the repository at this point in the history
Java21
  • Loading branch information
johnmay committed Oct 31, 2023
2 parents 8f66145 + 53cec03 commit ab2a931
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 56 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 8, 11, 17]
java: [ 8, 11, 17, 21]
name: Java ${{ matrix.java }}

steps:
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'adopt'
distribution: 'temurin'
java-version: ${{ matrix.java }}
cache: maven
- name: Build with Maven
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
distribution: 'temurin'
java-version: 17
cache: maven
- name: Cache SonarCloud packages
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<version>3.1.2</version>
<configuration>
<!-- prevent the annoying ForkedBooter process from stealing
window focus on Mac OS -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.StreamSupport;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
Expand Down Expand Up @@ -290,98 +294,60 @@ void first() throws Exception {
@Test
@SuppressWarnings("unchecked")
void count() throws Exception {
Iterable<int[]> iterable = mock(Iterable.class);
Iterator<int[]> iterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true, true, true, true, true, false);
doCallRealMethod().when(iterator)
.forEachRemaining(ArgumentMatchers.any(Consumer.class));

Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable);
List<int[]> list = Arrays.asList(new int[0],
new int[0],
new int[0],
new int[0],
new int[0]);
Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), list);
assertThat(ms.count(), is(5));
}

@Test
@SuppressWarnings("unchecked")
void countUnique() throws Exception {
Iterable<int[]> iterable = mock(Iterable.class);
Iterator<int[]> iterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true, true, true, true, false);
doCallRealMethod().when(iterator)
.forEachRemaining(ArgumentMatchers.any(Consumer.class));

int[] p1 = {0, 1, 2};
int[] p2 = {0, 2, 1};
int[] p3 = {0, 3, 4};
int[] p4 = {0, 4, 3};

when(iterator.next()).thenReturn(p1, p2, p3, p4);

Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable);
List<int[]> list = Arrays.asList(p1, p2, p3, p4);
Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), list);
assertThat(ms.countUnique(), is(2));
}

@Test
@SuppressWarnings("unchecked")
void countUnique2() throws Exception {
Iterable<int[]> iterable = mock(Iterable.class);
Iterator<int[]> iterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true, true, true, true, false);
doCallRealMethod().when(iterator)
.forEachRemaining(ArgumentMatchers.any(Consumer.class));

int[] p1 = {0, 1};
int[] p2 = {0, 2};
int[] p3 = {0, 3};
int[] p4 = {0, 4};

when(iterator.next()).thenReturn(p1, p2, p3, p4);

Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable);
List<int[]> list = Arrays.asList(p1, p2, p3, p4);
Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), list);
assertThat(ms.countUnique(), is(4));
}

@Test
@SuppressWarnings("unchecked")
void countExclusive() throws Exception {
Iterable<int[]> iterable = mock(Iterable.class);
Iterator<int[]> iterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true, true, true, true, false);
doCallRealMethod().when(iterator)
.forEachRemaining(ArgumentMatchers.any(Consumer.class));

int[] p1 = {0, 1, 2};
int[] p2 = {0, 2, 1};
int[] p3 = {0, 3, 4};
int[] p4 = {0, 4, 3};

when(iterator.next()).thenReturn(p1, p2, p3, p4);

Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable);
List<int[]> list = Arrays.asList(p1, p2, p3, p4);
Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), list);
assertThat(ms.exclusiveAtoms().count(), is(1));
}

@Test
@SuppressWarnings("unchecked")
void countExclusive2() throws Exception {
Iterable<int[]> iterable = mock(Iterable.class);
Iterator<int[]> iterator = mock(Iterator.class);
when(iterable.iterator()).thenReturn(iterator);
when(iterator.hasNext()).thenReturn(true, true, true, true, false);
doCallRealMethod().when(iterator)
.forEachRemaining(ArgumentMatchers.any(Consumer.class));

int[] p1 = {0, 1, 2};
int[] p2 = {0, 2, 1};
int[] p3 = {5, 3, 4};
int[] p4 = {5, 4, 3};

when(iterator.next()).thenReturn(p1, p2, p3, p4);

Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), iterable);
List<int[]> list = Arrays.asList(p1, p2, p3, p4);
Mappings ms = new Mappings(mock(IAtomContainer.class), mock(IAtomContainer.class), list);
assertThat(ms.exclusiveAtoms().count(), is(2));
}

Expand Down

0 comments on commit ab2a931

Please sign in to comment.