Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Service
- public class FooJob extends BaseJob {
- @Autowired private SomeDepA depA;
- }
- import org.elasticsearch.client.RestHighLevelClient;
- public abstract class BaseJob implements Job {
- @Autowired private RestHighLevelClient client;
- }
- @RunWith(SpringRunner.class)
- public class FooJobTest {
- @Mock SomeDepA depA;
- @Mock RestHighLevelClient client;
- @InjectMocks
- private FooJob job;
- @Before
- public void setUp() throws Exception {
- //do stuff
- }
- @Test
- public void fooTest() throws Exception {
- job.execute(null);
- }
- }
- public class RestHighLevelClient implements Closeable {
- private final RestClient client;
- private final IndicesClient indicesClient = new IndicesClient(this);
- ...
- public RestHighLevelClient(RestClientBuilder restClientBuilder) {
- this(restClientBuilder, Collections.emptyList());
- }
- ...
- }
- public final class IndicesClient {
- private final RestHighLevelClient restHighLevelClient;
- IndicesClient(RestHighLevelClient restHighLevelClient) {
- this.restHighLevelClient = restHighLevelClient;
- }
- ...
- }
- @Before
- public void setUp() throws Exception {
- final HttpHost host = new HttpHost("foo");
- RestClientBuilder builder = RestClient.builder(host);
- client = new RestHighLevelClient(restClientBuilder);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement