@SuppressWarnings("unchecked") @Test public void testModelsConfig() { StbModelController controller = new StbModelController(); controller.service = new MockParkService(); DawgModel model1 = createModel("DCT6412", "MAC_G", "HD", "DVR"); DawgModel model2 = createModel("DCT6416", "MAC_G", "HD", "DVR", "VOD"); DawgModel model3 = createModel("SA2200", "MAC_S"); controller.service.upsertModel(model1, model2, model3); ModelAndView mav = controller.models(); List<DawgModel> models = (List<DawgModel>) mav.getModelMap().get("models"); Set<String> caps = (Set<String>) mav.getModelMap().get("capabilities"); Set<String> fams = (Set<String>) mav.getModelMap().get("families"); Assert.assertEquals(models.size(), 3); Assert.assertEquals(caps.size(), 3); Assert.assertEquals(fams.size(), 2); Assert.assertTrue(caps.contains("HD")); Assert.assertTrue(caps.contains("DVR")); Assert.assertTrue(caps.contains("VOD")); Assert.assertTrue(fams.contains("MAC_G")); Assert.assertTrue(fams.contains("MAC_S")); }
@RequestMapping("/modelsConfig") public ModelAndView models() { List<DawgModel> models = service.getModels(); Set<String> caps = new HashSet<String>(); Set<String> families = new HashSet<String>(); for (DawgModel model : models) { caps.addAll(model.getCapabilities()); families.add(model.getFamily()); } ModelAndView dataModel = new ModelAndView("models"); dataModel.addObject("models", models); dataModel.addObject("capabilities", caps); dataModel.addObject("families", families); return dataModel; }
StbModelController { @RequestMapping("/modelsConfig") public ModelAndView models() { List<DawgModel> models = service.getModels(); Set<String> caps = new HashSet<String>(); Set<String> families = new HashSet<String>(); for (DawgModel model : models) { caps.addAll(model.getCapabilities()); families.add(model.getFamily()); } ModelAndView dataModel = new ModelAndView("models"); dataModel.addObject("models", models); dataModel.addObject("capabilities", caps); dataModel.addObject("families", families); return dataModel; } }
StbModelController { @RequestMapping("/modelsConfig") public ModelAndView models() { List<DawgModel> models = service.getModels(); Set<String> caps = new HashSet<String>(); Set<String> families = new HashSet<String>(); for (DawgModel model : models) { caps.addAll(model.getCapabilities()); families.add(model.getFamily()); } ModelAndView dataModel = new ModelAndView("models"); dataModel.addObject("models", models); dataModel.addObject("capabilities", caps); dataModel.addObject("families", families); return dataModel; }  }
StbModelController { @RequestMapping("/modelsConfig") public ModelAndView models() { List<DawgModel> models = service.getModels(); Set<String> caps = new HashSet<String>(); Set<String> families = new HashSet<String>(); for (DawgModel model : models) { caps.addAll(model.getCapabilities()); families.add(model.getFamily()); } ModelAndView dataModel = new ModelAndView("models"); dataModel.addObject("models", models); dataModel.addObject("capabilities", caps); dataModel.addObject("families", families); return dataModel; }  @RequestMapping(value="models", method=RequestMethod.GET) @ResponseBody List<DawgModel> getModels(@RequestParam String[] id); @RequestMapping(value="models/{id}", method=RequestMethod.POST) @ResponseBody boolean addModel(@RequestBody DawgModel newModel, @PathVariable String id); @RequestMapping(value="models/{id}", method=RequestMethod.DELETE) @ResponseBody boolean deleteModel(@PathVariable String id); @RequestMapping("/modelsConfig") ModelAndView models(); @RequestMapping("/assignmodels") ModelAndView assignModels(); void applyModels(Map<String, Object>[] stbs, List<DawgModel> models); }
StbModelController { @RequestMapping("/modelsConfig") public ModelAndView models() { List<DawgModel> models = service.getModels(); Set<String> caps = new HashSet<String>(); Set<String> families = new HashSet<String>(); for (DawgModel model : models) { caps.addAll(model.getCapabilities()); families.add(model.getFamily()); } ModelAndView dataModel = new ModelAndView("models"); dataModel.addObject("models", models); dataModel.addObject("capabilities", caps); dataModel.addObject("families", families); return dataModel; }  @RequestMapping(value="models", method=RequestMethod.GET) @ResponseBody List<DawgModel> getModels(@RequestParam String[] id); @RequestMapping(value="models/{id}", method=RequestMethod.POST) @ResponseBody boolean addModel(@RequestBody DawgModel newModel, @PathVariable String id); @RequestMapping(value="models/{id}", method=RequestMethod.DELETE) @ResponseBody boolean deleteModel(@PathVariable String id); @RequestMapping("/modelsConfig") ModelAndView models(); @RequestMapping("/assignmodels") ModelAndView assignModels(); void applyModels(Map<String, Object>[] stbs, List<DawgModel> models);  }