### Question:
MostSurprising extends AbstractALSResource { @GET @Path("{userID}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) public List<IDValue> get( @PathParam("userID") String userID, @DefaultValue("10") @QueryParam("howMany") int howMany, @DefaultValue("0") @QueryParam("offset") int offset) throws OryxServingException { check(howMany > 0, "howMany must be positive"); check(offset >= 0, "offset must be nonnegative"); ALSServingModel model = getALSServingModel(); float[] userVector = model.getUserVector(userID); checkExists(userVector != null, userID); List<Pair<String,float[]>> knownItemVectors = model.getKnownItemVectorsForUser(userID); if (knownItemVectors == null || knownItemVectors.isEmpty()) { return Collections.emptyList(); } Stream<Pair<String,Double>> idDots = knownItemVectors.stream().map(itemIDVector -> new Pair<>(itemIDVector.getFirst(), VectorMath.dot(userVector, itemIDVector.getSecond()))); return toIDValueResponse(idDots.sorted(Pairs.orderBySecond(Pairs.SortOrder.ASCENDING)), howMany, offset); }  @GET @Path("{userID}") @Produces({MediaType.TEXT_PLAIN, "text/csv", MediaType.APPLICATION_JSON}) List<IDValue> get(
      @PathParam("userID") String userID,
      @DefaultValue("10") @QueryParam("howMany") int howMany,
      @DefaultValue("0") @QueryParam("offset") int offset);  }### Answer:
@Test(expected = NotFoundException.class) public void testNoArg() { target("/mostSurprising").request().get(String.class); }
@Test public void testMostSurprising() { List<IDValue> recs = target("/mostSurprising/U0").request() .accept(MediaType.APPLICATION_JSON_TYPE).get(LIST_ID_VALUE_TYPE); testTopByValue(3, recs, true); Assert.assertEquals("I0", recs.get(0).getID()); Assert.assertEquals(0.38761317555864894, recs.get(0).getValue(), DOUBLE_EPSILON); }
@Test public void testMostSurprisingCSV() { String response = target("/mostSurprising/U0").request().get(String.class); testCSVLeastByScore(3, response); }