Skip to content

Commit

Permalink
Alert tests fix (#1501)
Browse files Browse the repository at this point in the history
Signed-off-by: tomsun28 <tomsun28@outlook.com>
Co-authored-by: yqxxgh <1135131038@qq.com>
Co-authored-by: yqxxgh <42080876+yqxxgh@users.noreply.github.com>
Co-authored-by: tomsun28 <tomsun28@outlook.com>
  • Loading branch information
4 people authored Jan 20, 2024
1 parent ac7a404 commit d3c1929
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -42,11 +42,17 @@ class AlertDefineServiceTest {
@Mock
private AlertDefineBindDao alertDefineBindDao;

@Mock
private List<AlertDefineImExportService> 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")
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit d3c1929

Please sign in to comment.