package io.renren; import cn.hutool.core.lang.UUID; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.renren.common.redis.RedisUtils; import io.renren.modules.processForm.service.ApiGatewayService; import io.renren.modules.resource.dao.ResourceDao; import io.renren.modules.resource.entity.ResourceEntity; import io.renren.modules.sys.entity.SysUserEntity; import org.apache.commons.lang3.builder.ToStringBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; import java.util.List; @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ApiGatewayServiceTest { @Autowired private ApiGatewayService apiGatewayService; @Autowired private ResourceDao resourceDao; @Test public void registerApi2Gateway() { // String[] resourceIds = {"1522550194833530884","1522550194535735298","1522550194544123906"}; // for (String resourceId : resourceIds) { // apiGatewayService.registerApi2Gateway(resourceId); // } LambdaQueryWrapper select = new QueryWrapper().lambda() .select(ResourceEntity::getId) .eq(ResourceEntity::getType, "组件服务") .in(ResourceEntity::getApiMethodType, new String[]{"POST", "GET"}) .like(ResourceEntity::getApiUrl,"http%"); List resourceEntities = resourceDao.selectList(select); resourceEntities.forEach(item -> { String id = String.valueOf(item.getId()); apiGatewayService.resetApiGroup(id); apiGatewayService.deleteGroup(id); apiGatewayService.registerApi2Gateway(id); }); } @Test public void registerAPI(){ String id = "1522550194544123907"; apiGatewayService.resetApiGroup(id); try{ apiGatewayService.deleteGroup(id); }catch (Exception e){ e.printStackTrace(); } apiGatewayService.registerApi2Gateway(id); } @Test public void registerCode2Group() { String code = UUID.randomUUID().toString(); apiGatewayService.subscribeCode("1522756586483789825", code); System.out.println(code); } }