use of com.nimbusds.jose.shaded.json.JSONObject in project spring-security by spring-projects.
the class ClaimConversionServiceTests method convertMapStringObjectWhenJsonObjectThenConverts.
@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);
}
use of com.nimbusds.jose.shaded.json.JSONObject in project spring-security by spring-projects.
the class ClaimTypeConverterTests method convertWhenAllClaimsRequireConversionThenConvertAll.
@Test
public void convertWhenAllClaimsRequireConversionThenConvertAll() throws Exception {
Instant instant = Instant.now();
URL url = new URL("https://localhost");
List<Number> listNumber = Lists.list(1, 2, 3, 4);
List<String> listString = Lists.list("1", "2", "3", "4");
Map<Integer, Object> mapIntegerObject = new HashMap<>();
mapIntegerObject.put(1, "value1");
Map<String, Object> mapStringObject = new HashMap<>();
mapStringObject.put("1", "value1");
JSONArray jsonArray = new JSONArray();
jsonArray.add("1");
List<String> jsonArrayListString = Lists.list("1");
JSONObject jsonObject = new JSONObject();
jsonObject.put("1", "value1");
Map<String, Object> jsonObjectMap = Maps.newHashMap("1", "value1");
Map<String, Object> claims = new HashMap<>();
claims.put(STRING_CLAIM, Boolean.TRUE);
claims.put(BOOLEAN_CLAIM, "true");
claims.put(INSTANT_CLAIM, instant.toString());
claims.put(URL_CLAIM, url.toExternalForm());
claims.put(COLLECTION_STRING_CLAIM, listNumber);
claims.put(LIST_STRING_CLAIM, listNumber);
claims.put(MAP_STRING_OBJECT_CLAIM, mapIntegerObject);
claims.put(JSON_ARRAY_CLAIM, jsonArray);
claims.put(JSON_OBJECT_CLAIM, jsonObject);
claims = this.claimTypeConverter.convert(claims);
assertThat(claims.get(STRING_CLAIM)).isEqualTo("true");
assertThat(claims.get(BOOLEAN_CLAIM)).isEqualTo(Boolean.TRUE);
assertThat(claims.get(INSTANT_CLAIM)).isEqualTo(instant);
assertThat(claims.get(URL_CLAIM)).isEqualTo(url);
assertThat(claims.get(COLLECTION_STRING_CLAIM)).isEqualTo(listString);
assertThat(claims.get(LIST_STRING_CLAIM)).isEqualTo(listString);
assertThat(claims.get(MAP_STRING_OBJECT_CLAIM)).isEqualTo(mapStringObject);
assertThat(claims.get(JSON_ARRAY_CLAIM)).isEqualTo(jsonArrayListString);
assertThat(claims.get(JSON_OBJECT_CLAIM)).isEqualTo(jsonObjectMap);
}
Aggregations