### Question:
DefaultQueryCollection implements QueryCollection { @Override public Set<QueryContext> getQueries() { return Sets.newHashSet(queries); } DefaultQueryCollection();  DefaultQueryCollection(@NonNull final Set<QueryContext> queries);  DefaultQueryCollection(final TreeSet<QueryContext> treeSet); @Override boolean add(final QueryContext query); @Override boolean addAll(final Set<QueryContext> queries); @Override boolean remove(final QueryContext query); @Override boolean removeAll(Set<QueryContext> queries); @Override Set<QueryContext> getQueries(); @Override Set<QueryContext> getQueries(final String user); @Override int getQueriesCount(); @Override Integer getQueryIndex(QueryContext query);  }### Answer:
@Test public void testGetQueriesPerUserMustReturnCopyOfUnderlyingCollection() { final int noOfQueriesUsedInTest = 2; QueryCollection queries = createQueriesInstanceWithUserStubbing(noOfQueriesUsedInTest, MOCK_USER); Set<QueryContext> copiedSet = queries.getQueries(MOCK_USER); copiedSet.clear(); assertEquals(queries.getQueries(MOCK_USER).size(), noOfQueriesUsedInTest); }