本文整理汇总了Java中org.springframework.validation.support.BindingAwareModelMap类的典型用法代码示例。如果您正苦于以下问题:Java BindingAwareModelMap类的具体用法?Java BindingAwareModelMap怎么用?Java BindingAwareModelMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BindingAwareModelMap类属于org.springframework.validation.support包,在下文中一共展示了BindingAwareModelMap类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testUserFrontWithInvalidToken
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(dataProvider="testUserFrontWithInvalidTokenData")
public void testUserFrontWithInvalidToken(String token,String tags, String q, String[] sort, String[] otherTagsExp) {
ParkController controller = new ParkController();
Integer page = Integer.valueOf(1);
Integer size = Integer.valueOf(1);
Boolean asc = Boolean.TRUE;
try {
Model model = new BindingAwareModelMap();
MockHttpSession session = new MockHttpSession();
ReflectionTestUtils.setField(controller, "serverUtils", utils);
Assert.assertEquals("login", controller.userFront(token, q,tags, page, size, asc, sort, model, session));
}catch (CerealException e) {
Assert.fail(e.getMessage());
}
}
开发者ID:Comcast,项目名称:dawg,代码行数:17,代码来源:ParkControllerTest.java
示例2: reserveTicket
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
private String reserveTicket(String eventName) {
ReservationForm reservationForm = new ReservationForm();
MockHttpServletRequest request = new MockHttpServletRequest();
request.setMethod("POST");
ServletWebRequest servletWebRequest = new ServletWebRequest(request);
BindingResult bindingResult = new BeanPropertyBindingResult(reservationForm, "reservation");
Model model = new BindingAwareModelMap();
RedirectAttributes redirectAttributes = new RedirectAttributesModelMap();
TicketReservationModification ticketReservation = new TicketReservationModification();
ticketReservation.setAmount(1);
ticketReservation.setTicketCategoryId(ticketCategoryRepository.findByEventId(event.getId()).stream().findFirst().map(TicketCategory::getId).orElseThrow(IllegalStateException::new));
reservationForm.setReservation(Collections.singletonList(ticketReservation));
return eventController.reserveTicket(eventName, reservationForm, bindingResult, model, servletWebRequest, redirectAttributes, Locale.ENGLISH);
}
开发者ID:alfio-event,项目名称:alf.io,代码行数:17,代码来源:ReservationFlowIntegrationTest.java
示例3: simulateUsersClicking
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@EventListener
public void simulateUsersClicking(ApplicationReadyEvent event) {
Flux
.interval(Duration.ofMillis(500))
.flatMap(tick ->
Mono.defer(() ->
homeController.index(new BindingAwareModelMap())))
.subscribe();
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:10,代码来源:CommentSimulator.java
示例4: invokeHandlerMethod
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
protected ModelAndView invokeHandlerMethod(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
ServletHandlerMethodResolver methodResolver = getMethodResolver(handler);
Method handlerMethod = methodResolver.resolveHandlerMethod(request);
ServletHandlerMethodInvoker methodInvoker = new ServletHandlerMethodInvoker(methodResolver);
ServletWebRequest webRequest = new ServletWebRequest(request, response);
ExtendedModelMap implicitModel = new BindingAwareModelMap();
Object result = methodInvoker.invokeHandlerMethod(handlerMethod, handler, webRequest, implicitModel);
ModelAndView mav =
methodInvoker.getModelAndView(handlerMethod, handler.getClass(), result, implicitModel, webRequest);
methodInvoker.updateModelAttributes(handler, (mav != null ? mav.getModel() : null), implicitModel, webRequest);
return mav;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AnnotationMethodHandlerAdapter.java
示例5: setUp
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
searchController = new SearchController();
facets = new ArrayList<FacetRequest>();
model = new BindingAwareModelMap();
searchableObjectService = EasyMock.createMock(SearchableObjectService.class);
searchController.setSearchableObjectService(searchableObjectService);
page = new DefaultPageImpl<SearchableObject>(0, 0, 20, new ArrayList<SearchableObject>(),null);
facetNames = new String[] {"base.class_s", "taxon.family_ss", "taxon.distribution_TDWG_0_ss", "taxon.measurement_or_fact_threatStatus_txt", "taxon.measurement_or_fact_Lifeform_txt", "taxon.measurement_or_fact_Habitat_txt", "taxon.taxon_rank_s", "taxon.taxonomic_status_s", "searchable.sources_ss" };
}
开发者ID:RBGKew,项目名称:eMonocot,代码行数:11,代码来源:SearchControllerTest.java
示例6: testPopulateWithModel
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testPopulateWithModel() {
PopulateController controller = new PopulateController();
ParkService mockParkService = new MockParkService();
ChimpsToken myToken = new ChimpsToken("mytoken");
mockParkService.saveToken(myToken);
ReflectionTestUtils.setField(controller, "parkService", mockParkService);
Model model = new BindingAwareModelMap();
Assert.assertEquals(controller.populate(model), "populate");
List<ChimpsToken> tokens = (List<ChimpsToken>) model.asMap().get("population");
Assert.assertNotNull(tokens);
Assert.assertTrue(tokens.contains(myToken));
}
开发者ID:Comcast,项目名称:dawg,代码行数:15,代码来源:PopulateControllerTest.java
示例7: testPopulateTable
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@Test
public void testPopulateTable() {
PopulateController controller = new PopulateController();
ParkService mockParkService = new MockParkService();
ReflectionTestUtils.setField(controller, "parkService", mockParkService);
Model model = new BindingAwareModelMap();
Assert.assertEquals(controller.populateTable(model), "populateTable");
Assert.assertNotNull(model.asMap().get("population"));
}
开发者ID:Comcast,项目名称:dawg,代码行数:11,代码来源:PopulateControllerTest.java
示例8: invokeHandlerMethod
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
protected ModelAndView invokeHandlerMethod(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
ServletHandlerMethodResolver methodResolver = getMethodResolver(handler);
Method handlerMethod = methodResolver.resolveHandlerMethod(request);
ServletHandlerMethodInvoker methodInvoker = new ServletHandlerMethodInvoker(
methodResolver);
ServletWebRequest webRequest = new ServletWebRequest(request, response);
ExtendedModelMap implicitModel = new BindingAwareModelMap();
if (this.methodInvokeInterceptors != null
&& !this.methodInvokeInterceptors.isEmpty()) {
for (AnnotationMethodHandlerInterceptor interceptor : this.methodInvokeInterceptors) {
interceptor.preInvoke(handlerMethod, handler, webRequest);
}
}
Object result = methodInvoker.invokeHandlerMethod(handlerMethod,
handler, webRequest, implicitModel);
ModelAndView mav = methodInvoker.getModelAndView(handlerMethod,
handler.getClass(), result, implicitModel, webRequest);
if (this.methodInvokeInterceptors != null
&& !this.methodInvokeInterceptors.isEmpty()) {
for (int i = this.methodInvokeInterceptors.size() - 1; i >= 0; i--) {
this.methodInvokeInterceptors.get(i).postInvoke(handlerMethod,
handler, webRequest, mav);
}
}
methodInvoker.updateModelAttributes(handler,
(mav != null ? mav.getModel() : null), implicitModel,
webRequest);
return mav;
}
开发者ID:xiyelife,项目名称:jresplus,代码行数:36,代码来源:ExtendableAnnotationMethodHandlerAdapter.java
示例9: checkReservationComplete
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
private TicketDecorator checkReservationComplete(String eventName, String reservationIdentifier) {
Model confirmationPageModel = new BindingAwareModelMap();
String confirmationPageSuccess = reservationController.showConfirmationPage(eventName, reservationIdentifier, false, false, confirmationPageModel, Locale.ENGLISH, new MockHttpServletRequest());
assertEquals("/event/reservation-page-complete", confirmationPageSuccess);
@SuppressWarnings("unchecked")
List<Pair<?, List<TicketDecorator>>> tickets = (List<Pair<?, List<TicketDecorator>>>) confirmationPageModel.asMap().get("ticketsByCategory");
assertEquals(1, tickets.size());
assertEquals(1, tickets.get(0).getRight().size());
return tickets.get(0).getRight().get(0);
}
开发者ID:alfio-event,项目名称:alf.io,代码行数:11,代码来源:ReservationFlowIntegrationTest.java
示例10: assignTicket
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
private void assignTicket(String eventName, String reservationIdentifier, String ticketIdentifier, String firstName, String lastName) throws Exception {
UpdateTicketOwnerForm ticketOwnerForm = new UpdateTicketOwnerForm();
ticketOwnerForm.setFirstName(firstName);
ticketOwnerForm.setLastName(lastName);
ticketOwnerForm.setEmail("[email protected]");
ticketOwnerForm.setUserLanguage("en");
Assert.assertTrue(reservationController.assignTicketToPerson(eventName, reservationIdentifier, ticketIdentifier, ticketOwnerForm, Mockito.mock(BindingResult.class), new MockHttpServletRequest(), new BindingAwareModelMap()).endsWith("/success"));
}
开发者ID:alfio-event,项目名称:alf.io,代码行数:9,代码来源:ReservationFlowIntegrationTest.java
示例11: validatePayment
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
private void validatePayment(String eventName, String reservationIdentifier) {
Principal principal = Mockito.mock(Principal.class);
Mockito.when(principal.getName()).thenReturn(user);
assertEquals(1, eventApiController.getPendingPayments(eventName, principal).size());
assertEquals("OK", eventApiController.confirmPayment(eventName, reservationIdentifier, principal, new BindingAwareModelMap(), new MockHttpServletRequest()));
assertEquals(0, eventApiController.getPendingPayments(eventName, principal).size());
}
开发者ID:alfio-event,项目名称:alf.io,代码行数:8,代码来源:ReservationFlowIntegrationTest.java
示例12: payOffline
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
private String payOffline(String eventName, String reservationIdentifier) {
PaymentForm paymentForm = new PaymentForm();
paymentForm.setPaymentMethod(PaymentProxy.OFFLINE);
paymentForm.setEmail("[email protected]");
paymentForm.setBillingAddress("my billing address");
paymentForm.setFirstName("full");
paymentForm.setLastName("name");
paymentForm.setTermAndConditionsAccepted(true);
paymentForm.setPostponeAssignment(true);
BindingResult bindingResult = new BeanPropertyBindingResult(paymentForm, "paymentForm");
Model model = new BindingAwareModelMap();
MockHttpServletRequest request = new MockHttpServletRequest();
RedirectAttributes redirectAttributes = new RedirectAttributesModelMap();
return reservationController.handleReservation(eventName, reservationIdentifier, paymentForm, bindingResult, model, request, Locale.ENGLISH, redirectAttributes);
}
开发者ID:alfio-event,项目名称:alf.io,代码行数:16,代码来源:ReservationFlowIntegrationTest.java
示例13: testRequestMap
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
/**
* RequestMappingHandlerAdapter's default ordering puts MapMethodProcessor ahead of custom Argument Resolvers.
* So we can't actually inject Maps from the context. :(
*/
@Test
public void testRequestMap() throws Exception {
MvcResult result1 = this.mockMvc.perform(get("/requestMap").param("param", "test"))
//.andDo(print())
.andExpect(status().isOk())
.andExpect(model().attribute("param", "test"))
.andExpect(model().attributeExists("map"))
.andReturn();
BindingAwareModelMap map1 = (BindingAwareModelMap) result1.getModelAndView().getModel().get("map");
assertThat((String)map1.get("param"), equalTo("test"));
}
开发者ID:karlkfi,项目名称:spring-mvc-params,代码行数:17,代码来源:ResourceParamControllerTest.java
示例14: simulateUsersClicking
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@Scheduled(fixedRate = 500)
public void simulateUsersClicking() {
homeController.index(
new BindingAwareModelMap(),
null);
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:7,代码来源:CommentSimulator.java
示例15: simulateUsersClicking
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@Scheduled(fixedRate = 500)
public void simulateUsersClicking() {
homeController.index(
new BindingAwareModelMap());
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:6,代码来源:CommentSimulator.java
示例16: postForm
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@PostMapping("/form")
public String postForm(@ModelAttribute Form form) {
Model model = new BindingAwareModelMap();
Context context = new Context();
context.setVariable("name", form.getName());
context.setVariable("url", form.getUrl());
context.setVariable("tags", form.getTags().split(" "));
String text = templateEngine.process("text-template", context);
model.addAttribute("text", text);
return "th-form";
}
开发者ID:bobxwang,项目名称:springboot-scala-withswagger,代码行数:17,代码来源:ThymeleafTextTemplatesController.java
示例17: testUserFrontWithValidToken
import org.springframework.validation.support.BindingAwareModelMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(dataProvider="testUserFrontWithValidTokenData")
public void testUserFrontWithValidToken(String token, String tag,String q, String[] sort, String[] otherTagsExp) {
ParkController controller = new ParkController();
Map<String, Object>[] filteredStbs = new HashMap[1];
Map<String, Object>[] allStbs = new HashMap[2];
Map<String, Object> stb1 = new HashMap<String, Object>();
stb1.put(MetaStb.ID, "sample");
stb1.put(MetaStb.TAGS, Arrays.asList("tag1"));
stb1.put(MetaStb.MACADDRESS, "00:00:00:00:00");
Map<String, Object> stb2 = new HashMap<String, Object>();
stb2.put(MetaStb.ID, "otherDevice");
stb2.put(MetaStb.TAGS, Arrays.asList("tag2", "tag3"));
stb2.put(MetaStb.MACADDRESS, "00:00:00:00:01");
filteredStbs[0] = stb1;
allStbs[0] = stb1;
allStbs[1] = stb2;
ReflectionTestUtils.setField(controller, "serverUtils", utils);
ParkService mockService = EasyMock.createMock(ParkService.class);
if (q == null) {
EasyMock.expect(mockService.findAll((Pageable) EasyMock.anyObject())).andReturn(allStbs);
} else {
EasyMock.expect(mockService.findByKeys((String[]) EasyMock.anyObject(), (Pageable) EasyMock.anyObject())).andReturn(
filteredStbs);
EasyMock.expect(mockService.findAll()).andReturn(allStbs);
}
if (tag != null) {
EasyMock.expect(
mockService.findByCriteria(
(Criteria) EasyMock.anyObject(),
(Pageable) EasyMock.anyObject())).andReturn(
filteredStbs);
}
EasyMock.replay(mockService);
ReflectionTestUtils.setField(controller, "service", mockService);
ReflectionTestUtils.setField(controller, "config", createConfig());
Integer page = Integer.valueOf(1);
Integer size = Integer.valueOf(1);
Boolean asc = Boolean.TRUE;
try {
Model model = new BindingAwareModelMap();
MockHttpSession session = new MockHttpSession();
Assert.assertEquals("index",
controller.userFront(token, tag,q, page, size, asc, sort, model, session));
Assert.assertEquals(model.asMap().get("search"), q == null ? "" : q);
String otherTagsJson = (String) model.asMap().get("otherTags");
String deviceTagsJson = (String) model.asMap().get("deviceTags");
JsonCerealEngine engine = new JsonCerealEngine();
List<String> otherTags = engine.readFromString(otherTagsJson, List.class);
Map<String, List<String>> deviceTags = engine.readFromString(deviceTagsJson, Map.class);
Assert.assertEquals(otherTags.size(), otherTagsExp.length);
for (String tags : otherTagsExp) {
Assert.assertTrue(otherTags.contains(tags));
}
Assert.assertEquals(deviceTags.size(), q != null ? 1 : 2);
Assert.assertTrue(deviceTags.containsKey("sample"));
Assert.assertTrue(deviceTags.get("sample").contains("tag1"));
} catch (CerealException e) {
Assert.fail(e.getMessage());
}
}
开发者ID:Comcast,项目名称:dawg,代码行数:70,代码来源:ParkControllerTest.java
注:本文中的org.springframework.validation.support.BindingAwareModelMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论