Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. @Service
  2. public class FooJob extends BaseJob {
  3. @Autowired private SomeDepA depA;
  4. }
  5.  
  6. import org.elasticsearch.client.RestHighLevelClient;
  7. public abstract class BaseJob implements Job {
  8. @Autowired private RestHighLevelClient client;
  9. }
  10.  
  11. @RunWith(SpringRunner.class)
  12. public class FooJobTest {
  13. @Mock SomeDepA depA;
  14. @Mock RestHighLevelClient client;
  15. @InjectMocks
  16. private FooJob job;
  17.  
  18. @Before
  19. public void setUp() throws Exception {
  20. //do stuff
  21. }
  22.  
  23. @Test
  24. public void fooTest() throws Exception {
  25. job.execute(null);
  26. }
  27. }
  28.  
  29. public class RestHighLevelClient implements Closeable {
  30. private final RestClient client;
  31. private final IndicesClient indicesClient = new IndicesClient(this);
  32. ...
  33. public RestHighLevelClient(RestClientBuilder restClientBuilder) {
  34. this(restClientBuilder, Collections.emptyList());
  35. }
  36. ...
  37. }
  38.  
  39. public final class IndicesClient {
  40. private final RestHighLevelClient restHighLevelClient;
  41.  
  42. IndicesClient(RestHighLevelClient restHighLevelClient) {
  43. this.restHighLevelClient = restHighLevelClient;
  44. }
  45. ...
  46. }
  47.  
  48. @Before
  49. public void setUp() throws Exception {
  50. final HttpHost host = new HttpHost("foo");
  51. RestClientBuilder builder = RestClient.builder(host);
  52. client = new RestHighLevelClient(restClientBuilder);
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement