### Question:
Handler implements RequestStreamHandler { @Override public void handleRequest(InputStream is, OutputStream os, Context context) throws IOException { LambdaLogger logger = context.getLogger(); String input = Utils.toString(is); try { Request request = GSON.fromJson(input, Request.class); String url = request.getInputImageUrl(); String artifactId = request.getArtifactId(); Map<String, String> filters = request.getFilters(); Criteria<Image, Classifications> criteria = Criteria.builder() .setTypes(Image.class, Classifications.class) .optArtifactId(artifactId) .optFilters(filters) .build(); try (ZooModel<Image, Classifications> model = ModelZoo.loadModel(criteria); Predictor<Image, Classifications> predictor = model.newPredictor()) { Image image = ImageFactory.getInstance().fromUrl(url); List<Classifications.Classification> result = predictor.predict(image).topK(5); os.write(GSON.toJson(result).getBytes(StandardCharsets.UTF_8)); } } catch (RuntimeException | ModelException | TranslateException e) { logger.log("Failed handle input: " + input); logger.log(e.toString()); String msg = "{\"status\": \"invoke failed: " + e.toString() + "\"}"; os.write(msg.getBytes(StandardCharsets.UTF_8)); } }  @Override void handleRequest(InputStream is, OutputStream os, Context context);  }### Answer:
@Test public void invokeTest() throws IOException { Context context = new MockContext(); Handler handler = new Handler(); Request request = new Request(); request.setInputImageUrl("https: Gson gson = new Gson(); byte[] buf = gson.toJson(request).getBytes(StandardCharsets.UTF_8); InputStream is = new ByteArrayInputStream(buf); ByteArrayOutputStream os = new ByteArrayOutputStream(); handler.handleRequest(is, os, context); String result = os.toString(StandardCharsets.UTF_8.name()); Type type = new TypeToken<List<Classifications.Classification>>() {}.getType(); List<Classifications.Classification> list = gson.fromJson(result, type); Assert.assertNotNull(list); Assert.assertEquals(list.get(0).getClassName(), "n02123045 tabby, tabby cat"); }