@Test public void shouldDeserializeParameterMetadataSectionFromJSON() throws ParamSerializationException { String json = "{ \"name\": \"parameter\", \"cacheable\": \"true\"," + "\"nullable\": \"true\", \"inputLevels\": 1, \"levels\": [" + "{\"name\": \"level1\", \"levelCreator\": \"level1Creator\", \"type\": \"level1Type\", \"matcher\": \"level1Matcher\"}," + "{\"name\": \"level2\"}" + "]}"; Parameter parameter = deserializer.deserialize(StringStreamUtil.reader(json)); assertThat(parameter).hasName("parameter").isCacheable().isNullable().hasInputLevels(1).hasLevels(2) .level(0).hasName("level1").hasLevelCreator("level1Creator") .hasType("level1Type").hasMatcher("level1Matcher"); }
@Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); @Override AppendableParameter deserialize(BufferedReader reader); }
JsonParameterMetadataDeserializer implements ParameterMetadataDeserializer { @Override public AppendableParameter deserialize(BufferedReader reader) throws ParamSerializationException { String jsonConfig = null; try { jsonConfig = StreamPartReader.readPart(reader, '{', '}'); } catch (IOException exception) { throw new ParamSerializationException("Unable to read config part from stream.", exception); } DeserializedParameter parameter = gson.fromJson(jsonConfig, DeserializedParameter.class); parameter.normalizeLevels(); return parameter; } JsonParameterMetadataDeserializer(); @Override AppendableParameter deserialize(BufferedReader reader);  }