### Question:
Estimate extends AbstractALSResource { @GET @Path("{userID}/{itemID : .+}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) public List<Double> get(@PathParam("userID") String userID, @PathParam("itemID") List<PathSegment> pathSegmentsList) throws OryxServingException { ALSServingModel model = getALSServingModel(); float[] userFeatures = model.getUserVector(userID); checkExists(userFeatures != null, userID); return pathSegmentsList.stream().map(pathSegment -> { float[] itemFeatures = model.getItemVector(pathSegment.getPath()); if (itemFeatures == null) { return 0.0; } else { double value = VectorMath.dot(itemFeatures, userFeatures); Preconditions.checkState(!(Double.isInfinite(value) || Double.isNaN(value)), "Bad estimate"); return value; } }).collect(Collectors.toList()); }  @GET @Path("{userID}/{itemID : .+}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) List<Double> get(@PathParam("userID") String userID,
                          @PathParam("itemID") List<PathSegment> pathSegmentsList);  }### Answer:
@Test public void testEstimate() { List<Double> items = target("estimate/U0/I0/I1/I2").request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_DOUBLE_TYPE); Assert.assertEquals(3, items.size()); Assert.assertEquals(0.38761318f, items.get(0), FLOAT_EPSILON); Assert.assertEquals(0.4653969f, items.get(1), FLOAT_EPSILON); Assert.assertEquals(-0.0801478f, items.get(2), FLOAT_EPSILON); }
@Test public void testEstimateCSV() { String response = target("estimate/U0/I0/I1/I2").request().get(String.class); testCSVScores(3, response); }
@Test(expected = NotFoundException.class) public void testBadRequest() { target("/estimate/Z").request().get(String.class); }
@Test public void testZeroEstimate() { List<Double> items = target("/estimate/U0/I10").request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_DOUBLE_TYPE); Assert.assertEquals(1, items.size()); Assert.assertEquals(0.0f, items.get(0), FLOAT_EPSILON); }