Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mae-consumer): fix aspect retriever injections mae-consumer #10125

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.linkedin.metadata.kafka;

import com.linkedin.metadata.aspect.AspectRetriever;
import com.linkedin.metadata.search.EntitySearchService;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MaeConsumerConfig {

@Autowired
@Qualifier("cachingAspectRetriever")
private AspectRetriever aspectRetriever;

@Autowired private EntitySearchService entitySearchService;

@PostConstruct
protected void postConstruct() {
entitySearchService.postConstruct(aspectRetriever);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

import static org.testng.AssertJUnit.*;

import com.linkedin.metadata.aspect.AspectRetriever;
import com.linkedin.metadata.entity.EntityService;
import com.linkedin.metadata.search.EntitySearchService;
import com.linkedin.metadata.search.elasticsearch.query.ESSearchDAO;
import com.linkedin.metadata.service.FormService;
import io.datahubproject.metadata.jobs.common.health.kafka.KafkaHealthIndicator;
import org.apache.commons.lang3.reflect.FieldUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
Expand All @@ -22,10 +26,20 @@ public class MaeConsumerApplicationTest extends AbstractTestNGSpringContextTests

@Autowired private FormService formService;

@Autowired private EntitySearchService entitySearchService;

@Test
public void testMaeConsumerAutoWiring() {
assertNotNull(mockEntityService);
assertNotNull(kafkaHealthIndicator);
assertNotNull(formService);
}

@Test
public void testPostConstruct() throws IllegalAccessException {
ESSearchDAO test = (ESSearchDAO) FieldUtils.readField(entitySearchService, "esSearchDAO", true);
AspectRetriever aspectRetriever =
(AspectRetriever) FieldUtils.readField(test, "aspectRetriever", true);
assertNotNull(aspectRetriever);
}
}
Loading