@Test public void testParseDefinitionStreamFile() throws Exception { StreamDefinitionParser parser = new StreamDefinitionParser(IOUtils.toString(this.getClass() .getResourceAsStream("/definition.json"))); StreamDefinition streamDefinition = parser.parse(); List<StreamField> listOfStreamFields = streamDefinition.getFields(); assertEquals(streamDefinition.getStreamName(),"testStream"); assertEquals(listOfStreamFields.size(), 2); assertEquals(listOfStreamFields.get(0).getName(), "field1"); assertEquals(listOfStreamFields.get(0).getType(), "string"); assertEquals(listOfStreamFields.get(1).getName(), "field2"); assertEquals(listOfStreamFields.get(1).getType(), "int"); }
public StreamDefinition parse() { ObjectMapper mapper = new ObjectMapper(); StreamDefinition streamDefinition; try { streamDefinition = mapper.readValue(jsonDefinition, StreamDefinition.class); } catch (Exception e) { throw new StratioDecisionSinkException(e); } return streamDefinition; }
StreamDefinitionParser { public StreamDefinition parse() { ObjectMapper mapper = new ObjectMapper(); StreamDefinition streamDefinition; try { streamDefinition = mapper.readValue(jsonDefinition, StreamDefinition.class); } catch (Exception e) { throw new StratioDecisionSinkException(e); } return streamDefinition; } }
StreamDefinitionParser { public StreamDefinition parse() { ObjectMapper mapper = new ObjectMapper(); StreamDefinition streamDefinition; try { streamDefinition = mapper.readValue(jsonDefinition, StreamDefinition.class); } catch (Exception e) { throw new StratioDecisionSinkException(e); } return streamDefinition; } StreamDefinitionParser(String jsonDefinition); }
StreamDefinitionParser { public StreamDefinition parse() { ObjectMapper mapper = new ObjectMapper(); StreamDefinition streamDefinition; try { streamDefinition = mapper.readValue(jsonDefinition, StreamDefinition.class); } catch (Exception e) { throw new StratioDecisionSinkException(e); } return streamDefinition; } StreamDefinitionParser(String jsonDefinition); StreamDefinition parse(); }
StreamDefinitionParser { public StreamDefinition parse() { ObjectMapper mapper = new ObjectMapper(); StreamDefinition streamDefinition; try { streamDefinition = mapper.readValue(jsonDefinition, StreamDefinition.class); } catch (Exception e) { throw new StratioDecisionSinkException(e); } return streamDefinition; } StreamDefinitionParser(String jsonDefinition); StreamDefinition parse();  }