当前位置: 首页>>代码示例>>Java>>正文


Java Restaurant类代码示例

本文整理汇总了Java中com.packtpub.mmj.restaurant.domain.model.entity.Restaurant的典型用法代码示例。如果您正苦于以下问题:Java Restaurant类的具体用法?Java Restaurant怎么用?Java Restaurant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Restaurant类属于com.packtpub.mmj.restaurant.domain.model.entity包,在下文中一共展示了Restaurant类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findByName

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 * Fetch restaurants with the specified name. A partial case-insensitive
 * match is supported. So <code>http://.../restaurants/rest</code> will find
 * any restaurants with upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of restaurants.
 */
@HystrixCommand(fallbackMethod = "defaultRestaurants")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Restaurant>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("restaurant-service findByName() invoked:{} for {} ", restaurantService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<Restaurant> restaurants;
    try {
        restaurants = restaurantService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurants.size() > 0 ? new ResponseEntity<>(restaurants, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:24,代码来源:RestaurantController.java

示例2: findByName

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 * Fetch restaurants with the specified name. A partial case-insensitive
 * match is supported. So <code>http://.../restaurants/rest</code> will find
 * any restaurants with upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of restaurants.
 */
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Restaurant>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("restaurant-service findByName() invoked:{} for {} ", restaurantService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<Restaurant> restaurants;
    try {
        restaurants = restaurantService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurants.size() > 0 ? new ResponseEntity<>(restaurants, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:RestaurantController.java

示例3: add

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 * Add restaurant with the specified information.
 *
 * @param restaurantVO
 * @return A non-null restaurant.
 */
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Restaurant> add(@RequestBody RestaurantVO restaurantVO) {
    logger.info(String.format("restaurant-service add() invoked: %s for %s", restaurantService.getClass().getName(), restaurantVO.getName()));
    System.out.println(restaurantVO);
    Restaurant restaurant = new Restaurant(null, null, null, null);
    BeanUtils.copyProperties(restaurantVO, restaurant);
    try {
        restaurantService.add(restaurant);
    } catch (Exception ex) {
        logger.log(Level.WARNING, "Exception raised add Restaurant REST Call {0}", ex);
        return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:21,代码来源:RestaurantController.java

示例4: validResturantByName

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 * Test method for findByName method
 */
@Test
public void validResturantByName() {
    Logger.getGlobal().info("Start validResturantByName test");
    ResponseEntity<Collection<Restaurant>> restaurants = restaurantController.findByName(RESTAURANT_NAME);
    Logger.getGlobal().info("In validAccount test");

    Assert.assertEquals(HttpStatus.OK, restaurants.getStatusCode());
    Assert.assertTrue(restaurants.hasBody());
    Assert.assertNotNull(restaurants.getBody());
    Assert.assertFalse(restaurants.getBody().isEmpty());
    Restaurant restaurant = (Restaurant) restaurants.getBody().toArray()[0];
    Assert.assertEquals(RESTAURANT, restaurant.getId());
    Assert.assertEquals(RESTAURANT_NAME, restaurant.getName());
    Logger.getGlobal().info("End validResturantByName test");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:19,代码来源:AbstractRestaurantControllerTests.java

示例5: update

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 *
 * @param entity
 */
@Override
public void update(Restaurant entity) {
    if (entities.containsKey(entity.getId())) {
        entities.put(entity.getId(), entity);
    }
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:11,代码来源:InMemRestaurantRepository.java

示例6: findByName

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 *
 * @param name
 * @return
 * @throws Exception
 */
@Override
public Collection<Restaurant> findByName(String name) throws Exception {
    Collection<Restaurant> restaurants = new ArrayList();
    int noOfChars = name.length();
    entities.forEach((k, v) -> {
        if (v.getName().toLowerCase().contains(name.subSequence(0, noOfChars))) {
            restaurants.add(v);
        }
    });
    return restaurants;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:18,代码来源:InMemRestaurantRepository.java

示例7: add

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
@Override
public void add(Restaurant restaurant) throws Exception {
    if (restaurantRepository.containsName(restaurant.getName())) {
        throw new Exception(String.format("There is already a product with the name - %s", restaurant.getName()));
    }

    if (restaurant.getName() == null || "".equals(restaurant.getName())) {
        throw new Exception("Restaurant name cannot be null or empty string.");
    }
    super.add(restaurant);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:12,代码来源:RestaurantServiceImpl.java

示例8: validAdd

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 * Test method for add method
 */
@Test
public void validAdd() {
    Logger.getGlobal().info("Start validAdd test");
    RestaurantVO restaurant = new RestaurantVO();
    restaurant.setId("999");
    restaurant.setName("Test Restaurant");

    ResponseEntity<Restaurant> restaurants = restaurantController.add(restaurant);
    Assert.assertEquals(HttpStatus.CREATED, restaurants.getStatusCode());
    Logger.getGlobal().info("End validAdd test");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:15,代码来源:AbstractRestaurantControllerTests.java

示例9: findByName

import com.packtpub.mmj.restaurant.domain.model.entity.Restaurant; //导入依赖的package包/类
/**
 *
 * @param name
 * @return
 * @throws Exception
 */
@Override
public Collection<Restaurant> findByName(String name) throws Exception {
    Collection<Restaurant> restaurants = new ArrayList();
    int noOfChars = name.length();
    entities.forEach((k, v) -> {
        if (v.getName().toLowerCase().contains(name.toLowerCase().subSequence(0, noOfChars))) {
            restaurants.add(v);
        }
    });
    return restaurants;
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:18,代码来源:InMemRestaurantRepository.java


注:本文中的com.packtpub.mmj.restaurant.domain.model.entity.Restaurant类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。