@Test public void noMatch() { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); RequestMethodsRequestCondition rm = new RequestMethodsRequestCondition(RequestMethod.POST); RequestConditionHolder custom = new RequestConditionHolder(rm); assertNull(custom.getMatchingCondition(request)); }
@Test public void match() { MockHttpServletRequest request = new MockHttpServletRequest("GET", "/"); request.setParameter("name1", "value1"); RequestMethodsRequestCondition rm = new RequestMethodsRequestCondition(RequestMethod.GET, RequestMethod.POST); RequestConditionHolder custom = new RequestConditionHolder(rm); RequestMethodsRequestCondition expected = new RequestMethodsRequestCondition(RequestMethod.GET); assertEquals(expected, custom.getMatchingCondition(request).getCondition()); }
@Test public void matchEmpty() { RequestConditionHolder empty = new RequestConditionHolder(null); assertSame(empty, empty.getMatchingCondition(new MockHttpServletRequest())); }