3636
3737class JiraConfigurationDeserializerTests
3838{
39+ private static final String JIRA_KEY = "jira" ;
40+
3941 @ Test
4042 void shouldDeserialize () throws IOException
4143 {
42- JsonParser parser = new JavaPropsFactory (). createParser ("""
44+ JiraConfiguration configuration = deserialize ("""
4345 project-key-regex=VVDS
4446 endpoint=https://jira.vividus.com
4547 fields-mapping.test-case-type=customfield_00001
@@ -48,10 +50,6 @@ void shouldDeserialize() throws IOException
4850 http.auth.password=052ddff802a174847345
4951 http.socket-timeout=1
5052 """ );
51- parser .setCodec (new JavaPropsMapper ().setPropertyNamingStrategy (PropertyNamingStrategies .KEBAB_CASE ));
52-
53- JiraConfigurationDeserializer deserializer = new JiraConfigurationDeserializer ();
54- JiraConfiguration configuration = deserializer .deserialize (parser , null );
5553
5654 assertEquals ("VVDS" , configuration .getProjectKeyRegex ().pattern ());
5755 String endpoint = "https://jira.vividus.com" ;
@@ -64,7 +62,7 @@ void shouldDeserialize() throws IOException
6462 assertEquals (1 , http .getSocketTimeout ());
6563 Map <String , HttpContextConfig > contextConfigs = http .getHttpContextConfig ();
6664 assertNotNull (contextConfigs );
67- HttpContextConfig contextConfig = contextConfigs .get ("jira" );
65+ HttpContextConfig contextConfig = contextConfigs .get (JIRA_KEY );
6866 assertNotNull (contextConfig );
6967 BasicAuthConfig config = contextConfig .getAuth ();
7068 assertNotNull (config );
@@ -74,17 +72,39 @@ void shouldDeserialize() throws IOException
7472 }
7573
7674 @ Test
77- void shouldDeserializeEmpty () throws IOException
75+ void shouldDeserializeWithoutAuth () throws IOException
7876 {
79- JsonParser parser = new JavaPropsFactory ().createParser ("" );
80- parser .setCodec (new JavaPropsMapper ().setPropertyNamingStrategy (PropertyNamingStrategies .KEBAB_CASE ));
77+ JiraConfiguration configuration = deserialize ("""
78+ http.socket-timeout=1
79+ """ );
8180
82- JiraConfigurationDeserializer deserializer = new JiraConfigurationDeserializer ();
83- JiraConfiguration configuration = deserializer .deserialize (parser , null );
81+ HttpClientConfig http = configuration .getHttpClientConfig ();
82+ assertNotNull (http );
83+ assertEquals (1 , http .getSocketTimeout ());
84+ Map <String , HttpContextConfig > contextConfigs = http .getHttpContextConfig ();
85+ assertNotNull (contextConfigs );
86+ HttpContextConfig contextConfig = contextConfigs .get (JIRA_KEY );
87+ assertNotNull (contextConfig );
88+ assertNull (contextConfig .getAuth ());
89+ }
90+
91+ @ Test
92+ void shouldDeserializeEmpty () throws IOException
93+ {
94+ JiraConfiguration configuration = deserialize ("" );
8495
8596 assertNull (configuration .getProjectKeyRegex ());
8697 assertNull (configuration .getEndpoint ());
8798 assertNull (configuration .getFieldsMapping ());
8899 assertNull (configuration .getHttpClientConfig ());
89100 }
101+
102+ private JiraConfiguration deserialize (String input ) throws IOException
103+ {
104+ JsonParser parser = new JavaPropsFactory ().createParser (input );
105+ parser .setCodec (new JavaPropsMapper ().setPropertyNamingStrategy (PropertyNamingStrategies .KEBAB_CASE ));
106+
107+ JiraConfigurationDeserializer deserializer = new JiraConfigurationDeserializer ();
108+ return deserializer .deserialize (parser , null );
109+ }
90110}
0 commit comments