Search in sources :

Example 1 with MealWithExceed

use of ru.javawebinar.topjava.to.MealWithExceed in project topjava10 by JavaWebinar.

the class SpringMain method main.

public static void main(String[] args) {
    // java 7 Automatic resource management
    try (GenericXmlApplicationContext appCtx = new GenericXmlApplicationContext()) {
        appCtx.getEnvironment().setActiveProfiles(Profiles.getActiveDbProfile(), Profiles.REPOSITORY_IMPLEMENTATION);
        appCtx.load("spring/spring-app.xml", "spring/mock.xml");
        appCtx.refresh();
        mockAuthorize(USER);
        System.out.println("Bean definition names: " + Arrays.toString(appCtx.getBeanDefinitionNames()));
        AdminRestController adminUserController = appCtx.getBean(AdminRestController.class);
        adminUserController.create(new User(null, "userName", "email", "password", 1500, Role.ROLE_ADMIN));
        System.out.println();
        MealRestController mealController = appCtx.getBean(MealRestController.class);
        List<MealWithExceed> filteredMealsWithExceeded = mealController.getBetween(LocalDate.of(2015, Month.MAY, 30), LocalTime.of(7, 0), LocalDate.of(2015, Month.MAY, 31), LocalTime.of(11, 0));
        filteredMealsWithExceeded.forEach(System.out::println);
    }
}
Also used : User(ru.javawebinar.topjava.model.User) MealRestController(ru.javawebinar.topjava.web.meal.MealRestController) AdminRestController(ru.javawebinar.topjava.web.user.AdminRestController) MealWithExceed(ru.javawebinar.topjava.to.MealWithExceed) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext)

Aggregations

GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)1 User (ru.javawebinar.topjava.model.User)1 MealWithExceed (ru.javawebinar.topjava.to.MealWithExceed)1 MealRestController (ru.javawebinar.topjava.web.meal.MealRestController)1 AdminRestController (ru.javawebinar.topjava.web.user.AdminRestController)1