Package com.softserve.academy.food.model

Examples of com.softserve.academy.food.model.CategoryModel


    @Transactional
    public CategoryModel get(int id) {
        if (categoryDao.get(id) != null) {
            return categoryDao.get(id).toModel();
        }
        return new CategoryModel();
    }
View Full Code Here


        id = category.getId();
        name = category.getName();
    }

    public CategoryModel toModel() {
        return new CategoryModel(this);
    }
View Full Code Here

    }

    @RequestMapping(value = "/category/{id}", method = RequestMethod.GET)
    protected String category(@PathVariable int id, Model model) {
        ArrayList<String> names = new ArrayList<String>();
        CategoryModel mod = categoryService.get(id);
        names.add(mod.toString());
        model.addAttribute("helloMessage", names);
        return "helloPage";
    }
View Full Code Here

    //ctegory by id
    @RequestMapping(value = "/android/cat/{id}")
    @ResponseBody
    public CategoryModel getCategoryById(@PathVariable int id) {
        CategoryModel category = categoryService.get(id);
        return category;
    }
View Full Code Here

    // dishes by ctegory
    @RequestMapping(value = "/android/dish/category/{id}")
    @ResponseBody
    public ArrayList<DishModel> getAllDishesByCategory(@PathVariable int id) {
        CategoryModel category = categoryService.get(id);
        ArrayList<DishModel> allDishesByCategory = menuService.getAllDishesForCategory(category);
        return allDishesByCategory;
    }
View Full Code Here

  }

  @Test
  public void testGetEmpty()
  {
    assertEquals( cService.get(1), new CategoryModel() );
  }
View Full Code Here

  }

  @Test
  public void testAddEmpty()
  {
    cService.add( new CategoryModel("Dessert") );
   
    assertFalse( categoryDao.getAll().isEmpty() );
    assertEquals( categoryDao.get(1).getName(), "Dessert" );
  }
View Full Code Here

  @Test
  public void testAdd()
  {
    categoryDao.add( new Category("Dessert") );
   
    cService.add( new CategoryModel("Fist dish") );
   
    assertEquals( categoryDao.get(2).getName(), "Fist dish" );
  }
View Full Code Here

  }
 
  @Test
  public void getAllCategoryEmpty()
  {
    CategoryModel category = new CategoryModel("Dessert");
   
    assertTrue( mService.getAllDishesForCategory(category).isEmpty() );
  }
View Full Code Here

  }
 
  @Test
  public void getAllCategory()
  {
    CategoryModel category = new CategoryModel("Dessert");
    Dish dish = new Dish( "IceCream", new Category("Dessert") );
    dishDao.add( dish );
   
    assertFalse( mService.getAllDishesForCategory(category).isEmpty() );
    assertEquals(mService.getAllDishesForCategory(category).get(0).getCategory().getName(), "Dessert");
View Full Code Here

TOP

Related Classes of com.softserve.academy.food.model.CategoryModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.