@Test public void getMatchingCondition() throws Exception { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml"); ConsumesRequestCondition result = condition.getMatchingCondition(exchange); assertConditions(result, "text/plain"); condition = new ConsumesRequestCondition("application/xml"); result = condition.getMatchingCondition(exchange); assertNull(result); }
@Test public void consumesParseError() throws Exception { MockServerWebExchange exchange = postExchange("01"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); assertNull(condition.getMatchingCondition(exchange)); }
@Test public void parseConsumesAndHeaders() throws Exception { String[] consumes = new String[] {"text/plain"}; String[] headers = new String[]{"foo=bar", "content-type=application/xml,application/pdf"}; ConsumesRequestCondition condition = new ConsumesRequestCondition(consumes, headers); assertConditions(condition, "text/plain", "application/xml", "application/pdf"); }
@Test public void negatedConsumesMatch() throws Exception { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain"); assertNull(condition.getMatchingCondition(exchange)); }
@Test public void consumesWildcardMatch() throws Exception { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/*"); assertNotNull(condition.getMatchingCondition(exchange)); }
@Test public void consumesParseErrorWithNegation() throws Exception { MockServerWebExchange exchange = postExchange("01"); ConsumesRequestCondition condition = new ConsumesRequestCondition("!text/plain"); assertNull(condition.getMatchingCondition(exchange)); }
@Test public void consumesMatch() throws Exception { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); assertNotNull(condition.getMatchingCondition(exchange)); }
@Test public void consumesMultipleMatch() throws Exception { MockServerWebExchange exchange = postExchange("text/plain"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain", "application/xml"); assertNotNull(condition.getMatchingCondition(exchange)); }
@Test public void consumesSingleNoMatch() throws Exception { MockServerWebExchange exchange = postExchange("application/xml"); ConsumesRequestCondition condition = new ConsumesRequestCondition("text/plain"); assertNull(condition.getMatchingCondition(exchange)); }