|
@@ -26,10 +26,10 @@ class WwwApplicationTests {
|
|
|
// Flux.range(1, 10).subscribe(System.out::println);
|
|
|
// Flux.interval(Duration.of(10, ChronoUnit.SECONDS)).subscribe(System.out::println);
|
|
|
|
|
|
- Flux.generate(sink -> {
|
|
|
- sink.next("Hello");
|
|
|
- sink.complete();
|
|
|
- }).subscribe(System.out::println);
|
|
|
+// Flux.generate(sink -> {
|
|
|
+// sink.next("Hello");
|
|
|
+// sink.complete();
|
|
|
+// }).subscribe(System.out::println);
|
|
|
|
|
|
|
|
|
// final Random random = new Random();
|
|
@@ -55,59 +55,59 @@ class WwwApplicationTests {
|
|
|
// Flux.range(1, 10).bufferWhile(i -> i % 2 == 0).subscribe(System.out::println);
|
|
|
|
|
|
|
|
|
- List<String> list = Arrays.asList("item1", "item2");
|
|
|
- list.forEach(System.out::println);
|
|
|
+// List<String> list = Arrays.asList("item1", "item2");
|
|
|
+// list.forEach(System.out::println);
|
|
|
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void test2(){
|
|
|
- List<String> strs = Arrays.asList("1","4","3","2");
|
|
|
- // strs.sort((s1,s2) -> s1.compareTo(s2));
|
|
|
- strs.sort(String::compareTo);
|
|
|
- strs.forEach(System.out::println);
|
|
|
- }
|
|
|
- @Data
|
|
|
- private static class Student{
|
|
|
- private String name;
|
|
|
- private int age;
|
|
|
- public Student(String name, int age) {
|
|
|
- this.name = name;
|
|
|
- this.age = age;
|
|
|
- }
|
|
|
+// List<String> strs = Arrays.asList("1","4","3","2");
|
|
|
+// // strs.sort((s1,s2) -> s1.compareTo(s2));
|
|
|
+// strs.sort(String::compareTo);
|
|
|
+// strs.forEach(System.out::println);
|
|
|
}
|
|
|
+// @Data
|
|
|
+// private static class Student{
|
|
|
+// private String name;
|
|
|
+// private int age;
|
|
|
+// public Student(String name, int age) {
|
|
|
+// this.name = name;
|
|
|
+// this.age = age;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
@Test
|
|
|
void test3(){
|
|
|
- List<Student> students = new ArrayList<>(3);
|
|
|
- students.add(new Student("路飞", 22));
|
|
|
- students.add(new Student("红发", 40));
|
|
|
- students.add(new Student("白胡子", 50));
|
|
|
-
|
|
|
- List<Student> list = students.stream()
|
|
|
- .filter(stu -> stu.getAge() < 50)
|
|
|
- .collect(Collectors.toList());
|
|
|
- System.out.println(list);
|
|
|
-
|
|
|
-
|
|
|
- List<String> names = students.stream().map(Student::getName)
|
|
|
- .collect(Collectors.toList());
|
|
|
- System.out.println(names);
|
|
|
+// List<Student> students = new ArrayList<>(3);
|
|
|
+// students.add(new Student("路飞", 22));
|
|
|
+// students.add(new Student("红发", 40));
|
|
|
+// students.add(new Student("白胡子", 50));
|
|
|
+//
|
|
|
+// List<Student> list = students.stream()
|
|
|
+// .filter(stu -> stu.getAge() < 50)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// System.out.println(list);
|
|
|
+//
|
|
|
+//
|
|
|
+// List<String> names = students.stream().map(Student::getName)
|
|
|
+// .collect(Collectors.toList());
|
|
|
+// System.out.println(names);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
void test4(){
|
|
|
- RestTemplate restTemplate = new RestTemplate();
|
|
|
- String uri = "https://spi.caimei365.com/search/query/product?keyword=采美";
|
|
|
- JSONObject forObject = restTemplate.getForObject(uri, JSONObject.class);
|
|
|
- if(forObject != null){
|
|
|
- String data = forObject.getString("data");
|
|
|
-
|
|
|
- JSONObject parse = JSONObject.parseObject(data);
|
|
|
- Integer total = parse.getInteger("total");
|
|
|
-
|
|
|
- System.out.println(total);
|
|
|
- }
|
|
|
+// RestTemplate restTemplate = new RestTemplate();
|
|
|
+// String uri = "https://spi.caimei365.com/search/query/product?keyword=采美";
|
|
|
+// JSONObject forObject = restTemplate.getForObject(uri, JSONObject.class);
|
|
|
+// if(forObject != null){
|
|
|
+// String data = forObject.getString("data");
|
|
|
+//
|
|
|
+// JSONObject parse = JSONObject.parseObject(data);
|
|
|
+// Integer total = parse.getInteger("total");
|
|
|
+//
|
|
|
+// System.out.println(total);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
}
|