Esempio n. 1
0
  @Test
  public void specialTypes() throws JSONException {
    JsonMapper jsonMapper = createJsonMapper();
    SpecialJavaTypes special = new SpecialJavaTypes();
    special.decimal = new BigDecimal("1234567.4");
    special.integer = new BigInteger("1234567");

    String string = jsonMapper.toJson(special);
    String expectedJson = "{\"integer\":1234567, \"decimal\":1234567.4}";

    JSONAssert.assertEquals(expectedJson, string, JSONCompareMode.NON_EXTENSIBLE);
  }
 public ClientDetails mapRow(ResultSet rs, int rowNum) throws SQLException {
   BaseClientDetails details =
       new BaseClientDetails(
           rs.getString(1),
           rs.getString(3),
           rs.getString(4),
           rs.getString(5),
           rs.getString(7),
           rs.getString(6));
   details.setClientSecret(rs.getString(2));
   if (rs.getObject(8) != null) {
     details.setAccessTokenValiditySeconds(rs.getInt(8));
   }
   if (rs.getObject(9) != null) {
     details.setRefreshTokenValiditySeconds(rs.getInt(9));
   }
   String json = rs.getString(10);
   if (json != null) {
     try {
       @SuppressWarnings("unchecked")
       Map<String, Object> additionalInformation = mapper.read(json, Map.class);
       details.setAdditionalInformation(additionalInformation);
     } catch (Exception e) {
       logger.warn("Could not decode JSON for additional information: " + details, e);
     }
   }
   String scopes = rs.getString(11);
   if (scopes != null) {
     details.setAutoApproveScopes(StringUtils.commaDelimitedListToSet(scopes));
   }
   return details;
 }
 private Object[] getFieldsForUpdate(ClientDetails clientDetails) {
   String json = null;
   try {
     json = mapper.write(clientDetails.getAdditionalInformation());
   } catch (Exception e) {
     logger.warn("Could not serialize additional information: " + clientDetails, e);
   }
   return new Object[] {
     clientDetails.getResourceIds() != null
         ? StringUtils.collectionToCommaDelimitedString(clientDetails.getResourceIds())
         : null,
     clientDetails.getScope() != null
         ? StringUtils.collectionToCommaDelimitedString(clientDetails.getScope())
         : null,
     clientDetails.getAuthorizedGrantTypes() != null
         ? StringUtils.collectionToCommaDelimitedString(clientDetails.getAuthorizedGrantTypes())
         : null,
     clientDetails.getRegisteredRedirectUri() != null
         ? StringUtils.collectionToCommaDelimitedString(clientDetails.getRegisteredRedirectUri())
         : null,
     clientDetails.getAuthorities() != null
         ? StringUtils.collectionToCommaDelimitedString(clientDetails.getAuthorities())
         : null,
     clientDetails.getAccessTokenValiditySeconds(),
     clientDetails.getRefreshTokenValiditySeconds(),
     json,
     getAutoApproveScopes(clientDetails),
     clientDetails.getClientId()
   };
 }
Esempio n. 4
0
 @PostConstruct
 protected void init() {
   super.init();
   Module module = getJacksonModule();
   if (module != null) jsonMapper.registerModule(module);
 }