88import httpserver .response .Response ;
99import org .junit .Test ;
1010
11+ import java .io .OutputStream ;
1112import java .nio .file .Path ;
1213
13- import static junit .framework . TestCase .*;
14+ import static org . junit .Assert .*;
1415import static org .mockito .Mockito .*;
1516
1617public class PostResponderTest {
@@ -47,7 +48,9 @@ public void overwritesFileWithDataIfHandlesAndExists() throws Exception {
4748 assertEquals (200 , response .getStatusCode ());
4849 verify (fileOperatorMock ).replaceContents (fullPathMock , "data=example" .getBytes ());
4950 verify (fileOperatorMock ).readContents (fullPathMock );
50- assertEquals (fileContentsMock , response .getPayload ());
51+ OutputStream outputStreamMock = mock (OutputStream .class );
52+ response .writePayload (outputStreamMock );
53+ verify (outputStreamMock ).write (fileContentsMock );
5154 }
5255
5356 @ Test
@@ -64,7 +67,9 @@ public void createsFileWithDataIfHandlesButDoesntExist() throws Exception {
6467 verify (fileOperatorMock ).createFileAtPath (fullPathMock );
6568 verify (fileOperatorMock ).replaceContents (fullPathMock , "data=example" .getBytes ());
6669 verify (fileOperatorMock ).readContents (fullPathMock );
67- assertEquals (fileContentsMock , response .getPayload ());
70+ OutputStream outputStreamMock = mock (OutputStream .class );
71+ response .writePayload (outputStreamMock );
72+ verify (outputStreamMock ).write (fileContentsMock );
6873 }
6974
7075 @ Test
0 commit comments