/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { if (obj instanceof SubgraphResults) { SubgraphResults that = (SubgraphResults)obj; return getLocation().equals(that.getLocation()) && request.equals(that.request); } else if (obj instanceof Subgraph) { Subgraph that = (Subgraph)obj; if (!getLocation().equals(that.getLocation())) return false; Iterator<SubgraphNode> thisIter = this.iterator(); Iterator<SubgraphNode> thatIter = that.iterator(); while (thisIter.hasNext() && thatIter.hasNext()) { SubgraphNode thisNode = thisIter.next(); SubgraphNode thatNode = thatIter.next(); if (!thisNode.getLocation().equals(thatNode.getLocation())) return false; if (!thisNode.getProperties().equals(thatNode.getProperties())) return false; if (!thisNode.getChildren().equals(thatNode.getChildren())) return false; } if (thisIter.hasNext() || thatIter.hasNext()) return false; return true; } return false; }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentLocations() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation2, workspace1, 20); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithDifferentWorkspaceNames() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, workspace2, 20); assertThat(request.equals(request2), is(false)); }
@Test public void shouldConsiderNotEqualTwoRequestsWithSameLocationsButDifferentMaximumDepths() { request = new ReadBranchRequest(validPathLocation1, workspace1, 20); ReadBranchRequest request2 = new ReadBranchRequest(validPathLocation1, workspace1, 2); assertThat(request.equals(request2), is(false)); }