List of usage examples for org.springframework.restdocs.operation.preprocess PrettyPrintingContentModifier PrettyPrintingContentModifier
PrettyPrintingContentModifier
From source file:org.springframework.restdocs.operation.preprocess.PrettyPrintingContentModifierTests.java
@Test public void prettyPrintJson() throws Exception { assertThat(new PrettyPrintingContentModifier().modifyContent("{\"a\":5}".getBytes(), null), equalTo(String.format("{%n \"a\" : 5%n}").getBytes())); }
From source file:org.springframework.restdocs.operation.preprocess.PrettyPrintingContentModifierTests.java
@Test public void prettyPrintXml() throws Exception { assertThat(/*from w w w . j a v a 2 s . co m*/ new PrettyPrintingContentModifier() .modifyContent("<one a=\"alpha\"><two b=\"bravo\"/></one>".getBytes(), null), equalTo(String.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n" + "<one a=\"alpha\">%n <two b=\"bravo\"/>%n</one>%n").getBytes())); }
From source file:org.springframework.restdocs.operation.preprocess.PrettyPrintingContentModifierTests.java
@Test public void empytContentIsHandledGracefully() throws Exception { assertThat(new PrettyPrintingContentModifier().modifyContent("".getBytes(), null), equalTo("".getBytes())); }
From source file:org.springframework.restdocs.operation.preprocess.PrettyPrintingContentModifierTests.java
@Test public void nonJsonAndNonXmlContentIsHandledGracefully() throws Exception { String content = "abcdefg"; this.outputCapture.expect(isEmptyString()); assertThat(new PrettyPrintingContentModifier().modifyContent(content.getBytes(), null), equalTo(content.getBytes())); }
From source file:org.springframework.restdocs.operation.preprocess.PrettyPrintingContentModifierTests.java
@Test public void encodingIsPreserved() throws Exception { Map<String, String> input = new HashMap<>(); input.put("japanese", "\u30b3\u30f3\u30c6\u30f3\u30c4"); ObjectMapper objectMapper = new ObjectMapper(); @SuppressWarnings("unchecked") Map<String, String> output = objectMapper.readValue( new PrettyPrintingContentModifier().modifyContent(objectMapper.writeValueAsBytes(input), null), Map.class); assertThat(output, is(equalTo(input))); }