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


Java LocalTime.MIDNIGHT属性代码示例

本文整理汇总了Java中org.joda.time.LocalTime.MIDNIGHT属性的典型用法代码示例。如果您正苦于以下问题:Java LocalTime.MIDNIGHT属性的具体用法?Java LocalTime.MIDNIGHT怎么用?Java LocalTime.MIDNIGHT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.joda.time.LocalTime的用法示例。


在下文中一共展示了LocalTime.MIDNIGHT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFoodsPutOk

@Test
@WithMockAuth(id="1")
public void testFoodsPutOk() throws Exception {
    Food mockFoodOk = new Food(10, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, newLastEdit("01/01/2017 00:00:00"), false);
   
    Settings global_settings = new Settings(1, LocalTime.MIDNIGHT,  DateTime.now(), "", "", "", "", 0, 1,"","");
    
    given(mockFoodRepository.findById(10)).willReturn(mockFoodOk);
    given(settingsRepo.findOne(1)).willReturn(global_settings);
    
    mockMvc.perform(put("/api/foods/{id}",10).content(
    "{\n" +
    "  \"foodName\": \"string\",\n" +
    "  \"foodType\": \"Drink\",\n" +
    "  \"description\": \"string\",\n" +
    "  \"price\": 10,\n" +
    "  \"standard\": \"false\",\n" +
    "  \"lastEdit\": {\n" +
    "    \"timeStamp\": \"2017-01-01T00:00:00.000Z\"\n" +
    "  }\n" +
    "}"
    ).contentType(MediaType.APPLICATION_JSON_UTF8))
        .andExpect(status().isNoContent())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8));
    
    
    verify(mockFoodRepository, times(1)).findById(10);
    assertEquals(mockFoodOk, mockFoodRepository.findById(10) );
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:29,代码来源:FoodsApiControllerTest.java

示例2: testFoodsPostOk

@Test
@WithMockAuth(id="1")
public void testFoodsPostOk() throws Exception {
    
    Food mockFoodOk = new Food(0, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, null, true);         
    Settings global_settings = new Settings(1, LocalTime.MIDNIGHT,  DateTime.now(), "", "", "", "", 0, 1, "", "");
    
    
    given(settingsRepo.findOne(1)).willReturn(global_settings); 
    given(mockFoodRepository.findByNameAndArchived(mockFoodOk.getName(), false)).willReturn(null);
    
    mockMvc.perform(post("/api/foods").content(
    "{\n" +
    "  \"foodName\": \""+mockFoodOk.getName()+"\",\n" +
    "  \"foodType\": \""+foodType.convertToDatabaseColumn(mockFoodOk.getFoodType())+"\",\n" +
    "  \"description\": \""+mockFoodOk.getDescription()+"\",\n" +
    "  \"standard\": \""+mockFoodOk.isStandard()+"\",\n" +
    "  \"price\": "+mockFoodOk.getPrice()+"\n" +
   
    "}"
    ).contentType(MediaType.APPLICATION_JSON_UTF8))
        .andExpect(status().isNoContent());
    
    
    verify(mockFoodRepository, times(1)).findByNameAndArchived(mockFoodOk.getName(), false);
    verify(mockFoodRepository, times(1)).save(mockFoodOk);
    verifyNoMoreInteractions(mockFoodRepository);
 
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:29,代码来源:FoodsApiControllerTest.java

示例3: testFoodsGetOk

@Test
@WithMockAuth(id="1")
public void testFoodsGetOk() throws Exception {
    
    Food mockFoodOk = new Food(10, "Pastitsio", new ArrayList<>(), FoodType.MAIN, "test Pastitsio", new BigDecimal("5.65"), false, null, false);
    Food mockFoodOk2 = new Food(11, "Pastitsio2", new ArrayList<>(), FoodType.MAIN, "test Pastitsio2", new BigDecimal("5.65"), false, null, false);
    // Mock List of Foods
    List<Food> mockFoodList = new ArrayList<>();
    // Adding an ok mock Food instance
    mockFoodList.add(mockFoodOk);
    mockFoodList.add(mockFoodOk2);
    
    Settings global_settings = new Settings(1, LocalTime.MIDNIGHT,  DateTime.now(), "", "", "", "", 0, 1, "", "");
    given(settingsRepo.findOne(1)).willReturn(global_settings);
    
    // telling Mockito to use this mock list every time the findAll method is called on the foodRepo
    given(mockFoodRepository.findAll()).willReturn(mockFoodList);
    given(mockFoodRepository.count()).willReturn(2L);
    
    Pageable pr = new PageRequest(1, 2 , Sort.Direction.DESC, "id" );
    Page<Food> pageofFood = new PageImpl<>(mockFoodList);
    
    given(mockFoodRepository.findAll(pr)).willReturn(pageofFood);
        
    // telling mockito there is one user in the database, with id 1
    // this step is specially needed if you use the User of the token in your controller.
    // in this case, use the annotation @WithMockAuth(id="1")
    given(mockUserRepository.findById(1L)).willReturn(new User());

    // We perform the API call, and check that the response status code, and the JSON response are corrects
    mockMvc.perform(get("/api/foods?stats=&size=2&page=1")).andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) 
            .andExpect(jsonPath("$.totalElements", is(2)))
            .andExpect(jsonPath("$.foods[0].foodItem.id", is(10)))
            .andExpect(jsonPath("$.foods[0].foodItem.foodName", is("Pastitsio"))) 
            .andExpect(jsonPath("$.foods[1].foodItem.id", is(11)))
            .andExpect(jsonPath("$.foods[1].foodItem.foodName", is("Pastitsio2")));
    
    // we verify that we called findAll method once only on the repo.
    verify(mockFoodRepository, times(1)).findAll(pr);
    verify(mockFoodRepository, times(1)).count();
    // we verify that we didnt call anything else on the repo
    verifyNoMoreInteractions(mockFoodRepository);
    // we verify that we didnt modify the first food item in the repository
    assertEquals(mockFoodOk, mockFoodRepository.findAll().iterator().next());
}
 
开发者ID:jrtechnologies,项目名称:yum,代码行数:46,代码来源:FoodsApiControllerTest.java


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