diff --git a/alerter/src/test/java/org/dromara/hertzbeat/alert/service/AlertDefineServiceTest.java b/alerter/src/test/java/org/dromara/hertzbeat/alert/service/AlertDefineServiceTest.java index 62fe088d482..82b66a8d863 100644 --- a/alerter/src/test/java/org/dromara/hertzbeat/alert/service/AlertDefineServiceTest.java +++ b/alerter/src/test/java/org/dromara/hertzbeat/alert/service/AlertDefineServiceTest.java @@ -13,12 +13,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; +import org.mockito.*; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.domain.Specification; +import org.springframework.test.util.ReflectionTestUtils; import javax.persistence.criteria.CriteriaBuilder; import java.util.*; @@ -42,11 +42,17 @@ class AlertDefineServiceTest { @Mock private AlertDefineBindDao alertDefineBindDao; + @Mock + private List alertDefineImExportServiceList; + @InjectMocks private AlertDefineServiceImpl alertDefineService = new AlertDefineServiceImpl(Collections.emptyList()); @BeforeEach void setUp() { + ReflectionTestUtils.setField(this.alertDefineService, "alertDefineDao", alertDefineDao); + ReflectionTestUtils.setField(this.alertDefineService, "alertDefineBindDao", alertDefineBindDao); + this.alertDefine = AlertDefine.builder() .id(1L) .app("app") @@ -162,7 +168,7 @@ void getAlertDefines() { @Test void getBindAlertDefineMonitors() { - Long id = 1L; + long id = 1L; when(alertDefineBindDao.getAlertDefineBindsByAlertDefineIdEquals(id)).thenReturn(alertDefineMonitorBinds); assertDoesNotThrow(() -> alertDefineService.getBindAlertDefineMonitors(id)); }