### Question:
ProductCategoryUsageTrajectory { public double amountAtTime(double time) { Pair<Double, Double> previous = null; for(Pair<Double, Double> entry : trajectory) { if(entry.getKey() > time) break; previous = entry; } if(previous == null) return 0.0; return previous.getValue(); } ProductCategoryUsageTrajectory(double initialTime, double initialAmount); void append(double time, double amount); double getLastAmount(); double getLastTime(); double amountAtTime(double time); Pair<Double, Double> getStep(int idx); int size();  }### Answer:
@Test public void testAmountAtTime() { ProductCategoryUsageTrajectory trajectory = new ProductCategoryUsageTrajectory(0.0, 30.0); trajectory.append(1.0, 25.0); trajectory.append(2.0, 20.0); trajectory.append(3.0, 50.0); trajectory.append(4.0, 40.0); trajectory.append(4.0, 50.0); trajectory.append(5.0, 30.0); assertEquals(30.0, trajectory.amountAtTime(0.5), 0.0001); assertEquals(50.0, trajectory.amountAtTime(4.0), 0.0001); assertEquals(30.0, trajectory.amountAtTime(10.0), 0.0001); }