Skip to content

Commit 6cd3b1c

Browse files
committed
update project to java 17 and update maven dependencies (junit 5)
1 parent be1ac67 commit 6cd3b1c

29 files changed

+277
-304
lines changed

pom.xml

Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,17 @@
99

1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
12-
<jersey.version>2.34</jersey.version>
13-
<jackson.version>2.10.0</jackson.version>
14-
<lombok.version>1.18.10</lombok.version>
12+
<jersey.version>2.43</jersey.version>
13+
<jackson.version>2.17.1</jackson.version>
14+
<lombok.version>1.18.32</lombok.version>
15+
<junit.version>5.10.2</junit.version>
1516
</properties>
1617

17-
<prerequisites>
18-
<maven>3.0.5</maven>
19-
</prerequisites>
20-
2118
<dependencies>
22-
<dependency>
23-
<groupId>javax.xml.bind</groupId>
24-
<artifactId>jaxb-api</artifactId>
25-
<version>2.3.1</version>
26-
</dependency>
2719
<dependency>
2820
<groupId>org.apache.commons</groupId>
2921
<artifactId>commons-lang3</artifactId>
30-
<version>3.9</version>
22+
<version>3.14.0</version>
3123
</dependency>
3224
<dependency>
3325
<groupId>org.apache.commons</groupId>
@@ -39,22 +31,7 @@
3931
<artifactId>lombok</artifactId>
4032
<version>${lombok.version}</version>
4133
</dependency>
42-
<dependency>
43-
<!-- https://github.com/mplushnikov/lombok-intellij-plugin/issues/656 -->
44-
<groupId>org.mapstruct</groupId>
45-
<artifactId>mapstruct-processor</artifactId>
46-
<version>1.3.1.Final</version>
47-
</dependency>
48-
<dependency>
49-
<groupId>org.glassfish.jersey.core</groupId>
50-
<artifactId>jersey-common</artifactId>
51-
<version>${jersey.version}</version>
52-
</dependency>
53-
<dependency>
54-
<groupId>org.glassfish.jersey.inject</groupId>
55-
<artifactId>jersey-hk2</artifactId>
56-
<version>${jersey.version}</version>
57-
</dependency>
34+
<!-- for Codewars rest api-->
5835
<dependency>
5936
<groupId>org.glassfish.jersey.core</groupId>
6037
<artifactId>jersey-client</artifactId>
@@ -65,11 +42,6 @@
6542
<artifactId>jersey-media-json-jackson</artifactId>
6643
<version>${jersey.version}</version>
6744
</dependency>
68-
<dependency>
69-
<groupId>com.fasterxml.jackson.datatype</groupId>
70-
<artifactId>jackson-datatype-jdk8</artifactId>
71-
<version>${jackson.version}</version>
72-
</dependency>
7345
<dependency>
7446
<groupId>com.fasterxml.jackson.datatype</groupId>
7547
<artifactId>jackson-datatype-jsr310</artifactId>
@@ -78,21 +50,21 @@
7850

7951
<!-- test dependencies -->
8052
<dependency>
81-
<groupId>junit</groupId>
82-
<artifactId>junit</artifactId>
83-
<version>4.13.1</version>
53+
<groupId>org.junit.jupiter</groupId>
54+
<artifactId>junit-jupiter-api</artifactId>
55+
<version>${junit.version}</version>
8456
<scope>test</scope>
8557
</dependency>
8658
<dependency>
8759
<groupId>org.assertj</groupId>
8860
<artifactId>assertj-core</artifactId>
89-
<version>3.13.2</version>
61+
<version>3.26.0</version>
9062
<scope>test</scope>
9163
</dependency>
9264
<dependency>
9365
<groupId>org.mockito</groupId>
9466
<artifactId>mockito-core</artifactId>
95-
<version>2.28.2</version>
67+
<version>5.12.0</version>
9668
<scope>test</scope>
9769
</dependency>
9870
</dependencies>
@@ -102,9 +74,10 @@
10274
<plugin>
10375
<groupId>org.apache.maven.plugins</groupId>
10476
<artifactId>maven-compiler-plugin</artifactId>
105-
<version>3.8.1</version>
77+
<version>3.13.0</version>
10678
<configuration>
107-
<release>11</release>
79+
<target>17</target>
80+
<release>17</release>
10881
<annotationProcessorPaths>
10982
<path>
11083
<groupId>org.projectlombok</groupId>
@@ -117,7 +90,7 @@
11790
<plugin>
11891
<groupId>org.codehaus.mojo</groupId>
11992
<artifactId>versions-maven-plugin</artifactId>
120-
<version>2.7</version>
93+
<version>2.16.2</version>
12194
<configuration>
12295
<generateBackupPoms>false</generateBackupPoms>
12396
</configuration>

