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

68 lines
2.3 KiB
Java

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.modules.processForm.service.ApiGateway;
import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.entity.ResourceEntity;
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 javax.annotation.Resource;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class ApiGatewayServiceTest {
@Resource(name = "${hisense.gateway.name}")
private ApiGateway apiGateway;
@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 -> {
String id = String.valueOf(item.getId());
apiGateway.resetApiGroup(id);
apiGateway.registerApi2Gateway(id);
});
}
@Test
public void registerAPI() {
String id = "1522550194544123907";
apiGateway.resetApiGroup(id);
apiGateway.registerApi2Gateway(id);
}
@Test
public void registerCode2Group() {
String code = UUID.randomUUID().toString();
apiGateway.subscribeCode("1522756586483789825", code);
System.out.println(code);
}
@Test
public void ssss() {
System.err.println("ssssss");
}
}