當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。