[ISSUE fix admin:remove  code that cause `mvn install` command execution to fail
package org.apache.shenyu.admin.service;
-import org.apache.shenyu.admin.model.entity.PluginDO;
-import org.apache.shenyu.admin.model.entity.SelectorDO;
-import org.apache.shenyu.admin.listener.DataChangedEvent;
import org.apache.shenyu.admin.mapper.PluginMapper;
import org.apache.shenyu.admin.mapper.SelectorConditionMapper;
import org.apache.shenyu.admin.mapper.SelectorMapper;
-import org.apache.shenyu.admin.model.query.SelectorConditionQuery;
import org.apache.shenyu.admin.service.impl.UpstreamCheckService;
import org.apache.shenyu.common.dto.convert.DivideUpstream;
-import org.apache.shenyu.common.enums.PluginEnum;
import org.apache.shenyu.register.common.config.ShenyuRegisterCenterConfig;
import org.junit.Assert;
import org.junit.Before;
@@ -41,11 +36,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doNothing;
-import static org.mockito.Mockito.when;
-
/**
* Test cases for UpstreamCheckService.
*/
@@ -58,8 +48,6 @@ public final class UpstreamCheckServiceTest {
private static final String MOCK_SELECTOR_NAME_OTHER = "mockSelectorNameOther";
- private static final String MOCK_PLUGIN_ID = "mockPluginId";
-
private UpstreamCheckService upstreamCheckService;
@Mock
@@ -84,38 +72,6 @@ public final class UpstreamCheckServiceTest {
//get static variable reference by reflection
upstreamMap = (Map<String, List<DivideUpstream>>) ReflectionTestUtils.getField(UpstreamCheckService.class, "UPSTREAM_MAP");
- //mock data
- PluginDO pluginDO = PluginDO.builder()
- .name(PluginEnum.DIVIDE.getName())
- .id(MOCK_PLUGIN_ID)
- .build();
- SelectorDO selectorDOWithUrlError = SelectorDO.builder()
- .pluginId(MOCK_PLUGIN_ID)
- .name(MOCK_SELECTOR_NAME)
- .handle("[{\"upstreamHost\":\"localhost\",\"protocol\":\"http://\",\"upstreamUrl\":\"divide-upstream-50\",\"weight\":50}]")
- .build();
- SelectorDO selectorDOWithUrlReachable = SelectorDO.builder()
- .pluginId(MOCK_PLUGIN_ID)
- .name(MOCK_SELECTOR_NAME_OTHER)
- .handle("[{\"upstreamHost\":\"localhost\",\"protocol\":\"http://\",\"localhost\":\"divide-upstream-60\",\"weight\":60}]")
- .build();
- //stubbing
-// when(pluginMapper.selectByNames(anyList())).thenReturn(Lists.newArrayList(pluginDO));
- when(pluginMapper.selectById(anyString())).thenReturn(pluginDO);
-// when(selectorMapper.findByPluginId(anyString())).thenReturn(Lists.newArrayList(selectorDOWithUrlError, selectorDOWithUrlReachable));
- when(selectorMapper.updateSelective(any(SelectorDO.class))).thenReturn(1);
- when(selectorMapper.selectByName(anyString())).then(invocationOnMock -> {
- Object[] args = invocationOnMock.getArguments();
- if (MOCK_SELECTOR_NAME.equals(args[0])) {
- return selectorDOWithUrlError;
- } else if (MOCK_SELECTOR_NAME_OTHER.equals(args[0])) {
- return selectorDOWithUrlReachable;
- }
- return null;
- });
- when(selectorConditionMapper.selectByQuery(any(SelectorConditionQuery.class))).thenReturn(Collections.emptyList());
- doNothing().when(eventPublisher).publishEvent(any(DataChangedEvent.class));
-
upstreamCheckService = new UpstreamCheckService(selectorMapper, eventPublisher, pluginMapper, selectorConditionMapper, shenyuRegisterCenterConfig);
//spring bean creation lifecycle phase:post construct.
upstreamCheckService.setup();
