@Test public void testViewLabel() throws Exception { Image dog = new Image(ViewImagesController.getPublicUrl(BUCKET, "obj1"), "dog"); mvc.perform(get("/label/dog")).andExpect(model().attribute("images", contains(dog))); }
@RequestMapping("/label/{label}") public String viewLabel(@PathVariable("label") String label, Model model) throws IOException { List<StorageObject> objects = cuteImageService.listAll(); List<Image> images = new ArrayList<>(); for (StorageObject obj : objects) { Image image = new Image(getPublicUrl(cuteImageService.getBucketName(), obj.getName()), obj.getMetadata().get("label")); if (image.label.equals(label)) { images.add(image); } } model.addAttribute("images", images); return "index"; }
ViewImagesController { @RequestMapping("/label/{label}") public String viewLabel(@PathVariable("label") String label, Model model) throws IOException { List<StorageObject> objects = cuteImageService.listAll(); List<Image> images = new ArrayList<>(); for (StorageObject obj : objects) { Image image = new Image(getPublicUrl(cuteImageService.getBucketName(), obj.getName()), obj.getMetadata().get("label")); if (image.label.equals(label)) { images.add(image); } } model.addAttribute("images", images); return "index"; } }
ViewImagesController { @RequestMapping("/label/{label}") public String viewLabel(@PathVariable("label") String label, Model model) throws IOException { List<StorageObject> objects = cuteImageService.listAll(); List<Image> images = new ArrayList<>(); for (StorageObject obj : objects) { Image image = new Image(getPublicUrl(cuteImageService.getBucketName(), obj.getName()), obj.getMetadata().get("label")); if (image.label.equals(label)) { images.add(image); } } model.addAttribute("images", images); return "index"; }  }
ViewImagesController { @RequestMapping("/label/{label}") public String viewLabel(@PathVariable("label") String label, Model model) throws IOException { List<StorageObject> objects = cuteImageService.listAll(); List<Image> images = new ArrayList<>(); for (StorageObject obj : objects) { Image image = new Image(getPublicUrl(cuteImageService.getBucketName(), obj.getName()), obj.getMetadata().get("label")); if (image.label.equals(label)) { images.add(image); } } model.addAttribute("images", images); return "index"; }  @RequestMapping("/") String view(Model model); @RequestMapping("/label/{label}") String viewLabel(@PathVariable("label") String label, Model model); }
ViewImagesController { @RequestMapping("/label/{label}") public String viewLabel(@PathVariable("label") String label, Model model) throws IOException { List<StorageObject> objects = cuteImageService.listAll(); List<Image> images = new ArrayList<>(); for (StorageObject obj : objects) { Image image = new Image(getPublicUrl(cuteImageService.getBucketName(), obj.getName()), obj.getMetadata().get("label")); if (image.label.equals(label)) { images.add(image); } } model.addAttribute("images", images); return "index"; }  @RequestMapping("/") String view(Model model); @RequestMapping("/label/{label}") String viewLabel(@PathVariable("label") String label, Model model);  }