@Test public void get() { LOG.info("\n===UserDaoTest.get===\n"); User user = ESSuiteTest.userDao.get(ESSuiteTest.USER_1); LOG.info("User is: {}", user.toString()); assertEquals("password", user.getPassword()); }
public User get( String username ) { SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( termQuery( "_id", username ) ) .execute() .actionGet(); SearchHit hits[] = response.getHits().hits(); return hits.length > 0 ? toUser( hits[ 0 ] ) : null; }
UserDao extends Dao { public User get( String username ) { SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( termQuery( "_id", username ) ) .execute() .actionGet(); SearchHit hits[] = response.getHits().hits(); return hits.length > 0 ? toUser( hits[ 0 ] ) : null; } }
UserDao extends Dao { public User get( String username ) { SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( termQuery( "_id", username ) ) .execute() .actionGet(); SearchHit hits[] = response.getHits().hits(); return hits.length > 0 ? toUser( hits[ 0 ] ) : null; } @Inject  UserDao( IElasticSearchClient elasticSearchClient ); }
UserDao extends Dao { public User get( String username ) { SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( termQuery( "_id", username ) ) .execute() .actionGet(); SearchHit hits[] = response.getHits().hits(); return hits.length > 0 ? toUser( hits[ 0 ] ) : null; } @Inject  UserDao( IElasticSearchClient elasticSearchClient ); boolean save( User user ); User get( String username ); List<User> getList(); boolean delete( String username ); }
UserDao extends Dao { public User get( String username ) { SearchResponse response = elasticSearchClient.getClient() .prepareSearch( DAO_INDEX_KEY ) .setTypes( DAO_TYPE_KEY ) .setQuery( termQuery( "_id", username ) ) .execute() .actionGet(); SearchHit hits[] = response.getHits().hits(); return hits.length > 0 ? toUser( hits[ 0 ] ) : null; } @Inject  UserDao( IElasticSearchClient elasticSearchClient ); boolean save( User user ); User get( String username ); List<User> getList(); boolean delete( String username ); static final String DAO_INDEX_KEY; static final String DAO_TYPE_KEY; }