### Question:
ALSUpdate extends MLUpdate<String> { static Rating decayRating(Rating rating, long timestamp, long now, double factor) { if (timestamp >= now) { return rating; } double days = (now - timestamp) / 86400000.0; return new Rating(rating.user(), rating.product(), rating.rating() * Math.pow(factor, days)); } ALSUpdate(Config config); @Override List<HyperParamValues<?>> getHyperParameterValues(); @Override PMML buildModel(JavaSparkContext sparkContext,
                         JavaRDD<String> trainData,
                         List<?> hyperParameters,
                         Path candidatePath); @Override double evaluate(JavaSparkContext sparkContext,
                         PMML model,
                         Path modelParentPath,
                         JavaRDD<String> testData,
                         JavaRDD<String> trainData); @Override boolean canPublishAdditionalModelData(); @Override void publishAdditionalModelData(JavaSparkContext sparkContext,
                                         PMML pmml,
                                         JavaRDD<String> newData,
                                         JavaRDD<String> pastData,
                                         Path modelParentPath,
                                         TopicProducer<String, String> modelUpdateTopic);  }### Answer:
@Test public void testDecay() { Rating rating = new Rating(1, 2, 3.0); long timestamp = 10_000_000L; Rating noDecay = ALSUpdate.decayRating(rating, timestamp, timestamp, 0.5); assertEquals(1, noDecay.user()); assertEquals(2, noDecay.product()); assertEquals(3.0, noDecay.rating()); Rating dayDecay = ALSUpdate.decayRating(rating, timestamp, timestamp + 86_400_000L, 0.5); assertEquals(1, dayDecay.user()); assertEquals(2, dayDecay.product()); assertEquals(1.5, dayDecay.rating()); }