Skip to content

Commit 3826ba8

Browse files
authored
Merge pull request #863 from kusumotolab/for-jdk17
jdk17 に対応
2 parents 7f59a43 + 1f99de8 commit 3826ba8

File tree

10 files changed

+72
-45
lines changed

10 files changed

+72
-45
lines changed

.github/workflows/test-branches.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
java: ['11', '12', '13']
18+
java: ['11', '17']
1919
platform: [ubuntu-latest, windows-latest, macos-latest]
2020
steps:
2121
- name: Git checkout
@@ -32,8 +32,9 @@ jobs:
3232
build-cache-
3333
build-
3434
- name: Set up JDK
35-
uses: actions/setup-java@v1
35+
uses: actions/setup-java@v3
3636
with:
37+
distribution: 'temurin'
3738
java-version: ${{ matrix.java }}
3839
- name: Resolve dependencies
3940
if: steps.cache-dependencies.outputs.cache-hit != 'true'

build.gradle

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies {
5353
implementation 'ch.qos.logback:logback-classic:1.2.3'
5454
implementation 'com.github.albfernandez:juniversalchardet:2.3.2'
5555
implementation 'com.github.wumpz:diffutils:2.2'
56-
implementation 'com.google.code.gson:gson:2.8.5'
56+
implementation 'com.google.code.gson:gson:2.10'
5757
implementation 'com.google.guava:guava:26.0-jre'
5858
implementation 'commons-codec:commons-codec:1.11'
5959
implementation 'io.gsonfire:gson-fire:1.8.5'
@@ -67,11 +67,11 @@ dependencies {
6767
implementation 'org.jacoco:org.jacoco.core:0.8.1'
6868
implementation 'org.slf4j:slf4j-api:1.7.25'
6969

70-
testImplementation 'org.assertj:assertj-core:3.18.1'
71-
testImplementation 'org.mockito:mockito-core:2.+'
70+
testImplementation 'org.assertj:assertj-core:3.23.1'
71+
testImplementation 'org.mockito:mockito-core:4.10.0'
7272
testImplementation 'com.google.jimfs:jimfs:1.1'
7373
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
74-
testImplementation 'net.javacrumbs.json-unit:json-unit-assertj:2.25.0'
74+
testImplementation 'net.javacrumbs.json-unit:json-unit-assertj:2.36.0'
7575

7676
// Declare by "runtimeOnly" cuz hamcrest is necessary to execute junit-test dynamically,
7777
// but it doesn't seem to be loaded on compile task.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package jp.kusumotolab.kgenprog.output;
2+
3+
import java.lang.reflect.Type;
4+
import java.time.Duration;
5+
import com.google.gson.JsonElement;
6+
import com.google.gson.JsonPrimitive;
7+
import com.google.gson.JsonSerializationContext;
8+
import com.google.gson.JsonSerializer;
9+
10+
public class DurationSerializer implements JsonSerializer<Duration> {
11+
@Override
12+
public JsonElement serialize(
13+
final Duration duration, final Type typeOfSrc, final JsonSerializationContext context) {
14+
return new JsonPrimitive(duration.toString());
15+
}
16+
}

src/main/java/jp/kusumotolab/kgenprog/output/JSONExporter.java

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.io.IOException;
55
import java.nio.file.Files;
66
import java.nio.file.Path;
7+
import java.time.Duration;
78
import org.eclipse.jdt.core.dom.ASTNode;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
@@ -81,6 +82,7 @@ private Gson setupGson() {
8182
new CrossoverHistoricalElementSerializer())
8283
.registerTypeHierarchyAdapter(MutationHistoricalElement.class,
8384
new MutationHistoricalElementSerializer())
85+
.registerTypeHierarchyAdapter(Duration.class, new DurationSerializer())
8486
.create();
8587
}
8688
}

