share-platform/renren-admin/src/test/java/io/renren/ApiGatewayServiceTest.java

54 lines
2.1 KiB
Java
Raw Normal View History

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.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<ResourceEntity> select = new QueryWrapper<ResourceEntity>().lambda()
.select(ResourceEntity::getId)
.eq(ResourceEntity::getType, "组件服务")
.in(ResourceEntity::getApiMethodType, new String[]{"POST", "GET"})
.like(ResourceEntity::getApiUrl,"http%");
List<ResourceEntity> resourceEntities = resourceDao.selectList(select);
resourceEntities.forEach(item -> {
apiGatewayService.registerApi2Gateway(String.valueOf(item.getId()));
});
}
@Test
public void registerCode2Group() {
String code = UUID.randomUUID().toString();
apiGatewayService.subscribeCode("1523913824099762177", code);
}
}