Package gov.nasa.arc.mct.components

Examples of gov.nasa.arc.mct.components.FeedProvider$RenderingInfo


  @SuppressWarnings("unchecked")
  @Test(dataProvider="evalTestData")
  public void testEvalutor(String code, String inputValue, String expectedValue) {
    EnumEvaluator enumEvaluator = new EnumEvaluator();
    Executor e = enumEvaluator.compile(code);
    FeedProvider fp = Mockito.mock(FeedProvider.class);
    Mockito.when(fp.getSubscriptionId()).thenReturn("abc");
    FeedProvider.RenderingInfo data = new FeedProvider.RenderingInfo(inputValue, Color.red, "x", Color.red, true);
    Mockito.when(fp.getRenderingInfo(Mockito.anyMap())).thenReturn(data);
    Map<String, String> value = Collections.singletonMap(FeedProvider.NORMALIZED_RENDERING_INFO, data.toString());
    List<Map<String, String>> values = Collections.singletonList(value);
    Map<String, List<Map<String, String>>> dataSet = Collections.singletonMap(fp.getSubscriptionId(), values);
    FeedProvider.RenderingInfo info = e.evaluate(dataSet, Collections.singletonList(fp));
    Assert.assertTrue(info.isValid());
    Assert.assertEquals(info.getValueText(), expectedValue);
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  @Test(dataProvider="expressions")
  public void test(final String expression, Map<String, List<Map<String,String>>> data, final String expectedValue, final String expectedStatus, final boolean isValid) {
    String[] ids = new String[] {"PARAMETER1","PARAMETER2","PARAMETER3"};
    for (String id:ids) {
      FeedProvider provider = Mockito.mock(FeedProvider.class);
      Mockito.when(provider.getSubscriptionId()).thenReturn("isp:"+id);
      Mockito.when(provider.getRenderingInfo(Mockito.anyMap())).thenAnswer(new Answer<FeedProvider.RenderingInfo>() {
        public FeedProvider.RenderingInfo answer(InvocationOnMock invocation) {
          Object[] args = invocation.getArguments();
          Map<String,String> dataValues = Map.class.cast(args[0]);
          String statusText = dataValues.get(INDICATOR_KEY);
          boolean isValid = Boolean.parseBoolean(dataValues.get(FeedProvider.NORMALIZED_IS_VALID_KEY));
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test(dataProvider="expressions2")
  public void test2(final String expression, Map<String, List<Map<String,String>>> data, final String expectedValue, final String expectedStatus, final boolean isValid) {
    String[] ids = new String[] {"PARAMETER1","PARAMETER2","PARAMETER3"};
    for (String id:ids) {
      FeedProvider provider = Mockito.mock(FeedProvider.class);
      Mockito.when(provider.getSubscriptionId()).thenReturn("isp:"+id);
      Mockito.when(provider.getRenderingInfo(Mockito.anyMap())).thenAnswer(new Answer<FeedProvider.RenderingInfo>() {
        public FeedProvider.RenderingInfo answer(InvocationOnMock invocation) {
          Object[] args = invocation.getArguments();
          Map<String,String> dataValues = Map.class.cast(args[0]);
          String statusText = dataValues.get(INDICATOR_KEY);
          boolean isValid = Boolean.parseBoolean(dataValues.get(FeedProvider.NORMALIZED_IS_VALID_KEY));
View Full Code Here

    component.setDisplayName(opsName);
  }

  @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); // expect this to fail when UI colors are implemented
    Assert.assertSame(provider.getTimeService(), TimeServiceImpl.getInstance())
  }
View Full Code Here

    label.setFont(updateBaseFont(Font.ITALIC));
    label.setForeground(Color.LIGHT_GRAY);

    add(label);

    FeedProvider fp = ac.getCapability(FeedProvider.class);
    feedProviders = fp==null ? Collections.<FeedProvider>emptyList() : Collections.singleton(fp);

    setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
   
    MouseAdapter adapter = new LegendEntryMouseAdapter();
View Full Code Here

                PolicyContext.PropertyName.TARGET_VIEW_INFO.getName(), ViewInfo.class);

    // Check if this is a graphical view
    if (GraphicalManifestation.class.equals(viewInfo.getViewClass())) {
            // Get the feed provider component
            FeedProvider provider = context.getProperty(
                            PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
                            FeedProvider.class);

            // Check if the feed type is String. We don't want to plot or
            // graphicalmatriculatamatize them
            if(provider != null){
              if (provider.getFeedType() == FeedType.STRING) {
                  return new ExecutionResult(context, false, EM_STRING);
              }
            }
        }
    return new ExecutionResult(context, true, EM_STRING);
View Full Code Here

        ViewInfo.class);

    // Check if this is a plot view
    if (viewInfo.getViewClass().equals(PlotViewManifestation.class)) {
      // Get the telemetry component
      FeedProvider provider = context.getProperty(
          PolicyContext.PropertyName.TARGET_COMPONENT.getName(),
          FeedProvider.class);

      // Check if the feed type is String. We don't want to plot or
      // graphicalmatize them
      if (provider != null) {
        if (provider.getFeedType() == FeedType.STRING) {
          return new ExecutionResult(context, false, EM_STRING);
        }
      }
    }
    return new ExecutionResult(context, true, EM_STRING);
View Full Code Here

  }
 
  @Test(dataProvider="expandDataTest")
  public void testExpandData(Map<String, List<Map<String, String>>> expandedData,
      long startTime, long endTime, Long[] expectedTimes) throws Exception {
    final FeedProvider fp = Mockito.mock(FeedProvider.class);
    final String feedId = "feedId";
    Mockito.when(fp.getSubscriptionId()).thenReturn(feedId);
    PlotViewManifestation manifestation = new PlotViewManifestation(mockComponent,new ViewInfo(PlotViewManifestation.class,"",ViewType.OBJECT)) {
      private static final long serialVersionUID = 1L;

      @Override
      public Collection<FeedProvider> getVisibleFeedProviders() {
        return Collections.singleton(fp);
      }
     
      @Override
      public long getCurrentMCTTime() {
        return 7L;
      }
    };
    Mockito.when(fp.getTimeService()).thenReturn(timeService);

    Method m = PlotViewManifestation.class.getDeclaredMethod("expandData", Map.class, Long.TYPE, Long.TYPE);
    m.setAccessible(true);
    m.invoke(manifestation, expandedData,startTime, endTime);
    List<Map<String, String>> values = expandedData.get(feedId);
View Full Code Here

   
    List<FeedProvider> fps = new ArrayList<FeedProvider>();
    for (String timeSys : TEST_TIME_SYSTEMS) {
      TimeService ts = Mockito.mock(TimeService.class);
      Mockito.when(ts.getTimeSystemId()).thenReturn(timeSys);
      FeedProvider fp = Mockito.mock(FeedProvider.class);
      Mockito.when(fp.getTimeService()).thenReturn(ts);     
      fps.add(fp);
    }
   
    AbstractComponent fpMockComponent = Mockito.mock(AbstractComponent.class);
    Mockito.when(fpMockComponent.getCapabilities(FeedProvider.class)).thenReturn(fps);
    Mockito.when(fpMockComponent.getCapability(FeedProvider.class)).thenReturn(null);
    FeedProvider fp = manifestation.getFeedProvider(fpMockComponent);
   
    if (setting.startsWith("SYS")) { // One of the expected test time systems
      Assert.assertEquals(fp.getTimeService().getTimeSystemId(), setting);
    } else { // One of the time systems that should fail.
      Assert.assertNull(fp);
    }
  }
View Full Code Here

      Collection<FeedProvider> feedproviders = getVisibleFeedProviders();
      if (!feedproviders.isEmpty()) {
         
          /* We want to get our "current time" from the feeds we're plotting */
          Iterator<FeedProvider> feedIterator = feedproviders.iterator();
        FeedProvider firstProvider = feedIterator.next();
        FeedProvider fp = firstProvider;
       
        /* Find the first non-predictive feed provider;
         * predictive feeds may not have useful time values */
        while (fp.isPrediction() && feedIterator.hasNext()) {
            fp = feedIterator.next();
        }
       
        /* If none is available, use the first predictive provider for consistency */
        if (fp.isPrediction()) fp = firstProvider;
       
        long currentTimeInMillis =  fp.getTimeService().getCurrentTime();
        if (currentTimeInMillis >= 0) {
          cachedTime = currentTimeInMillis;
        } else {
          logger.error("FeedProvider currentTimeMillis() returned a time less than zero: {}", currentTimeInMillis);
        }
View Full Code Here

TOP

Related Classes of gov.nasa.arc.mct.components.FeedProvider$RenderingInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.