@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } ResponseEntity<?> otherEntity = (ResponseEntity<?>) other; return ObjectUtils.nullSafeEquals(this.status, otherEntity.status); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } ResponseEntity<?> otherEntity = (ResponseEntity<?>) other; return ObjectUtils.nullSafeEquals(this.status, otherEntity.status); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } RequestEntity<?> otherEntity = (RequestEntity<?>) other; return (ObjectUtils.nullSafeEquals(getMethod(), otherEntity.getMethod()) && ObjectUtils.nullSafeEquals(getUrl(), otherEntity.getUrl())); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } RequestEntity<?> otherEntity = (RequestEntity<?>) other; return (ObjectUtils.nullSafeEquals(getMethod(), otherEntity.getMethod()) && ObjectUtils.nullSafeEquals(getUrl(), otherEntity.getUrl())); }
@Test public void testEquals() { MultiValueMap<String, String> map1 = new LinkedMultiValueMap<>(); map1.set("Content-Type", "text/plain"); MultiValueMap<String, String> map2 = new LinkedMultiValueMap<>(); map2.set("Content-Type", "application/json"); assertTrue(new HttpEntity<>().equals(new HttpEntity<Object>())); assertFalse(new HttpEntity<>(map1).equals(new HttpEntity<Object>())); assertFalse(new HttpEntity<>().equals(new HttpEntity<Object>(map2))); assertTrue(new HttpEntity<>(map1).equals(new HttpEntity<Object>(map1))); assertFalse(new HttpEntity<>(map1).equals(new HttpEntity<Object>(map2))); assertTrue(new HttpEntity<String>(null, null).equals(new HttpEntity<String>(null, null))); assertFalse(new HttpEntity<>("foo", null).equals(new HttpEntity<String>(null, null))); assertFalse(new HttpEntity<String>(null, null).equals(new HttpEntity<>("bar", null))); assertTrue(new HttpEntity<>("foo", map1).equals(new HttpEntity<String>("foo", map1))); assertFalse(new HttpEntity<>("foo", map1).equals(new HttpEntity<String>("bar", map1))); }
@Test public void requestEntity() throws Exception { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); String body = "foo"; HttpEntity<String> httpEntity = new HttpEntity<>(body, headers); RequestEntity<String> requestEntity = new RequestEntity<>(body, headers, HttpMethod.GET, new URI("/")); RequestEntity<String> requestEntity2 = new RequestEntity<>(body, headers, HttpMethod.GET, new URI("/")); assertEquals(body, requestEntity.getBody()); assertEquals(MediaType.TEXT_PLAIN, requestEntity.getHeaders().getContentType()); assertEquals("text/plain", requestEntity.getHeaders().getFirst("Content-Type")); assertEquals("text/plain", requestEntity.getHeaders().getFirst("Content-Type")); assertFalse(httpEntity.equals(requestEntity)); assertFalse(requestEntity.equals(httpEntity)); assertTrue(requestEntity.equals(requestEntity2)); assertTrue(requestEntity2.equals(requestEntity)); }
@Test public void responseEntity() { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.TEXT_PLAIN); String body = "foo"; HttpEntity<String> httpEntity = new HttpEntity<>(body, headers); ResponseEntity<String> responseEntity = new ResponseEntity<>(body, headers, HttpStatus.OK); ResponseEntity<String> responseEntity2 = new ResponseEntity<>(body, headers, HttpStatus.OK); assertEquals(body, responseEntity.getBody()); assertEquals(MediaType.TEXT_PLAIN, responseEntity.getHeaders().getContentType()); assertEquals("text/plain", responseEntity.getHeaders().getFirst("Content-Type")); assertEquals("text/plain", responseEntity.getHeaders().getFirst("Content-Type")); assertFalse(httpEntity.equals(responseEntity)); assertFalse(responseEntity.equals(httpEntity)); assertTrue(responseEntity.equals(responseEntity2)); assertTrue(responseEntity2.equals(responseEntity)); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } ResponseEntity<?> otherEntity = (ResponseEntity<?>) other; return ObjectUtils.nullSafeEquals(this.status, otherEntity.status); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } ResponseEntity<?> otherEntity = (ResponseEntity<?>) other; return ObjectUtils.nullSafeEquals(this.status, otherEntity.status); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } RequestEntity<?> otherEntity = (RequestEntity<?>) other; return (ObjectUtils.nullSafeEquals(getMethod(), otherEntity.getMethod()) && ObjectUtils.nullSafeEquals(getUrl(), otherEntity.getUrl())); }
@Override public boolean equals(@Nullable Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } RequestEntity<?> otherEntity = (RequestEntity<?>) other; return (ObjectUtils.nullSafeEquals(getMethod(), otherEntity.getMethod()) && ObjectUtils.nullSafeEquals(getUrl(), otherEntity.getUrl())); }
@Override public boolean equals(Object other) { if (this == other) { return true; } if (!super.equals(other)) { return false; } RequestEntity<?> otherEntity = (RequestEntity<?>) other; return (ObjectUtils.nullSafeEquals(getMethod(), otherEntity.getMethod()) && ObjectUtils.nullSafeEquals(getUrl(), otherEntity.getUrl())); }