Skip to content

Commit ffe69df

Browse files
committed
refactor: replace deprecated FriendlyId with FriendlyIds in tests
1 parent 4627bd8 commit ffe69df

8 files changed

Lines changed: 25 additions & 26 deletions

File tree

friendly-id-jackson-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import org.junit.jupiter.api.Test;
66

7-
import com.devskiller.friendly_id.FriendlyId;
7+
import com.devskiller.friendly_id.FriendlyIds;
88

99
import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper;
1010
import static org.assertj.core.api.Assertions.assertThat;
@@ -16,13 +16,13 @@ void shouldSerializeFriendlyId() {
1616
UUID uuid = UUID.randomUUID();
1717
String json = mapper().writeValueAsString(uuid);
1818
System.out.println(json);
19-
assertThat(json).contains(FriendlyId.toFriendlyId(uuid));
19+
assertThat(json).contains(FriendlyIds.toFriendlyId(uuid));
2020
}
2121

2222
@Test
2323
void shouldDeserializeFriendlyId() {
2424
String friendlyId = "2YSfgVHnEYbYgfFKhEX3Sz";
2525
UUID uuid = mapper().readValue("\"" + friendlyId + "\"", UUID.class);
26-
assertThat(uuid).isEqualByComparingTo(FriendlyId.toUuid(friendlyId));
26+
assertThat(uuid).isEqualByComparingTo(FriendlyIds.toUuid(friendlyId));
2727
}
2828
}

friendly-id-jackson2-datatype/src/test/java/com/devskiller/friendly_id/spring/FieldWithoutFriendlyIdTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
77
import org.junit.jupiter.api.Test;
88

9-
import com.devskiller.friendly_id.FriendlyId;
9+
import com.devskiller.friendly_id.FriendlyIds;
1010

1111
import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper;
1212
import static org.assertj.core.api.Assertions.assertThat;

friendly-id-jackson2-datatype/src/test/java/com/devskiller/friendly_id/spring/FriendlyIdDeserializerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import org.junit.jupiter.api.Test;
66

7-
import com.devskiller.friendly_id.FriendlyId;
7+
import com.devskiller.friendly_id.FriendlyIds;
88

99
import static com.devskiller.friendly_id.spring.ObjectMapperConfiguration.mapper;
1010
import static org.assertj.core.api.Assertions.assertThat;
@@ -16,13 +16,13 @@ void shouldSerializeFriendlyId() throws Exception {
1616
UUID uuid = UUID.randomUUID();
1717
String json = mapper().writeValueAsString(uuid);
1818
System.out.println(json);
19-
assertThat(json).contains(FriendlyId.toFriendlyId(uuid));
19+
assertThat(json).contains(FriendlyIds.toFriendlyId(uuid));
2020
}
2121

2222
@Test
2323
void shouldDeserializeFriendlyId() throws Exception {
2424
String friendlyId = "2YSfgVHnEYbYgfFKhEX3Sz";
2525
UUID uuid = mapper().readValue("\"" + friendlyId + "\"", UUID.class);
26-
assertThat(uuid).isEqualByComparingTo(FriendlyId.toUuid(friendlyId));
26+
assertThat(uuid).isEqualByComparingTo(FriendlyIds.toUuid(friendlyId));
2727
}
2828
}

friendly-id-samples/friendly-id-spring-boot-customized/src/test/java/com/devskiller/friendly_id/sample/customized/ApplicationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
import org.springframework.test.context.bean.override.mockito.MockitoBean;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import com.devskiller.friendly_id.FriendlyId;
12+
import com.devskiller.friendly_id.FriendlyIds;
1313
import com.devskiller.friendly_id.spring.EnableFriendlyId;
1414

15-
import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
16-
import static com.devskiller.friendly_id.FriendlyId.toUuid;
15+
import static com.devskiller.friendly_id.FriendlyIds.toFriendlyId;
16+
import static com.devskiller.friendly_id.FriendlyIds.toUuid;
1717
import static org.hamcrest.CoreMatchers.is;
1818
import static org.mockito.ArgumentMatchers.any;
1919
import static org.mockito.ArgumentMatchers.eq;

friendly-id-samples/friendly-id-spring-boot-simple/src/test/java/com/devskiller/friendly_id/sample/simple/ApplicationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.http.MediaType;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import com.devskiller.friendly_id.FriendlyId;
12+
import com.devskiller.friendly_id.FriendlyIds;
1313

