{"action":"created","issue":{"url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/34","labels_url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/34/comments","events_url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/34/events","html_url":"https://github.com/aerospike/aerospike-client-java/issues/34","id":85286139,"number":34,"title":"Cannot mock query results","user":{"login":"daniel-siegmann-aol","id":4664577,"avatar_url":"https://avatars.githubusercontent.com/u/4664577?v=3","gravatar_id":"","url":"https://api.github.com/users/daniel-siegmann-aol","html_url":"https://github.com/daniel-siegmann-aol","followers_url":"https://api.github.com/users/daniel-siegmann-aol/followers","following_url":"https://api.github.com/users/daniel-siegmann-aol/following{/other_user}","gists_url":"https://api.github.com/users/daniel-siegmann-aol/gists{/gist_id}","starred_url":"https://api.github.com/users/daniel-siegmann-aol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/daniel-siegmann-aol/subscriptions","organizations_url":"https://api.github.com/users/daniel-siegmann-aol/orgs","repos_url":"https://api.github.com/users/daniel-siegmann-aol/repos","events_url":"https://api.github.com/users/daniel-siegmann-aol/events{/privacy}","received_events_url":"https://api.github.com/users/daniel-siegmann-aol/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-06-04T21:30:18Z","updated_at":"2015-12-21T22:48:45Z","closed_at":null,"body":"I am trying to write unit tests for some code of mine which is calling `AerospikeClient.queryAggregate`. I have mocked the `AerospikeClient` via the `IAerospikeClient` interface using Mockito. So far, so good.\r\n\r\nWhere I run into trouble is that I cannot mock the result. Mockito cannot mock `ResultSet` because that class is final. Its dependency, `QueryAggregateExecutor` is also final, which would lead me to mock `Cluster`. That is possible, but leads down a very complicated rabbit hole.\r\n\r\n`RecordSet` might be more practical to mock since it depends on a `QueryExecutor`, which is the abstract parent class. However, many of `QueryExecutor`'s method are final, so it may still be difficult.\r\n\r\nI think the most expedient solution would be to make `RecordSet` and `ResultSet` non-final. I understand making classes final is good practice, but I believe making the code mock-able so it can be unit tested is considerably more valuable. I am certainly open to other suggestions.\r\n\r\nBy the way, the `ExecutionTask` returned from `AerospikeClient.execute` has a similar problem, so you may wish to apply the same solution. I was able to work around that case like so:\r\n\r\n```java\r\nExecuteTask task = client.execute(...); // When client is a mock, will return null\r\nif (task != null) task.waitTillComplete();\r\n```"},"comment":{"url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/comments/166445238","html_url":"https://github.com/aerospike/aerospike-client-java/issues/34#issuecomment-166445238","issue_url":"https://api.github.com/repos/aerospike/aerospike-client-java/issues/34","id":166445238,"user":{"login":"maverickgautam","id":9612985,"avatar_url":"https://avatars.githubusercontent.com/u/9612985?v=3","gravatar_id":"","url":"https://api.github.com/users/maverickgautam","html_url":"https://github.com/maverickgautam","followers_url":"https://api.github.com/users/maverickgautam/followers","following_url":"https://api.github.com/users/maverickgautam/following{/other_user}","gists_url":"https://api.github.com/users/maverickgautam/gists{/gist_id}","starred_url":"https://api.github.com/users/maverickgautam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maverickgautam/subscriptions","organizations_url":"https://api.github.com/users/maverickgautam/orgs","repos_url":"https://api.github.com/users/maverickgautam/repos","events_url":"https://api.github.com/users/maverickgautam/events{/privacy}","received_events_url":"https://api.github.com/users/maverickgautam/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T22:48:45Z","updated_at":"2015-12-21T22:48:45Z","body":"https://github.com/maverickgautam/Aerospike-unit/\r\n\r\nThis is a Java wrapper over actual Aerospike Server which can be used for unit + Integration Testing . \r\nPom is having some issue i am fixing it ASAP , please let me know if you want to use i can do it urgently . Reachable at kunal.gautham@gmail.com"}}