@Test public void handleGetCapability() { FeedProvider provider = component.getCapability(FeedProvider.class); Assert.assertEquals(provider.getMaximumSampleRate(),1); Assert.assertEquals(provider.getSubscriptionId(),"limit:"+component.getComponentId()); Assert.assertEquals(provider.getCanonicalName(), opsName); Assert.assertEquals(provider.getLegendText(),opsName); Assert.assertEquals(provider.getFeedType(),FeedProvider.FeedType.FLOATING_POINT); FeedProvider.RenderingInfo info = provider.getRenderingInfo(Collections.<String,String>singletonMap(FeedProvider.NORMALIZED_VALUE_KEY, "1.23")); Assert.assertEquals(info.getStatusText()," "); Assert.assertEquals(info.getValueText(), "1.23"); Assert.assertEquals(info.getValueColor(), Color.green); Assert.assertEquals(info.getStatusColor(), Color.green); Assert.assertSame(provider.getTimeService(), TimeServiceImpl.getInstance()); }
@Override protected <T> T handleGetCapability(Class<T> capability) { if (FeedProvider.class.isAssignableFrom(capability)) { return capability.cast(this); } if (ModelStatePersistence.class.isAssignableFrom(capability)) { JAXBModelStatePersistence<LimitLineModel> persistence = new JAXBModelStatePersistence<LimitLineModel>() { @Override protected LimitLineModel getStateToPersist() { return model.get(); } @Override protected void setPersistentState(LimitLineModel modelState) { model.set(modelState); } @Override protected Class<LimitLineModel> getJAXBClass() { return LimitLineModel.class; } }; return capability.cast(persistence); } return null; }
LimitLineComponent extends AbstractComponent implements FeedProvider { @Override protected <T> T handleGetCapability(Class<T> capability) { if (FeedProvider.class.isAssignableFrom(capability)) { return capability.cast(this); } if (ModelStatePersistence.class.isAssignableFrom(capability)) { JAXBModelStatePersistence<LimitLineModel> persistence = new JAXBModelStatePersistence<LimitLineModel>() { @Override protected LimitLineModel getStateToPersist() { return model.get(); } @Override protected void setPersistentState(LimitLineModel modelState) { model.set(modelState); } @Override protected Class<LimitLineModel> getJAXBClass() { return LimitLineModel.class; } }; return capability.cast(persistence); } return null; } }
LimitLineComponent extends AbstractComponent implements FeedProvider { @Override protected <T> T handleGetCapability(Class<T> capability) { if (FeedProvider.class.isAssignableFrom(capability)) { return capability.cast(this); } if (ModelStatePersistence.class.isAssignableFrom(capability)) { JAXBModelStatePersistence<LimitLineModel> persistence = new JAXBModelStatePersistence<LimitLineModel>() { @Override protected LimitLineModel getStateToPersist() { return model.get(); } @Override protected void setPersistentState(LimitLineModel modelState) { model.set(modelState); } @Override protected Class<LimitLineModel> getJAXBClass() { return LimitLineModel.class; } }; return capability.cast(persistence); } return null; }  }
LimitLineComponent extends AbstractComponent implements FeedProvider { @Override protected <T> T handleGetCapability(Class<T> capability) { if (FeedProvider.class.isAssignableFrom(capability)) { return capability.cast(this); } if (ModelStatePersistence.class.isAssignableFrom(capability)) { JAXBModelStatePersistence<LimitLineModel> persistence = new JAXBModelStatePersistence<LimitLineModel>() { @Override protected LimitLineModel getStateToPersist() { return model.get(); } @Override protected void setPersistentState(LimitLineModel modelState) { model.set(modelState); } @Override protected Class<LimitLineModel> getJAXBClass() { return LimitLineModel.class; } }; return capability.cast(persistence); } return null; }  @Override boolean isLeaf(); @Override String getLegendText(); @Override int getMaximumSampleRate(); @Override String getSubscriptionId(); LimitLineModel getModel(); @Override boolean isPrediction(); @Override TimeService getTimeService(); @Override String getCanonicalName(); @Override RenderingInfo getRenderingInfo(Map<String, String> data); static RenderingInfo getRenderingInfo(String stringifiedValue); @Override FeedType getFeedType(); @Override long getValidDataExtent(); void setDataProvider(DataProvider dataProvider); LimitDataProvider getDataProvider(); @Override List<PropertyDescriptor> getFieldDescriptors(); @Override boolean isNonCODDataBuffer(); }
LimitLineComponent extends AbstractComponent implements FeedProvider { @Override protected <T> T handleGetCapability(Class<T> capability) { if (FeedProvider.class.isAssignableFrom(capability)) { return capability.cast(this); } if (ModelStatePersistence.class.isAssignableFrom(capability)) { JAXBModelStatePersistence<LimitLineModel> persistence = new JAXBModelStatePersistence<LimitLineModel>() { @Override protected LimitLineModel getStateToPersist() { return model.get(); } @Override protected void setPersistentState(LimitLineModel modelState) { model.set(modelState); } @Override protected Class<LimitLineModel> getJAXBClass() { return LimitLineModel.class; } }; return capability.cast(persistence); } return null; }  @Override boolean isLeaf(); @Override String getLegendText(); @Override int getMaximumSampleRate(); @Override String getSubscriptionId(); LimitLineModel getModel(); @Override boolean isPrediction(); @Override TimeService getTimeService(); @Override String getCanonicalName(); @Override RenderingInfo getRenderingInfo(Map<String, String> data); static RenderingInfo getRenderingInfo(String stringifiedValue); @Override FeedType getFeedType(); @Override long getValidDataExtent(); void setDataProvider(DataProvider dataProvider); LimitDataProvider getDataProvider(); @Override List<PropertyDescriptor> getFieldDescriptors(); @Override boolean isNonCODDataBuffer(); static final String LIMIT_FEED_PREFIX; }