@Test @UsingDataSet(locations = "singleDashboard.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT) public void testAll() throws Exception { final List<Dashboard> dashboards = dashboardService.all(); final Dashboard dashboard = dashboards.get(0); assertEquals("Should have returned exactly 1 document", 1, dashboards.size()); assertEquals("Example dashboard", dashboard.getTitle()); }
protected Dashboard getDashboardFromCache(DashboardCacheKey key) { Dashboard dashboard; RepositoryAccess repository = RepositoryAccess.getRepository(); try { Cache cache = getCache(); Element cacheElement = cache.get(key); if (cacheElement == null) { return null; } else { dashboard = (Dashboard) cacheElement.getValue(); } logger.info("Got dashboard from cache"); ISolutionFile dash = repository.getSolutionFile(key.getCdfde(), FileAccess.READ); // was NO_PERM=0; if (dash == null) { logger.error(key.getCdfde() + " not found."); return null; } ISolutionFile templ; if (key.getTemplate() == null) { templ = null; } else { templ = repository.getSolutionFile(key.getTemplate(), FileAccess.READ); } /* Cache is invalidated if the dashboard or template have changed since * the cache was loaded, or at midnight every day, because of dynamic * generation of date parameters. */ Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY, 00); cal.set(Calendar.MINUTE, 00); cal.set(Calendar.SECOND, 1); boolean cacheInvalid = dash.getLastModified() > dashboard.getLoaded().getTime() || (templ != null && templ.getLastModified() > dashboard.getLoaded().getTime()), cacheExpired = cal.getTime().after(dashboard.getLoaded()); if (cacheExpired) { logger.info("Dashboard expired, re-rendering"); return null; } else if (cacheInvalid) { logger.info("Dashboard cache invalidated, re-rendering"); return null; } else { return dashboard; } } catch (CacheException ce) { logger.info("Dashboard cache invalidated, re-rendering"); return null; } }
@Test @UsingDataSet(locations = "singleDashboard.json", loadStrategy = LoadStrategyEnum.CLEAN_INSERT) public void testLoad() throws Exception { final String exampleDashboardId = "54e3deadbeefdeadbeefaffe"; final Dashboard dashboard = dashboardService.load(exampleDashboardId); assertNotNull("Dashboard should have been found", dashboard); assertEquals( "Dashboard id should be the one that was retrieved", exampleDashboardId, dashboard.getId()); }
@Test @UsingDataSet(loadStrategy = LoadStrategyEnum.DELETE_ALL) public void testCreate() throws Exception { final String title = "Dashboard Title"; final String description = "This is the dashboard description"; final String creatorUserId = "foobar"; final DateTime createdAt = Tools.nowUTC(); final Dashboard dashboard = dashboardService.create(title, description, creatorUserId, createdAt); assertNotNull(dashboard); assertEquals(title, dashboard.getTitle()); assertEquals(description, dashboard.getDescription()); assertNotNull(dashboard.getId()); assertEquals(0, dashboardService.count()); }
/** Main method that gets the Trabant going. */ public void go() throws InterruptedException { try { dashboard.log("Running ..."); driveDirect(speed, speed); howFarBacked = howFarToGoBackWhenBumped; while (isRunning()) { try { stateController(); } catch (Exception ex) { Logger.getLogger(Trabant.class.getName()).log(Level.SEVERE, null, ex); } } dashboard.log("Run completed."); } catch (ConnectionLostException ex) { Logger.getLogger(Trabant.class.getName()).log(Level.SEVERE, null, ex); } }
/** * This method is called repeatedly * * @throws ConnectionLostException */ public void loop() throws ConnectionLostException { try { sonar.read(); } catch (InterruptedException ex) { } dashboard.log( "L: " + sonar.getLeftDistance() + " F: " + sonar.getFrontDistance() + " R: " + sonar.getRightDistance()); }
private void backingUp(String direction) throws Exception { dashboard.speak("backing up"); if (direction.equals("right")) { driveDirect(-(speed), -(speed / 4)); } if (direction.equals("left")) { driveDirect(-(speed / 4), -(speed)); } if (direction.equals("straight")) { driveDirect(-(speed), -(speed)); } howFarBacked += getDistance(); if (howFarBacked < 0) { driveDirect(speed, speed); howFarBacked = howFarToGoBackWhenBumped; statePointer = 0; presentState = 0; } }
public void addDashboard(Dashboard dashboard) { for (MonitoredResource resource : dashboard.getResource()) { addMonitoredResource(resource); } }
public void initialize() throws ConnectionLostException { dashboard.log("===========Start==========="); readSensors(SENSORS_GROUP_ID6); dashboard.log("Battery Charge = " + getBatteryCharge() + ", 3,000 = Full charge"); }