liujie
2026-04-01 4b33796be3887c81fa40fba2f55dce4489cff041
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.estate.expert.admin.service;
 
import com.alibaba.fastjson.JSONObject;
import com.estate.expert.admin.domain.business.client.Client;
import com.estate.expert.admin.domain.common.request.BatchReq;
import com.estate.expert.admin.domain.common.request.PageReq;
import com.estate.expert.admin.domain.business.client.ClientType;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.Arrays;
 
/**
 * @author ligf
 * @Description
 * @date 2023-09-05
 **/
@Slf4j
@SpringBootTest
@ExtendWith(SpringExtension.class)
@Transactional
public class ClientServiceTest {
 
    @Resource
    private ClientService clientService;
 
    @Resource
    private UserService userService;
 
    private Client currentClient;
 
    @BeforeEach
    public void setUp() {
        var request = new Client();
        request.setName("测试委托方A");
        request.setType(ClientType.DEVELOPER);
        request.setIntention("测试意向A");
        currentClient = clientService.add(userService.getSystemUser(), request);
    }
 
    @AfterEach
    public void tearDown() {
        var request = BatchReq.of(Arrays.asList(currentClient.getId()));
        clientService.deleteAllById(request.getIds());
    }
 
    @Test
    public void testList() {
        var response = clientService.list(null, null, null, PageReq.of(0, 10));
        log.info("response: {}", JSONObject.toJSONString(response));
    }
 
    @Test
    public void testListAll() {
        var options = clientService.findAll();
        Assertions.assertNotNull(options);
        Assertions.assertFalse(options.isEmpty());
    }
 
    @Test
    public void testEdit() {
        currentClient.setName("测试委托方X");
        currentClient.setType(ClientType.ESTATE);
        currentClient.setIntention("测试意向X");
//        clientService.edit(currentClient);
 
        var client = clientService.get(currentClient.getId());
        Assertions.assertEquals("测试委托方X", client.getName());
        Assertions.assertEquals(ClientType.ESTATE, client.getType());
        Assertions.assertEquals("测试意向X", client.getIntention());
    }
 
}