SQLDelightReportsToReportsMapper extends Mapper<SQLDelightReports, Reports> { @Override public Reports map(SQLDelightReports sqlDelightReports) { if (sqlDelightReports.getReports().size() == 0) { return null; } List<String> reportsIds = mapReportsIds(sqlDelightReports.getReports()); List<SQLDelightMetric> metrics = sqlDelightReports.getMetrics(); if (metrics.isEmpty()) { return new Reports(reportsIds); } String firstMetricName = metrics.get(0).metric_name(); String appPackage = getAppPackage(firstMetricName); String uuid = getUUID(firstMetricName); String deviceModel = getDeviceModel(firstMetricName); String screenDensity = getScreenDensity(firstMetricName); String screenSize = getScreenSize(firstMetricName); int numberOfCores = getNumberOfCores(firstMetricName); List<NetworkMetric> networkMetrics = mapNetworkMetrics(sqlDelightReports); List<UIMetric> uiMetrics = mapUIMetrics(sqlDelightReports); List<CPUMetric> cpuMetrics = mapCPUMetrics(sqlDelightReports); List<MemoryMetric> memoryMetrics = mapMemoryMetrics(sqlDelightReports); List<DiskMetric> diskMetrics = mapDiskMetrics(sqlDelightReports); return new Reports(reportsIds, appPackage, uuid, deviceModel, screenDensity, screenSize, numberOfCores, networkMetrics, uiMetrics, cpuMetrics, memoryMetrics, diskMetrics); }  @Override Reports map(SQLDelightReports sqlDelightReports);  }
@Test public void doesNotSendReportIfCPUMetricHasNoValue() { SQLDelightReports sqlDelightReports = getSqlDelightReports("cpuUsage"); Reports mappedReports = mapper.map(sqlDelightReports); assertEquals(0, mappedReports.getCpuMetrics().size()); }
@Test public void doesNotSendReportIfMemoryMetricHasNoValue() { SQLDelightReports sqlDelightReports = getSqlDelightReports("memoryUsage"); Reports mappedReports = mapper.map(sqlDelightReports); assertEquals(0, mappedReports.getMemoryMetrics().size()); }
@Test public void doesNotSendReportIfNetworkMetricHasNoValue() { SQLDelightReports sqlDelightReports = getSqlDelightReports("bytesUploaded"); Reports mappedReports = mapper.map(sqlDelightReports); assertEquals(0, mappedReports.getNetworkMetrics().size()); }
@Test public void doesNotSendReportIfDiskMetricHasNoValue() { SQLDelightReports sqlDelightReports = getSqlDelightReports("bytesUploaded"); Reports mappedReports = mapper.map(sqlDelightReports); assertEquals(0, mappedReports.getDiskMetrics().size()); }