|
|
|
package cn.teammodel;
|
|
|
|
|
|
|
|
import cn.teammodel.dao.EvaluationTreeRepository;
|
|
|
|
import cn.teammodel.dao.StudentRepository;
|
|
|
|
import cn.teammodel.manager.DingAlertNotifier;
|
|
|
|
import cn.teammodel.model.entity.EvaluationTree;
|
|
|
|
import cn.teammodel.model.entity.EvaluationTreeNode;
|
|
|
|
import cn.teammodel.model.entity.Student;
|
|
|
|
import com.azure.cosmos.models.PartitionKey;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
@SpringBootTest
|
|
|
|
class TeamModelExtensionApplicationTests {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DingAlertNotifier notifier;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
StudentRepository studentRepository;
|
|
|
|
@Autowired
|
|
|
|
private EvaluationTreeRepository evaluationTreeRepository;
|
|
|
|
|
|
|
|
@Test
|
|
|
|
void contextLoads() {
|
|
|
|
notifier.send("告警: 测试消息推送封装模块");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCrud() {
|
|
|
|
EvaluationTree evaluationTree = new EvaluationTree();
|
|
|
|
evaluationTree.setCode("evaluation");
|
|
|
|
evaluationTree.setCampusId("default");
|
|
|
|
List<EvaluationTreeNode> nodes = new ArrayList<>();
|
|
|
|
|
|
|
|
// 1
|
|
|
|
String rootId = UUID.randomUUID().toString();
|
|
|
|
EvaluationTreeNode node = new EvaluationTreeNode();
|
|
|
|
node.setId(rootId);
|
|
|
|
node.setPid(null);
|
|
|
|
node.setName("root");
|
|
|
|
node.setScore(0);
|
|
|
|
// 2
|
|
|
|
EvaluationTreeNode node1 = new EvaluationTreeNode();
|
|
|
|
String subId = UUID.randomUUID().toString();
|
|
|
|
node1.setId(subId);
|
|
|
|
node1.setPid(rootId);
|
|
|
|
node1.setName("child-1");
|
|
|
|
node1.setScore(0);
|
|
|
|
// 3
|
|
|
|
EvaluationTreeNode node2 = new EvaluationTreeNode();
|
|
|
|
node2.setId(UUID.randomUUID().toString());
|
|
|
|
node2.setPid(subId);
|
|
|
|
node2.setName("child-2");
|
|
|
|
node2.setScore(0);
|
|
|
|
nodes.add(node);
|
|
|
|
nodes.add(node1);
|
|
|
|
nodes.add(node2);
|
|
|
|
evaluationTree.setNodes(nodes);
|
|
|
|
|
|
|
|
EvaluationTree saved = evaluationTreeRepository.save(evaluationTree);
|
|
|
|
System.out.println(saved);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testSelect() {
|
|
|
|
Optional<Student> s = studentRepository.findById("24913", new PartitionKey("Base-hbcn"));
|
|
|
|
System.out.println(s.orElse(null));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|