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

This commit is contained in:
david-leifker 2024-03-25 16:15:29 -05:00 committed by GitHub
parent eb2278ccfd
commit f726135673
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -2,9 +2,13 @@ package com.linkedin.metadata.kafka;
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;
@ -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);
}
}