DocumentStoreTimelineReaderImpl extends AbstractService implements TimelineReader { public TimelineEntity getEntity(TimelineReaderContext context, TimelineDataToRetrieve dataToRetrieve) throws IOException { TimelineEntityDocument timelineEntityDoc; switch (TimelineEntityType.valueOf(context.getEntityType())) { case YARN_FLOW_ACTIVITY: case YARN_FLOW_RUN: timelineEntityDoc = collectionReader.readDocument(context); return DocumentStoreUtils.createEntityToBeReturned( timelineEntityDoc, dataToRetrieve.getConfsToRetrieve(), dataToRetrieve.getMetricsToRetrieve()); default: timelineEntityDoc = collectionReader.readDocument(context); } return DocumentStoreUtils.createEntityToBeReturned( timelineEntityDoc, dataToRetrieve); } DocumentStoreTimelineReaderImpl(); @Override void serviceInit(Configuration conf); @Override void serviceStop(); TimelineEntity getEntity(TimelineReaderContext context,
      TimelineDataToRetrieve dataToRetrieve); Set<TimelineEntity> getEntities(TimelineReaderContext context,
      TimelineEntityFilters filters, TimelineDataToRetrieve dataToRetrieve); Set<String> getEntityTypes(TimelineReaderContext context); @Override TimelineHealth getHealthStatus();  }
@Test public void testGetEntity() throws Exception { context.setEntityType(TimelineEntityType.YARN_APPLICATION.toString()); timelineReader.serviceInit(conf); TimelineDataToRetrieve dataToRetrieve = new TimelineDataToRetrieve(); EnumSet<TimelineReader.Field> fieldsToRetrieve = EnumSet.noneOf( TimelineReader.Field.class); dataToRetrieve.setFieldsToRetrieve(fieldsToRetrieve); TimelineEntity timelineEntity = timelineReader.getEntity(context, dataToRetrieve); Assert.assertEquals(appTimelineEntity.getCreatedTime(), timelineEntity .getCreatedTime().longValue()); Assert.assertEquals(0, timelineEntity .getMetrics().size()); Assert.assertEquals(0, timelineEntity.getEvents().size()); Assert.assertEquals(0, timelineEntity.getConfigs().size()); Assert.assertEquals(appTimelineEntity.getInfo().size(), timelineEntity.getInfo().size()); }