src/test/java/jp/kusumotolab/kgenprog/ga/crossover/CascadeCrossoverTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.mockito.ArgumentMatchers.any;
66
import static org.mockito.ArgumentMatchers.anyInt;
77
import static org.mockito.Mockito.when;
8+
import static org.mockito.Mockito.withSettings;
89
import java.nio.file.Paths;
910
import java.util.Arrays;
1011
import java.util.Collections;
@@ -413,7 +414,7 @@ public void testForDerivedParents() {
413414
public void testStopFirst01() {
414415

415416
// 生成するバリアントを制御するための疑似乱数
416-
final Random random = Mockito.mock(Random.class);
417+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
417418
when(random.nextBoolean()).thenReturn(true);
418419
when(random.nextInt(anyInt())).thenReturn(0);
419420

@@ -437,7 +438,7 @@ public void testStopFirst01() {
437438
public void testStopFirst02() {
438439

439440
// 生成するバリアントを制御するための疑似乱数
440-
final Random random = Mockito.mock(Random.class);
441+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
441442
when(random.nextBoolean()).thenReturn(true);
442443
when(random.nextInt(anyInt())).thenReturn(0);
443444

src/test/java/jp/kusumotolab/kgenprog/ga/crossover/RandomCrossoverTest.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.mockito.ArgumentMatchers.any;
55
import static org.mockito.ArgumentMatchers.anyInt;
66
import static org.mockito.Mockito.when;
7+
import static org.mockito.Mockito.withSettings;
78
import java.util.List;
89
import java.util.Random;
910
import org.junit.Test;
@@ -23,7 +24,7 @@ public class RandomCrossoverTest {
2324
public void testNumberOfGeneratedVariants() {
2425

2526
// 生成するバリアントを制御するための疑似乱数
26-
final Random random = Mockito.mock(Random.class);
27+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
2728
when(random.nextBoolean()).thenReturn(true);
2829
when(random.nextInt(anyInt())).thenReturn(0);
2930

@@ -49,7 +50,7 @@ public void testNumberOfGeneratedVariants() {
4950
public void testStopFirst01() {
5051

5152
// 生成するバリアントを制御するための疑似乱数
52-
final Random random = Mockito.mock(Random.class);
53+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
5354
when(random.nextBoolean()).thenReturn(true);
5455
when(random.nextInt(anyInt())).thenReturn(0);
5556

@@ -73,7 +74,7 @@ public void testStopFirst01() {
7374
public void testStopFirst02() {
7475

7576
// 生成するバリアントを制御するための疑似乱数
76-
final Random random = Mockito.mock(Random.class);
77+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
7778
when(random.nextBoolean()).thenReturn(true);
7879
when(random.nextInt(anyInt())).thenReturn(0);
7980

@@ -102,7 +103,7 @@ public void testStopFirst02() {
102103
public void testGeneratedVariants01() {
103104

104105
// 生成するバリアントを制御するための疑似乱数
105-
final Random random = Mockito.mock(Random.class);
106+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
106107
when(random.nextBoolean()).thenReturn(true);
107108
when(random.nextInt(anyInt())).thenReturn(0)
108109
.thenReturn(0)
@@ -132,7 +133,7 @@ public void testGeneratedVariants01() {
132133
public void testGeneratedVariants02() {
133134

134135
// 生成するバリアントを制御するための疑似乱数
135-
final Random random = Mockito.mock(Random.class);
136+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
136137
when(random.nextBoolean()).thenReturn(true);
137138
when(random.nextInt(anyInt())).thenReturn(1)
138139
.thenReturn(1)
@@ -162,7 +163,7 @@ public void testGeneratedVariants02() {
162163
public void testGeneratedVariants03() {
163164

164165
// 生成するバリアントを制御するための疑似乱数
165-
final Random random = Mockito.mock(Random.class);
166+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
166167
when(random.nextBoolean()).thenReturn(true);
167168
when(random.nextInt(anyInt())).thenReturn(0);
168169

@@ -190,7 +191,7 @@ public void testGeneratedVariants03() {
190191
public void testGeneratedVariants04() {
191192

192193
// 生成するバリアントを制御するための疑似乱数
193-
final Random random = Mockito.mock(Random.class);
194+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
194195
when(random.nextBoolean()).thenReturn(true);
195196
when(random.nextInt(anyInt())).thenReturn(2);
196197

@@ -218,7 +219,7 @@ public void testGeneratedVariants04() {
218219
public void testGeneratedVariants05() {
219220

220221
// 生成するバリアントを制御するための疑似乱数
221-
final Random random = Mockito.mock(Random.class);
222+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
222223
when(random.nextBoolean()).thenReturn(true);
223224
when(random.nextInt(anyInt())).thenReturn(0);
224225

@@ -246,7 +247,7 @@ public void testGeneratedVariants05() {
246247
public void testGeneratedVariants06() {
247248

248249
// 生成するバリアントを制御するための疑似乱数
249-
final Random random = Mockito.mock(Random.class);
250+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
250251
when(random.nextBoolean()).thenReturn(true);
251252
when(random.nextInt(anyInt())).thenReturn(2);
252253

@@ -274,7 +275,7 @@ public void testGeneratedVariants06() {
274275
public void testGeneratedVariants07() {
275276

276277
// 生成するバリアントを制御するための疑似乱数
277-
final Random random = Mockito.mock(Random.class);
278+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
278279
when(random.nextBoolean()).thenReturn(true);
279280
when(random.nextInt(anyInt())).thenReturn(0);
280281

@@ -302,7 +303,7 @@ public void testGeneratedVariants07() {
302303
public void testGeneratedVariants08() {
303304

304305
// 生成するバリアントを制御するための疑似乱数
305-
final Random random = Mockito.mock(Random.class);
306+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
306307
when(random.nextBoolean()).thenReturn(true);
307308
when(random.nextInt(anyInt())).thenReturn(1);
308309

@@ -330,7 +331,7 @@ public void testGeneratedVariants08() {
330331
public void testGeneratedVariants09() {
331332

332333
// 生成するバリアントを制御するための疑似乱数
333-
final Random random = Mockito.mock(Random.class);
334+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
334335
when(random.nextBoolean()).thenReturn(true);
335336
when(random.nextInt(anyInt())).thenReturn(1);
336337

src/test/java/jp/kusumotolab/kgenprog/ga/crossover/SinglePointCrossoverTest.java

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.mockito.ArgumentMatchers.any;
55
import static org.mockito.ArgumentMatchers.anyInt;
66
import static org.mockito.Mockito.when;
7+
import static org.mockito.Mockito.withSettings;
78
import java.util.List;
89
import java.util.Random;
910
import org.junit.Test;
@@ -23,7 +24,7 @@ public class SinglePointCrossoverTest {
2324
public void testNumberOfGeneratedVariants() {
2425

2526
// 生成するバリアントを制御するための疑似乱数
26-
final Random random = Mockito.mock(Random.class);
27+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
2728
when(random.nextBoolean()).thenReturn(true);
2829
when(random.nextInt(anyInt())).thenReturn(0);
2930

@@ -49,7 +50,7 @@ public void testNumberOfGeneratedVariants() {
4950
public void testStopFirst01() {
5051

5152
// 生成するバリアントを制御するための疑似乱数
52-
final Random random = Mockito.mock(Random.class);
53+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
5354
when(random.nextBoolean()).thenReturn(true);
5455
when(random.nextInt(anyInt())).thenReturn(0);
5556

@@ -73,7 +74,7 @@ public void testStopFirst01() {
7374
public void testStopFirst02() {
7475

7576
// 生成するバリアントを制御するための疑似乱数
76-
final Random random = Mockito.mock(Random.class);
77+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
7778
when(random.nextBoolean()).thenReturn(true);
7879
when(random.nextInt(anyInt())).thenReturn(0);
7980

@@ -102,7 +103,7 @@ public void testStopFirst02() {
102103
public void testGeneratedVariants01() {
103104

104105
// 生成するバリアントを制御するための疑似乱数
105-
final Random random = Mockito.mock(Random.class);
106+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
106107
when(random.nextBoolean()).thenReturn(true);
107108
when(random.nextInt(anyInt())).thenReturn(0) // variantAを選ぶための0
108109
.thenReturn(0) // variantBを選ぶための0
@@ -132,7 +133,7 @@ public void testGeneratedVariants01() {
132133
public void testGeneratedVariants02() {
133134

134135
// 生成するバリアントを制御するための疑似乱数
135-
final Random random = Mockito.mock(Random.class);
136+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
136137
when(random.nextBoolean()).thenReturn(false);
137138
when(random.nextInt(anyInt())).thenReturn(2) // variantCを選ぶための2
138139
.thenReturn(2) // variantDを選ぶための2
@@ -162,7 +163,7 @@ public void testGeneratedVariants02() {
162163
public void testGeneratedVariants03() {
163164

164165
// 生成するバリアントを制御するための疑似乱数
165-
final Random random = Mockito.mock(Random.class);
166+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
166167
when(random.nextBoolean()).thenReturn(true);
167168
when(random.nextInt(anyInt())).thenReturn(0);
168169

@@ -191,7 +192,7 @@ public void testGeneratedVariants03() {
191192
public void testGeneratedVariants04() {
192193

193194
// 生成するバリアントを制御するための疑似乱数
194-
final Random random = Mockito.mock(Random.class);
195+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
195196
when(random.nextBoolean()).thenReturn(false);
196197
when(random.nextInt(anyInt())).thenReturn(2);
197198

@@ -220,7 +221,7 @@ public void testGeneratedVariants04() {
220221
public void testGeneratedVariants05() {
221222

222223
// 生成するバリアントを制御するための疑似乱数
223-
final Random random = Mockito.mock(Random.class);
224+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
224225
when(random.nextBoolean()).thenReturn(true);
225226
when(random.nextInt(anyInt())).thenReturn(0);
226227

@@ -249,7 +250,7 @@ public void testGeneratedVariants05() {
249250
public void testGeneratedVariants06() {
250251

251252
// 生成するバリアントを制御するための疑似乱数
252-
final Random random = Mockito.mock(Random.class);
253+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
253254
when(random.nextBoolean()).thenReturn(false);
254255
when(random.nextInt(anyInt())).thenReturn(2);
255256

@@ -278,7 +279,7 @@ public void testGeneratedVariants06() {
278279
public void testGeneratedVariants07() {
279280

280281
// 生成するバリアントを制御するための疑似乱数
281-
final Random random = Mockito.mock(Random.class);
282+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
282283
when(random.nextBoolean()).thenReturn(true);
283284
when(random.nextInt(anyInt())).thenReturn(0);
284285

@@ -306,7 +307,7 @@ public void testGeneratedVariants07() {
306307
public void testGeneratedVariants08() {
307308

308309
// 生成するバリアントを制御するための疑似乱数
309-
final Random random = Mockito.mock(Random.class);
310+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
310311
when(random.nextBoolean()).thenReturn(true);
311312
when(random.nextInt(anyInt())).thenReturn(1);
312313

@@ -334,7 +335,7 @@ public void testGeneratedVariants08() {
334335
public void testGeneratedVariants09() {
335336

336337
// 生成するバリアントを制御するための疑似乱数
337-
final Random random = Mockito.mock(Random.class);
338+
final Random random = Mockito.mock(Random.class, withSettings().withoutAnnotations());
338339
when(random.nextBoolean()).thenReturn(true);
339340
when(random.nextInt(anyInt())).thenReturn(1);
340341

0 commit comments

Comments
 (0)