-
Notifications
You must be signed in to change notification settings - Fork 267
/
AuthApplicationTest.java
57 lines (44 loc) · 1.61 KB
/
AuthApplicationTest.java
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
package com.blueskykong.auth;
import com.blueskykong.auth.dao.ClientSecretDAO;
import com.blueskykong.auth.dto.ApiClientDTO;
import com.blueskykong.auth.entity.ClientSecret;
import com.blueskykong.auth.service.ClientSecretService;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.UUID;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/**
* @author keets
* @date 2016/12/5
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class AuthApplicationTest {
@Mock
private ClientSecretDAO clientSecretDao;
@Mock
private ClientSecretService clientSecretService;
@Before
public void setUp() {
ApiClientDTO mockClient = new ApiClientDTO();
mockClient.setClientId("test");
mockClient.setClientSecret("test");
mockClient.setPurpose("test..");
ClientSecret clientSecret = new ClientSecret.ClientSecretBuilder()
.withTenantId(UUID.randomUUID())
.build();
when(clientSecretService.getClientSecretByClientId("test")).thenReturn(mockClient);
// when(clientSecretDao.get(clientSecret)).thenReturn()
}
@Test
public void getClientSecretByClientIdTest() {
ApiClientDTO apiClientDTO = clientSecretService.getClientSecretByClientId("test");
Assert.assertEquals(apiClientDTO.getClientSecret(),"test" );
}
}