### Question:
CoreTokenAdapter { public Collection<PartialToken> attributeQuery(final TokenFilter filter) throws CoreTokenException, IllegalArgumentException { ResultHandler<Collection<PartialToken>, CoreTokenException> handler = handlerFactory.getPartialQueryHandler(); try { attributeQueryWithHandler(filter, handler); Collection<PartialToken> partialTokens = handler.getResults(); Collection<PartialToken> results = new ArrayList<PartialToken>(); if (filter.getReturnFields().contains(CoreTokenField.BLOB)) { for (PartialToken p : partialTokens) { try { byte[] value = p.getValue(CoreTokenField.BLOB); results.add(new PartialToken(p, CoreTokenField.BLOB, strategy.reverse(value))); } catch (TokenStrategyFailedException e) { throw new CoreTokenException("Failed to reverse Blob strategy", e); } } } else { results = partialTokens; } debug("AttributeQuery: returned {0} Partial Tokens: {1}", results.size(), filter); return results; } catch (CoreTokenException e) { throw new QueryFailedException(filter, e); } } @Inject  CoreTokenAdapter(TokenBlobStrategy strategy, TaskDispatcher dispatcher, ResultHandlerFactory handlerFactory,
                            CTSReaperInit reaperInit, @Named(CoreTokenConstants.CTS_DEBUG) Debug debug); ResultHandler<Token, CoreTokenException> create(Token token); Token read(String tokenId); ResultHandler<Token, CoreTokenException> updateOrCreate(Token token); ResultHandler<String, CoreTokenException> delete(String tokenId); Collection<Token> query(final TokenFilter tokenFilter); Collection<PartialToken> attributeQuery(final TokenFilter filter); void deleteOnQuery(final TokenFilter filter);  }### Answer:
@Test (expectedExceptions = IllegalArgumentException.class) public void shouldPreventAttributeQueryWhenReturnAttributesAreNotDefined() throws CoreTokenException { adapter.attributeQuery(new TokenFilterBuilder().and().build()); }
@Test public void shouldUseTaskQueueForAttributeQuery() throws CoreTokenException { Collection<PartialToken> partialTokens = new ArrayList<PartialToken>(); ResultHandler<Collection<PartialToken>, CoreTokenException> mockResultHandler = mock(ResultHandler.class); given(mockResultHandler.getResults()).willReturn(partialTokens); given(mockResultHandlerFactory.getPartialQueryHandler()).willReturn(mockResultHandler); TokenFilter filter = new TokenFilterBuilder().returnAttribute(CoreTokenField.BLOB).build(); adapter.attributeQuery(filter); verify(mockTaskDispatcher).partialQuery(eq(filter), eq(mockResultHandler)); }