@@ -98,6 +98,58 @@ void newLineIndent() throws IOException {
9898 assertThat (output .toString (), equalTo (String .format ("__%n__Good%n__ morning,%n__ Dave%n" )));
9999 }
100100
101+ @ Test
102+ void unwrapEscapedQuotes_withNullInput_shouldWriteNothing () throws IOException {
103+ final BoatSpringCodeGen .UnwrapEscapedQuotes lambda = new BoatSpringCodeGen .UnwrapEscapedQuotes ();
104+ final StringWriter output = new StringWriter ();
105+ final Fragment frag = mock (Fragment .class );
106+
107+ when (frag .execute ()).thenReturn (null );
108+
109+ lambda .execute (frag , output );
110+
111+ assertThat (output .toString (), equalTo ("" ));
112+ }
113+
114+ @ Test
115+ void unwrapEscapedQuotes_withWrappedEscapedQuotes_shouldRemoveOuterEscapedQuotes () throws IOException {
116+ final BoatSpringCodeGen .UnwrapEscapedQuotes lambda = new BoatSpringCodeGen .UnwrapEscapedQuotes ();
117+ final StringWriter output = new StringWriter ();
118+ final Fragment frag = mock (Fragment .class );
119+
120+ when (frag .execute ()).thenReturn ("\\ \" {\\ \" message\\ \" :\\ \" Bad Request\\ \" }\\ \" " );
121+
122+ lambda .execute (frag , output );
123+
124+ assertThat (output .toString (), equalTo ("{\\ \" message\\ \" :\\ \" Bad Request\\ \" }" ));
125+ }
126+
127+ @ Test
128+ void unwrapEscapedQuotes_withDoubleEscapedQuotesAndNoWrapper_shouldOnlyNormalize () throws IOException {
129+ final BoatSpringCodeGen .UnwrapEscapedQuotes lambda = new BoatSpringCodeGen .UnwrapEscapedQuotes ();
130+ final StringWriter output = new StringWriter ();
131+ final Fragment frag = mock (Fragment .class );
132+
133+ when (frag .execute ()).thenReturn ("prefix\\ \\ \" quoted\\ \\ \" suffix" );
134+
135+ lambda .execute (frag , output );
136+
137+ assertThat (output .toString (), equalTo ("prefix\\ \" quoted\\ \" suffix" ));
138+ }
139+
140+ @ Test
141+ void unwrapEscapedQuotes_withShortEscapedQuoteToken_shouldNotUnwrap () throws IOException {
142+ final BoatSpringCodeGen .UnwrapEscapedQuotes lambda = new BoatSpringCodeGen .UnwrapEscapedQuotes ();
143+ final StringWriter output = new StringWriter ();
144+ final Fragment frag = mock (Fragment .class );
145+
146+ when (frag .execute ()).thenReturn ("\\ \" " );
147+
148+ lambda .execute (frag , output );
149+
150+ assertThat (output .toString (), equalTo ("\\ \" " ));
151+ }
152+
101153 @ Test
102154 void addServletRequestTestFromOperation (){
103155 final BoatSpringCodeGen gen = new BoatSpringCodeGen ();
0 commit comments