Increasing test coverage
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / dal / rest / config / RestEndpointConfigTest.java
1 package org.onap.aai.sparky.dal.rest.config;
2
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertNull;
6 import static org.junit.Assert.assertTrue;
7
8 import org.junit.Before;
9 import org.junit.Test;
10
11 import org.onap.aai.restclient.enums.RestAuthenticationMode;
12
13 public class RestEndpointConfigTest {
14         
15         private RestEndpointConfig restEndpointConfig; 
16         @Before
17         public void init() throws Exception{
18                 
19                 restEndpointConfig = new RestEndpointConfig();
20                 
21                 
22         }
23         
24         @Test
25         public void updateValues(){
26                 restEndpointConfig.setValidateServerCertChain(true);
27                 assertTrue(restEndpointConfig.isValidateServerCertChain());
28                 restEndpointConfig.setValidateServerHostname(true);
29                 assertTrue(restEndpointConfig.isValidateServerHostname());
30                 restEndpointConfig.setEndpointIpAddress("10.147.110.199");
31                 assertNotNull(restEndpointConfig.getEndpointIpAddress());
32                 restEndpointConfig.setEndpointServerPort("9885");
33                 assertNotNull(restEndpointConfig.getEndpointServerPort());
34                 restEndpointConfig.setNumRequestRetries(5);
35                 assertEquals(restEndpointConfig.getNumRequestRetries(),5);
36                 restEndpointConfig.setBasicAuthUserName("sparky");
37                 assertNotNull(restEndpointConfig.getBasicAuthUserName());
38                 restEndpointConfig.setBasicAuthPassword("sparky");
39                 assertNotNull(restEndpointConfig.getBasicAuthPassword());
40                 restEndpointConfig.setRestAuthenticationMode(RestAuthenticationMode.SSL_BASIC);
41                 assertEquals(restEndpointConfig.getRestAuthenticationMode(),RestAuthenticationMode.SSL_BASIC);  
42                 restEndpointConfig.setConnectTimeoutInMs(6000);
43                 assertEquals(restEndpointConfig.getConnectTimeoutInMs(),6000);
44                 restEndpointConfig.setCertFileName("aai-client-cert.p12");
45                 assertNotNull(restEndpointConfig.getCertFileName());
46                 restEndpointConfig.setReadTimeoutInMs(4000);
47                 assertEquals(restEndpointConfig.getReadTimeoutInMs(),4000);
48                 restEndpointConfig.setCertPassword("1i9a1u2a1unz1lr61wn51wn11lss1unz1u301i6o");
49                 assertNotNull(restEndpointConfig.getCertPassword());
50                 restEndpointConfig.setTruststoreFileName("synchronizer.jks");
51                 assertNotNull(restEndpointConfig.getTruststoreFileName());
52                 assertNotNull(restEndpointConfig.toString());
53                 
54                 restEndpointConfig.setEndpointIpAddress(null);
55                 assertNull(restEndpointConfig.getEndpointIpAddress());
56                 restEndpointConfig.setEndpointServerPort(null);
57                 assertNull(restEndpointConfig.getEndpointServerPort());
58                 restEndpointConfig.setCertFileName(null);
59                 assertNull(restEndpointConfig.getCertFileName());
60                 restEndpointConfig.setTruststoreFileName(null);
61                 assertNull(restEndpointConfig.getTruststoreFileName());
62                 restEndpointConfig.setRestAuthenticationMode(null);
63                 assertNull(restEndpointConfig.getRestAuthenticationMode());     
64                 restEndpointConfig.setCertPassword(null);
65                 assertNull(restEndpointConfig.getCertPassword());
66                 restEndpointConfig.setBasicAuthUserName(null);
67                 assertNull(restEndpointConfig.getBasicAuthUserName());
68                 restEndpointConfig.setBasicAuthPassword(null);
69                 assertNull(restEndpointConfig.getBasicAuthPassword());
70                 assertNotNull(restEndpointConfig.toString());
71                 
72                 
73                 
74         }
75
76 }