1414
import static org.hamcrest.Matchers.is;
1515
import static org.hamcrest.Matchers.notNullValue;
@@ -28,7 +28,7 @@ class ApplicationTest {
2828
void shouldAcceptFriendlyIdAsPathVariable() throws Exception {
2929
// given
3030
UUID uuid = UUID.randomUUID();
31-
String friendlyId = FriendlyId.toFriendlyId(uuid);
31+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
3232
String rawUuid = uuid.toString();
3333

3434
// when/then
@@ -46,7 +46,7 @@ void shouldAcceptFriendlyIdAsPathVariable() throws Exception {
4646
void shouldAcceptUuidAsPathVariable() throws Exception {
4747
// given
4848
UUID uuid = UUID.randomUUID();
49-
String friendlyId = FriendlyId.toFriendlyId(uuid);
49+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
5050
String rawUuid = uuid.toString();
5151

5252
// when/then - using raw UUID as path variable
@@ -64,7 +64,7 @@ void shouldAcceptUuidAsPathVariable() throws Exception {
6464
void shouldDeserializeAndSerialize() throws Exception {
6565
// given
6666
UUID uuid = UUID.randomUUID();
67-
String friendlyId = FriendlyId.toFriendlyId(uuid);
67+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
6868
String json = """
6969
{"id": "%s"}
7070
""".formatted(friendlyId);
@@ -101,7 +101,7 @@ void shouldGenerateAllIdsWhenNotProvided() throws Exception {
101101
void shouldAcceptFriendlyIdAsRequestParam() throws Exception {
102102
// given
103103
UUID uuid = UUID.randomUUID();
104-
String friendlyId = FriendlyId.toFriendlyId(uuid);
104+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
105105
String rawUuid = uuid.toString();
106106

107107
// when/then - using FriendlyId as ?id=xxx
@@ -118,7 +118,7 @@ void shouldAcceptFriendlyIdAsRequestParam() throws Exception {
118118
void shouldAcceptUuidAsRequestParam() throws Exception {
119119
// given
120120
UUID uuid = UUID.randomUUID();
121-
String friendlyId = FriendlyId.toFriendlyId(uuid);
121+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
122122
String rawUuid = uuid.toString();
123123

124124
// when/then - using raw UUID as ?id=xxx
@@ -135,7 +135,7 @@ void shouldAcceptUuidAsRequestParam() throws Exception {
135135
void shouldAcceptFriendlyIdTypeAsRequestParam() throws Exception {
136136
// given
137137
UUID uuid = UUID.randomUUID();
138-
String friendlyId = FriendlyId.toFriendlyId(uuid);
138+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
139139
String rawUuid = uuid.toString();
140140

141141
// when/then - using FriendlyId string with @RequestParam FriendlyId type

friendly-id-samples/friendly-id-spring-boot3-simple/src/main/java/com/devskiller/friendly_id/sample/spring3/FriendlyIdConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.springframework.format.FormatterRegistry;
99
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
1010

11-
import com.devskiller.friendly_id.FriendlyId;
11+
import com.devskiller.friendly_id.FriendlyIds;
1212
import com.devskiller.friendly_id.jackson2.FriendlyIdJackson2Module;
1313

1414
@Configuration
@@ -29,15 +29,15 @@ public static class StringToUuidConverter implements Converter<String, UUID> {
2929

3030
@Override
3131
public UUID convert(String id) {
32-
return FriendlyId.toUuid(id);
32+
return FriendlyIds.toUuid(id);
3333
}
3434
}
3535

3636
public static class UuidToStringConverter implements Converter<UUID, String> {
3737

3838
@Override
3939
public String convert(UUID id) {
40-
return FriendlyId.toFriendlyId(id);
40+
return FriendlyIds.toFriendlyId(id);
4141
}
4242
}
4343
}

friendly-id-samples/friendly-id-spring-boot3-simple/src/test/java/com/devskiller/friendly_id/sample/spring3/ApplicationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import org.springframework.http.MediaType;
1010
import org.springframework.test.web.servlet.MockMvc;
1111

12-
import com.devskiller.friendly_id.FriendlyId;
12+
import com.devskiller.friendly_id.FriendlyIds;
1313

1414
import static org.hamcrest.Matchers.is;
1515
import static org.hamcrest.Matchers.notNullValue;
@@ -28,7 +28,7 @@ class ApplicationTest {
2828
void shouldSerializeAllIdFormats() throws Exception {
2929
// given
3030
UUID uuid = UUID.randomUUID();
31-
String friendlyId = FriendlyId.toFriendlyId(uuid);
31+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
3232
String rawUuid = uuid.toString();
3333

3434
// when/then
@@ -46,7 +46,7 @@ void shouldSerializeAllIdFormats() throws Exception {
4646
void shouldDeserializeAndSerialize() throws Exception {
4747
// given
4848
UUID uuid = UUID.randomUUID();
49-
String friendlyId = FriendlyId.toFriendlyId(uuid);
49+
String friendlyId = FriendlyIds.toFriendlyId(uuid);
5050
String json = """
5151
{"id": "%s"}
5252
""".formatted(friendlyId);

friendly-id/src/test/java/com/devskiller/friendly_id/FriendlyIdTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.devskiller.friendly_id;
22

3-
import org.junit.jupiter.api.RepeatedTest;
4-
import org.junit.jupiter.api.Test;
5-
63
import java.math.BigInteger;
74
import java.util.Random;
85
import java.util.UUID;
96

7+
import org.junit.jupiter.api.RepeatedTest;
8+
109
import static com.devskiller.friendly_id.FriendlyId.toFriendlyId;
1110
import static com.devskiller.friendly_id.FriendlyId.toUuid;
1211
import static com.devskiller.friendly_id.IdUtil.areEqualIgnoringLeadingZeros;

0 commit comments

Comments
 (0)