@Test public void tokenRestrictionDeserialisationWithTypeWorks() throws Exception { InternalSession is = SERIALISATION.deserialise(getJSON("/json/basic-session-with-restriction.json"), InternalSession.class); assertThat(is).isNotNull(); TokenRestriction restriction = is.getRestrictionForToken(new SessionID("AQIC5wM2LY4SfcyTLz6VjQ7nkFeDcEh8K5dXkIE" + "NpXlpg28.*AAJTSQACMDIAAlMxAAIwMQACU0sAEzc5ODIzMDM5MzQyNzU2MTg1NDQ.*")); assertThat(restriction).isNotNull().isInstanceOf(DNOrIPAddressListTokenRestriction.class); assertThat(restriction.toString().equals("Fzy2GsI/O1TsXhvlVuqjqIuTG2k=")); }
public <T> T deserialise(String text, Class<T> clazz) { try { T value = mapper.readValue(text, clazz); return value; } catch (IOException e) { throw new IllegalStateException( MessageFormat.format( "Failed to deserailise {0}", clazz.getSimpleName()), e); } }
JSONSerialisation { public <T> T deserialise(String text, Class<T> clazz) { try { T value = mapper.readValue(text, clazz); return value; } catch (IOException e) { throw new IllegalStateException( MessageFormat.format( "Failed to deserailise {0}", clazz.getSimpleName()), e); } } }
JSONSerialisation { public <T> T deserialise(String text, Class<T> clazz) { try { T value = mapper.readValue(text, clazz); return value; } catch (IOException e) { throw new IllegalStateException( MessageFormat.format( "Failed to deserailise {0}", clazz.getSimpleName()), e); } } JSONSerialisation(); }
JSONSerialisation { public <T> T deserialise(String text, Class<T> clazz) { try { T value = mapper.readValue(text, clazz); return value; } catch (IOException e) { throw new IllegalStateException( MessageFormat.format( "Failed to deserailise {0}", clazz.getSimpleName()), e); } } JSONSerialisation(); String serialise(T object); T deserialise(String text, Class<T> clazz); static String jsonAttributeName(String name); }
JSONSerialisation { public <T> T deserialise(String text, Class<T> clazz) { try { T value = mapper.readValue(text, clazz); return value; } catch (IOException e) { throw new IllegalStateException( MessageFormat.format( "Failed to deserailise {0}", clazz.getSimpleName()), e); } } JSONSerialisation(); String serialise(T object); T deserialise(String text, Class<T> clazz); static String jsonAttributeName(String name);  }