|
@@ -26,6 +26,8 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import com.nimbusds.jose.shaded.json.JSONArray;
|
|
|
+import com.nimbusds.jose.shaded.json.JSONObject;
|
|
|
import org.assertj.core.util.Lists;
|
|
|
import org.junit.Test;
|
|
|
|
|
@@ -145,9 +147,9 @@ public class ClaimConversionServiceTests {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void convertCollectionStringWhenListStringThenReturnSame() {
|
|
|
+ public void convertCollectionStringWhenListStringThenReturnNotSameButEqual() {
|
|
|
List<String> list = Lists.list("1", "2", "3", "4");
|
|
|
- assertThat(this.conversionService.convert(list, Collection.class)).isSameAs(list);
|
|
|
+ assertThat(this.conversionService.convert(list, Collection.class)).isNotSameAs(list).isEqualTo(list);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -156,6 +158,17 @@ public class ClaimConversionServiceTests {
|
|
|
.isEqualTo(Lists.list("1", "2", "3", "4"));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void convertListStringWhenJsonArrayThenConverts() {
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ jsonArray.add("1");
|
|
|
+ jsonArray.add("2");
|
|
|
+ jsonArray.add("3");
|
|
|
+ jsonArray.add(null);
|
|
|
+ assertThat(this.conversionService.convert(jsonArray, List.class)).isNotInstanceOf(JSONArray.class)
|
|
|
+ .isEqualTo(Lists.list("1", "2", "3"));
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void convertCollectionStringWhenNotConvertibleThenReturnSingletonList() {
|
|
|
String string = "not-convertible-collection";
|
|
@@ -169,9 +182,9 @@ public class ClaimConversionServiceTests {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void convertListStringWhenListStringThenReturnSame() {
|
|
|
+ public void convertListStringWhenListStringThenReturnNotSameButEqual() {
|
|
|
List<String> list = Lists.list("1", "2", "3", "4");
|
|
|
- assertThat(this.conversionService.convert(list, List.class)).isSameAs(list);
|
|
|
+ assertThat(this.conversionService.convert(list, List.class)).isNotSameAs(list).isEqualTo(list);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -192,7 +205,7 @@ public class ClaimConversionServiceTests {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void convertMapStringObjectWhenMapStringObjectThenReturnSame() {
|
|
|
+ public void convertMapStringObjectWhenMapStringObjectThenReturnNotSameButEqual() {
|
|
|
Map<String, Object> mapStringObject = new HashMap<String, Object>() {
|
|
|
{
|
|
|
put("key1", "value1");
|
|
@@ -200,7 +213,8 @@ public class ClaimConversionServiceTests {
|
|
|
put("key3", "value3");
|
|
|
}
|
|
|
};
|
|
|
- assertThat(this.conversionService.convert(mapStringObject, Map.class)).isSameAs(mapStringObject);
|
|
|
+ assertThat(this.conversionService.convert(mapStringObject, Map.class)).isNotSameAs(mapStringObject)
|
|
|
+ .isEqualTo(mapStringObject);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
@@ -222,6 +236,22 @@ public class ClaimConversionServiceTests {
|
|
|
assertThat(this.conversionService.convert(mapIntegerObject, Map.class)).isEqualTo(mapStringObject);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void convertMapStringObjectWhenJsonObjectThenConverts() {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("1", "value1");
|
|
|
+ jsonObject.put("2", "value2");
|
|
|
+
|
|
|
+ Map<String, Object> mapStringObject = new HashMap<String, Object>() {
|
|
|
+ {
|
|
|
+ put("1", "value1");
|
|
|
+ put("2", "value2");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ assertThat(this.conversionService.convert(jsonObject, Map.class)).isNotInstanceOf(JSONObject.class)
|
|
|
+ .isEqualTo(mapStringObject);
|
|
|
+ }
|
|
|
+
|
|
|
@Test
|
|
|
public void convertMapStringObjectWhenNotConvertibleThenReturnNull() {
|
|
|
List<String> notConvertibleList = Lists.list("1", "2", "3", "4");
|