21
21
import com .navercorp .pinpoint .common .util .BytesUtils ;
22
22
import com .navercorp .pinpoint .common .util .IOUtils ;
23
23
import com .navercorp .pinpoint .web .install .dao .AgentDownloadInfoDao ;
24
- import com .navercorp .pinpoint .web .install .dao .AgentDownloadInfoDaoFactoryBean ;
25
24
import com .navercorp .pinpoint .web .install .dao .GithubAgentDownloadInfoDao ;
26
25
import com .navercorp .pinpoint .web .install .dao .MemoryAgentDownloadInfoDao ;
27
26
import com .navercorp .pinpoint .web .install .model .GithubAgentDownloadInfo ;
34
33
35
34
import static org .assertj .core .api .Assertions .assertThat ;
36
35
import static org .junit .jupiter .api .Assertions .assertEquals ;
36
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
37
37
38
38
/**
39
39
* @author Taejin Koo
@@ -45,41 +45,31 @@ public class AgentDownloadInfoTest {
45
45
RestTemplate restTemplate = new RestTemplate ();
46
46
47
47
@ Test
48
- void factoryTest1 () throws Exception {
49
- AgentDownloadInfoDaoFactoryBean factoryBean = new AgentDownloadInfoDaoFactoryBean ();
50
- factoryBean .setVersion (version );
51
- factoryBean .setDownloadUrl (downloadUrl );
52
- factoryBean .setRestTemplate (restTemplate );
48
+ void factoryTest1 () {
49
+ InstallModule module = new InstallModule ();
53
50
54
- AgentDownloadInfoDao dao = factoryBean . getObject ( );
51
+ AgentDownloadInfoDao dao = module . urlAgentDownloadInfoDao ( version , downloadUrl );
55
52
assertThat (dao ).isInstanceOf (MemoryAgentDownloadInfoDao .class );
56
53
assertEquals (version , dao .getDownloadInfoList ().get (0 ).getVersion ());
57
54
assertEquals (downloadUrl , dao .getDownloadInfoList ().get (0 ).getDownloadUrl ());
58
55
}
59
56
60
57
@ Test
61
- void factoryTest2 () throws Exception {
62
- AgentDownloadInfoDaoFactoryBean factoryBean = new AgentDownloadInfoDaoFactoryBean ();
63
- factoryBean .setVersion (version );
64
- factoryBean .setDownloadUrl ("" );
65
- factoryBean .setRestTemplate (restTemplate );
58
+ void factoryTest2 () {
59
+ InstallModule module = new InstallModule ();
66
60
67
- AgentDownloadInfoDao dao = factoryBean . getObject ();
68
- assertThat ( dao ). isInstanceOf ( GithubAgentDownloadInfoDao . class );
61
+ assertThrows ( IllegalArgumentException . class ,
62
+ () -> module . urlAgentDownloadInfoDao ( version , "" ) );
69
63
}
70
64
71
65
@ Test
72
- void factoryTest3 () throws Exception {
73
- AgentDownloadInfoDaoFactoryBean factoryBean = new AgentDownloadInfoDaoFactoryBean ();
74
- factoryBean .setVersion (" " );
75
- factoryBean .setDownloadUrl (downloadUrl );
76
- factoryBean .setRestTemplate (restTemplate );
66
+ void factoryTest3 () {
67
+ InstallModule module = new InstallModule ();
77
68
78
- AgentDownloadInfoDao dao = factoryBean . getObject ( );
69
+ AgentDownloadInfoDao dao = module . githubAgentDownloadInfoDao ( restTemplate );
79
70
assertThat (dao ).isInstanceOf (GithubAgentDownloadInfoDao .class );
80
71
}
81
72
82
-
83
73
@ Test
84
74
void defaultTest () throws Exception {
85
75
String mockResponseString = getMockJsonString ();
0 commit comments