### Question:
ResultDescriptor implements Serializable { public ResultDescriptor datasource(String metricName, AggregationFunction aggregationFunction) { return datasource(metricName, metricName, aggregationFunction); } ResultDescriptor();  ResultDescriptor(long step);  ResultDescriptor(Duration step); Duration getInterval(); Map<String, Datasource> getDatasources(); Map<String, Calculation> getCalculations(); Set<String> getSourceNames(); Set<String> getLabels(); Set<String> getExports(); ResultDescriptor step(long step); ResultDescriptor step(Duration step); ResultDescriptor datasource(String metricName, AggregationFunction aggregationFunction); ResultDescriptor datasource(String name, String metricName, AggregationFunction aggregationFunction); ResultDescriptor datasource(String name, String metricName, long heartbeat, AggregationFunction aggregationFunction); ResultDescriptor datasource(String name, String metricName, Duration heartbeat, AggregationFunction aggregationFunction); ResultDescriptor datasource(String name, String metricName, Duration heartbeat, double xff, AggregationFunction aggregationFunction); ResultDescriptor export(String... names); ResultDescriptor calculate(Calculation calculation); ResultDescriptor calculate(String label, CalculationFunction calculationFunction, String... args); ResultDescriptor calculate(String label, final BinaryFunction binaryFunction, String arg1, String arg2); ResultDescriptor calculate(String label, final UnaryFunction unaryFunction, String arg); ResultDescriptor expression(String label, String expression); @Override String toString(); static final int DEFAULT_STEP; static final int DEFAULT_HEARTBEAT_MULTIPLIER; static final double DEFAULT_XFF; }### Answer:
@Test(expected = IllegalArgumentException.class) public void testInvalidHeartbeat() { new ResultDescriptor(Duration.seconds(300)).datasource("in", "in", Duration.seconds(100), null); }
@Test public void testDatasource() { ResultDescriptor descriptor; Datasource dataSource; descriptor = new ResultDescriptor().datasource("ifInOctets", AVERAGE); dataSource = descriptor.getDatasources().get("ifInOctets"); assertEquals("ifInOctets", dataSource.getLabel()); assertEquals("ifInOctets", dataSource.getSource()); int heatbeat = ResultDescriptor.DEFAULT_HEARTBEAT_MULTIPLIER * ResultDescriptor.DEFAULT_STEP; assertEquals(heatbeat, dataSource.getHeartbeat().asMillis()); descriptor = new ResultDescriptor(); dataSource = descriptor.datasource("in", "ifInOctets", AVERAGE).getDatasources().get("in"); assertEquals("in", dataSource.getLabel()); assertEquals("ifInOctets", dataSource.getSource()); descriptor = new ResultDescriptor(); dataSource = descriptor.datasource("in", "ifInOctets", 900000, AVERAGE).getDatasources().get("in"); assertEquals("in", dataSource.getLabel()); assertEquals("ifInOctets", dataSource.getSource()); assertEquals(900, dataSource.getHeartbeat().asSeconds()); assertEquals(1, descriptor.getDatasources().size()); assertEquals("in", descriptor.getLabels().iterator().next()); }