src/main/java/com/codewars/chrisgw/cli/CodewarsCli.java renamed to src/main/java/com/codewars/chrisgw/CodewarsCli.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.codewars.chrisgw.cli;
1+
package com.codewars.chrisgw;
22

33
import com.codewars.chrisgw.restapi.CodeChallenge;
44
import com.codewars.chrisgw.restapi.CodeChallengeRank;
@@ -91,7 +91,7 @@ private static StringBuilder getUrlJavaDoc(CodeChallenge codeChallenge) {
9191

9292
private static String descriptionAsClassJavaDoc(CodeChallenge codeChallenge) {
9393
System.out.println(codeChallenge.getDescription());
94-
StringBuffer description = new StringBuffer(codeChallenge.getDescription().length());
94+
StringBuilder description = new StringBuilder(codeChallenge.getDescription().length());
9595
Pattern codeExamplePattern = Pattern.compile("``+(\\w+)\\s+(.+)``+\\s*", Pattern.DOTALL);
9696
Matcher codeExampleMatcher = codeExamplePattern.matcher(codeChallenge.getDescription());
9797
while (codeExampleMatcher.find()) {
@@ -116,7 +116,7 @@ private static String getCodeChallengeJavaFileName(CodeChallenge codeChallenge,
116116
static Pattern dashOrUnderscoreDelimiterPattern = Pattern.compile("[\\-_]+([a-zA-Z0-9])");
117117

118118
static String toCamelCase(String s) {
119-
StringBuffer sb = new StringBuffer(s.length());
119+
StringBuilder sb = new StringBuilder(s.length());
120120
Matcher matcher = dashOrUnderscoreDelimiterPattern.matcher(s);
121121
while (matcher.find()) {
122122
String followingUpperCaseLetter = matcher.group(1).toUpperCase();

src/main/java/com/codewars/chrisgw/restapi/CodewarsRestApi.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import com.fasterxml.jackson.databind.DeserializationFeature;
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import com.fasterxml.jackson.databind.SerializationFeature;
6-
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
7-
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
86

97
import javax.ws.rs.client.Client;
108
import javax.ws.rs.client.ClientBuilder;
@@ -23,8 +21,8 @@ public class CodewarsRestApi {
2321

2422
public static final String CODEWARS_API_URL = "https://www.codewars.com/api/v1/";
2523

26-
private Client client;
27-
private WebTarget codewarsRestApi;
24+
private final Client client;
25+
private final WebTarget codewarsRestApi;
2826

2927

3028
public CodewarsRestApi() {
@@ -72,9 +70,7 @@ public static class ObjectMapperContextResolver implements ContextResolver<Objec
7270
@Override
7371
public ObjectMapper getContext(Class<?> type) {
7472
ObjectMapper objectMapper = new ObjectMapper();
75-
objectMapper.registerModule(new Jdk8Module());
76-
objectMapper.registerModule(new JavaTimeModule());
77-
73+
objectMapper.findAndRegisterModules();
7874
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
7975
objectMapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
8076
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);

src/main/java/module-info.java

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
package com.codewars.chrisgw.algorithms.kyu_3;
22

3-
import org.junit.Test;
43

5-
import static org.junit.Assert.assertEquals;
4+
import org.junit.jupiter.api.Test;
65

6+
import static org.junit.jupiter.api.Assertions.assertTrue;
77

88
public class BattleshipFieldValidatorTest {
99

1010

1111
private static int[][] battleField = { //
12-
{ 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, //
13-
{ 1, 0, 1, 0, 0, 0, 0, 0, 1, 0 }, //
14-
{ 1, 0, 1, 0, 1, 1, 1, 0, 1, 0 }, //
15-
{ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, //
16-
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, //
17-
{ 0, 0, 0, 0, 1, 1, 1, 0, 0, 0 }, //
18-
{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, //
19-
{ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, //
20-
{ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 }, //
21-
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; //
12+
{1, 0, 0, 0, 0, 1, 1, 0, 0, 0}, //
13+
{1, 0, 1, 0, 0, 0, 0, 0, 1, 0}, //
14+
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0}, //
15+
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //
16+
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, //
17+
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0}, //
18+
{0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, //
19+
{0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, //
20+
{0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, //
21+
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}; //
2222

2323
@Test
2424
public void SampleTest() {
25-
assertEquals(true, BattleshipFieldValidator.fieldValidator(battleField));
25+
boolean validField = BattleshipFieldValidator.fieldValidator(battleField);
26+
assertTrue(validField);
2627
}
2728

2829
}

src/test/java/com/codewars/chrisgw/algorithms/kyu_3/BlainIsAPainTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.codewars.chrisgw.algorithms.kyu_3;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.assertArrayEquals;
6-
import static org.junit.Assert.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
6+
import static org.junit.jupiter.api.Assertions.assertEquals;
77

88

99
public class BlainIsAPainTest {
@@ -81,7 +81,7 @@ public void testTrickyQueues() {
8181
new int[] {} // 6
8282
};
8383
final int[] result = Dinglemouse.theLift(queues, 5);
84-
assertEquals(result.length, 9);
84+
assertEquals(9, result.length, "result length");
8585
}
8686

8787
@Test
@@ -96,7 +96,7 @@ public void testLiftFullUp() {
9696
new int[] {}, // 6
9797
};
9898
final int[] result = Dinglemouse.theLift(queues, 5);
99-
assertEquals(result.length, 5);
99+
assertEquals(5, result.length, "result length");
100100
}
101101

102102
@Test
@@ -111,7 +111,6 @@ public void testEmpty() {
111111
new int[] {}, // 6
112112
};
113113
final int[] result = Dinglemouse.theLift(queues, 5);
114-
assertEquals(result.length, 1);
114+
assertEquals(1, result.length, "result length");
115115
}
116-
117116
}

src/test/java/com/codewars/chrisgw/algorithms/kyu_3/MakeASpiralTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.codewars.chrisgw.algorithms.kyu_3;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.assertArrayEquals;
5+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
66

77

88
public class MakeASpiralTest {
@@ -59,5 +59,4 @@ public void test8() {
5959
}); //
6060
}
6161

62-
6362
}

src/test/java/com/codewars/chrisgw/algorithms/kyu_4/RangeExtractionTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.codewars.chrisgw.algorithms.kyu_4;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.*;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
66

77

88
public class RangeExtractionTest {

src/test/java/com/codewars/chrisgw/algorithms/kyu_4/SortablePokerHandsTest.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
package com.codewars.chrisgw.algorithms.kyu_4;
22

3-
import org.junit.Ignore;
4-
import org.junit.Test;
3+
import org.junit.jupiter.api.Disabled;
4+
import org.junit.jupiter.api.Test;
55

6-
import java.util.ArrayList;
7-
import java.util.Collections;
8-
import java.util.Iterator;
9-
import java.util.Random;
6+
import java.util.*;
107

11-
import static org.junit.Assert.assertEquals;
8+
import static org.junit.jupiter.api.Assertions.assertEquals;
129

1310

1411
public class SortablePokerHandsTest {
1512

1613
@Test
17-
@Ignore
14+
@Disabled
1815
public void pokerHandSortTest() {
1916
// Arrange
20-
ArrayList<PokerHand> expected = new ArrayList<>();
17+
List<PokerHand> expected = new ArrayList<>();
2118
expected.add(new PokerHand("KS AS TS QS JS"));
2219
expected.add(new PokerHand("2H 3H 4H 5H 6H"));
2320
expected.add(new PokerHand("AS AD AC AH JD"));
@@ -35,20 +32,20 @@ public void pokerHandSortTest() {
3532
expected.add(new PokerHand("2S 3H 6H 7S 9C"));
3633

3734
Random random = new Random();
38-
ArrayList<PokerHand> actual = createRandomOrderedList(random, expected);
35+
List<PokerHand> actual = createRandomOrderedList(random, expected);
3936

4037
// Act
4138
Collections.sort(actual);
4239

4340
// Assert
44-
Iterator a = actual.iterator();
41+
Iterator<PokerHand> a = actual.iterator();
4542
for (PokerHand e : expected) {
4643
assertEquals(e, a.next());
4744
}
4845
}
4946

50-
private ArrayList<PokerHand> createRandomOrderedList(Random random, ArrayList<PokerHand> expected) {
51-
ArrayList<PokerHand> actual = new ArrayList<>();
47+
private List<PokerHand> createRandomOrderedList(Random random, List<PokerHand> expected) {
48+
List<PokerHand> actual = new ArrayList<>();
5249
for (PokerHand pokerHand : expected) {
5350
int j = random.nextInt(actual.size() + 1);
5451
actual.add(j, pokerHand);

src/test/java/com/codewars/chrisgw/algorithms/kyu_4/SudokuSolutionValidatorTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package com.codewars.chrisgw.algorithms.kyu_4;
22

3-
import org.junit.Test;
3+
import org.junit.jupiter.api.Test;
44

5-
import static org.junit.Assert.*;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertTrue;
67

78

89
public class SudokuSolutionValidatorTest {
@@ -21,10 +22,10 @@ public void exampleTest() {
2122
{ 2, 8, 7, 4, 1, 9, 6, 3, 5 }, //
2223
{ 3, 4, 5, 2, 8, 6, 1, 7, 9 } //
2324
};
24-
assertTrue(SudokuSolutionValidator.check(sudoku));
25+
assertTrue(SudokuSolutionValidator.check(sudoku), "valid sudoku");
2526

2627
sudoku[4][4] = 0;
27-
assertFalse(SudokuSolutionValidator.check(sudoku));
28+
assertFalse(SudokuSolutionValidator.check(sudoku), "invalid sudoku");
2829
}
2930

3031
}

0 commit comments

Comments
 (0)