### Question:
FederatedWorkspace { @Override public boolean equals( Object obj ) { if (obj == this) return true; if (obj instanceof FederatedWorkspace) { FederatedWorkspace that = (FederatedWorkspace)obj; if (!this.getSourceName().equals(that.getSourceName())) return false; if (!this.getName().equals(that.getName())) return false; if (!this.getProjections().equals(that.getProjections())) return false; return true; } return false; } FederatedWorkspace( RepositoryContext repositoryContext,
                               String sourceName,
                               String workspaceName,
                               Iterable<Projection> projections,
                               CachePolicy cachePolicy ); RepositoryContext getRepositoryContext(); String getSourceName(); String getName(); CachePolicy getCachePolicy(); Problems getProblems(); List<Projection> getProjections(); boolean contains( String sourceName,
                             String workspaceName ); ProjectedNode project( ExecutionContext context,
                                  Location location,
                                  boolean requiresUpdate ); @Override int hashCode(); @Override boolean equals( Object obj );  }### Answer:
@Test public void shouldConsiderWorkspacesEqualIfSameSourceNameAndSameWorkspaceNameAndSameProjections() { RepositoryContext otherReposContext = mock(RepositoryContext.class); when(otherReposContext.getExecutionContext()).thenReturn(context); CachePolicy otherPolicy = mock(CachePolicy.class); FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, workspaceName, projections, otherPolicy); assertThat(workspace.equals(other), is(true)); }
@Test public void shouldConsiderWorkspacesNotEqualIfDifferentSourceName() { RepositoryContext otherReposContext = mock(RepositoryContext.class); when(otherReposContext.getExecutionContext()).thenReturn(context); CachePolicy otherPolicy = mock(CachePolicy.class); FederatedWorkspace other = new FederatedWorkspace(otherReposContext, "diff", workspaceName, projections, otherPolicy); assertThat(workspace.equals(other), is(false)); }
@Test public void shouldConsiderWorkspacesNotEqualIfDifferentWorkspaceName() { RepositoryContext otherReposContext = mock(RepositoryContext.class); when(otherReposContext.getExecutionContext()).thenReturn(context); CachePolicy otherPolicy = mock(CachePolicy.class); FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, "diff", projections, otherPolicy); assertThat(workspace.equals(other), is(false)); }
@Test public void shouldConsiderWorkspacesNotEqualIfDifferentProjections() { RepositoryContext otherReposContext = mock(RepositoryContext.class); when(otherReposContext.getExecutionContext()).thenReturn(context); CachePolicy otherPolicy = mock(CachePolicy.class); FederatedWorkspace other = new FederatedWorkspace(otherReposContext, sourceName, workspaceName, projections.subList(0, 3), otherPolicy); assertThat(workspace.equals(other), is(false)); }