test练习文件
import java.lang.reflect.Field;
import java.util.*;
import java.util.regex.Pattern;
import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.Criteria;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
public class test {
public static void main(String[] args) {
// testTemp();
//test();
List<String> issueNoList=new ArrayList();
issueNoList.add("110314");
issueNoList.add("113364");
StringBuilder sb = new StringBuilder();
for(int i = 0; i < issueNoList.size(); i++){
if (sb.length() > 0) {//该步即不会第一位有逗号,也防止最后一位拼接逗号!
sb.append("+");
}
sb.append(issueNoList.get(i));
}
System.out.println(sb);
String q="fuyi";
String enterpriseName="fuyiff";
Pattern pattern = Pattern.compile("^.*" + q + ".*$", Pattern.CASE_INSENSITIVE);
System.out.println(pattern);
test1();
test2();
}
public static void testTemp(){
RestTemplate restTemplate = new RestTemplate();
//headers
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
//body
//MultiValueMap<String, String> requestBody = new LinkedMultiValueMap<>();
Map<String, String> requestBody = new HashMap();
requestBody.put("businessKey", "xxxxx");
//HttpEntity
HttpEntity<Map<String, String>> requestEntity = new HttpEntity<>(requestBody, requestHeaders);
//HttpEntity<MultiValueMap> requestEntity = new HttpEntity<MultiValueMap>(requestBody, requestHeaders);
String s = restTemplate.postForObject("url", requestEntity,
String.class);
System.out.println(s);
}
public static void test(){
RestTemplate restTemplate = new RestTemplate();
Map<String, String> params = new HashMap<String, String>();
List<String> issueNoList=new ArrayList();
issueNoList.add("110314");
issueNoList.add("113364");
String issueNoParams="";
for(int i = 0; i < issueNoList.size(); i++){
issueNoParams=issueNoList.get(i)+"+";
}
params.put("issueNo",issueNoParams);
ResultMsgVO resultMsgVO= restTemplate.getForObject("http://127.0.0.1:8080/requirement/getHasArrangementByIcafeId?"+"issueNo={issueNo}",ResultMsgVO.class,params);
System.out.println(resultMsgVO);
}
public static void test1(){
//键盘录入邮箱
Scanner sc = new Scanner(System.in);
System.out.println("请输入邮箱:");
String email = sc.nextLine();
//定义邮箱的规则
//String regex = "[a-zA-Z_0-9]+@[a-zA-Z_0-9]{2,6}(\\.[a-zA-Z_0-9]{2,3})+";
String regex = "^.*fui.*$";
//调用功能,判断即可
boolean flag = email.matches(regex);
//输出结果
System.out.println("flag:"+flag);
}
public static void test2(){
// Object obj="{"110314":0,"114461":0,"113323":0,"113364":1}";
// Map<String, Integer> map=new HashMap<String, Integer>();
// Field[] fields = obj.getClass().getDeclaredFields();
// for(Field field:fields){
// field.setAccessible(true);
// map.put(field.getName(), field.get(obj));
// }
// System.out.println(map);
}
}