ResponseObject { public byte[] getContent() { return content != null ? Arrays.copyOf(content, content.length) : null; } ResponseObject(Map<String, List<String>> headers, byte[] content); Map<String, List<String>> getHeaders(); byte[] getContent();  }
@Test public void getContent_NullUsedInConstructor_Null() throws Exception { responseObject = new ResponseObject(new HashMap<String, List<String>>(), null); assertTrue(responseObject.getContent() == null); }
@Test public void getContent_ByteArrayUsedInConstructor_ArraysAreDifferentObjects() throws Exception { assertFalse(responseObject.getContent() == byteArray); byte[] responseArray = responseObject.getContent(); byteArray = "other".getBytes(); assertFalse(Arrays.equals(responseArray, byteArray)); }
@Test public void constructor_ByteArrayUsedInConstructorWasChanged_ContentOfArraysAreDifferent() throws Exception { byteArray = "other".getBytes(); byte[] responseArray = responseObject.getContent(); assertFalse(Arrays.equals(responseArray, byteArray)); }
@Test public void getContent_ByteArrayUsedInConstructor_ContentOfArraysAreEqual() throws Exception { assertTrue(Arrays.equals(responseObject.getContent(), byteArray)); }