2222
2323import software .xdev .bzst .dip .client .exception .ConfigurationException ;
2424import software .xdev .bzst .dip .client .model .message .BzstDipAddressFix ;
25+ import software .xdev .bzst .dip .client .signing .SigningProviderByJks ;
2526
2627
2728class BzstDipConfigurationBuilderTest
@@ -44,9 +45,7 @@ void buildAndValidate_goodValue()
4445 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
4546 .setTaxID ("86095742719" )
4647 .setTaxNumber ("123" )
47- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
48- .getResourceAsStream ("DemoKeystore.jks" ))
49- .setCertificateKeystorePassword ("test123" )
48+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
5049 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
5150 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
5251 .setReportingPeriod (LocalDate .now ())
@@ -66,9 +65,7 @@ void buildAndValidate_missingClientId()
6665 () -> new BzstDipConfigurationBuilder ()
6766 .setTaxID ("86095742719" )
6867 .setTaxNumber ("123" )
69- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
70- .getResourceAsStream ("DemoKeystore.jks" ))
71- .setCertificateKeystorePassword ("test123" )
68+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
7269 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
7370 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
7471 .setReportingPeriod (LocalDate .now ())
@@ -88,9 +85,7 @@ void buildAndValidate_missingTaxId()
8885 () -> new BzstDipConfigurationBuilder ()
8986 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
9087 .setTaxNumber ("123" )
91- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
92- .getResourceAsStream ("DemoKeystore.jks" ))
93- .setCertificateKeystorePassword ("test123" )
88+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
9489 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
9590 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
9691 .setReportingPeriod (LocalDate .now ())
@@ -110,9 +105,7 @@ void buildAndValidate_missingTaxNumber()
110105 () -> new BzstDipConfigurationBuilder ()
111106 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
112107 .setTaxID ("86095742719" )
113- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
114- .getResourceAsStream ("DemoKeystore.jks" ))
115- .setCertificateKeystorePassword ("test123" )
108+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
116109 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
117110 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
118111 .setReportingPeriod (LocalDate .now ())
@@ -125,37 +118,14 @@ void buildAndValidate_missingTaxNumber()
125118 }
126119
127120 @ Test
128- void buildAndValidate_missingKeystore ()
121+ void buildAndValidate_missingSigningProvider ()
129122 {
130123 Assertions .assertThrows (
131124 ConfigurationException .class ,
132125 () -> new BzstDipConfigurationBuilder ()
133126 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
134127 .setTaxID ("86095742719" )
135128 .setTaxNumber ("123" )
136- .setCertificateKeystorePassword ("test123" )
137- .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
138- .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
139- .setReportingPeriod (LocalDate .now ())
140- .setDocTypeIndic (BzstDipOecdDocType .OECD_1 )
141- .setPlatformOperatorOrganizationName ("TestOrg" )
142- .setPlatformOperatorPlatformName ("TestApp" )
143- .setPlatformOperatorAddress (new BzstDipAddressFix ("TestCity" ))
144- .buildAndValidate ()
145- );
146- }
147-
148- @ Test
149- void buildAndValidate_missingKeystorePassword ()
150- {
151- Assertions .assertThrows (
152- ConfigurationException .class ,
153- () -> new BzstDipConfigurationBuilder ()
154- .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
155- .setTaxID ("86095742719" )
156- .setTaxNumber ("123" )
157- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
158- .getResourceAsStream ("DemoKeystore.jks" ))
159129 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
160130 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
161131 .setReportingPeriod (LocalDate .now ())
@@ -175,9 +145,7 @@ void buildAndValidate_defaultRealmBaseUrl()
175145 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
176146 .setTaxID ("86095742719" )
177147 .setTaxNumber ("123" )
178- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
179- .getResourceAsStream ("DemoKeystore.jks" ))
180- .setCertificateKeystorePassword ("test123" )
148+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
181149 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
182150 .setReportingPeriod (LocalDate .now ())
183151 .setDocTypeIndic (BzstDipOecdDocType .OECD_1 )
@@ -197,9 +165,7 @@ void buildAndValidate_missingMessageTypeIndic()
197165 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
198166 .setTaxID ("86095742719" )
199167 .setTaxNumber ("123" )
200- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
201- .getResourceAsStream ("DemoKeystore.jks" ))
202- .setCertificateKeystorePassword ("test123" )
168+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
203169 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
204170 .setReportingPeriod (LocalDate .now ())
205171 .setDocTypeIndic (BzstDipOecdDocType .OECD_1 )
@@ -219,9 +185,7 @@ void buildAndValidate_wrongReportingPeriod()
219185 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
220186 .setTaxID ("86095742719" )
221187 .setTaxNumber ("123" )
222- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
223- .getResourceAsStream ("DemoKeystore.jks" ))
224- .setCertificateKeystorePassword ("test123" )
188+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
225189 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
226190 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
227191 .setReportingPeriod (LocalDate .now ().plusDays (1 ))
@@ -242,9 +206,7 @@ void buildAndValidate_missingReportingPeriod()
242206 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
243207 .setTaxID ("86095742719" )
244208 .setTaxNumber ("123" )
245- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
246- .getResourceAsStream ("DemoKeystore.jks" ))
247- .setCertificateKeystorePassword ("test123" )
209+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
248210 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
249211 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
250212 .setDocTypeIndic (BzstDipOecdDocType .OECD_1 )
@@ -264,9 +226,7 @@ void buildAndValidate_missingAddress()
264226 .setClientId ("abcd1234-ab12-ab12-ab12-abcdef123456" )
265227 .setTaxID ("86095742719" )
266228 .setTaxNumber ("123" )
267- .setCertificateKeystoreInputStream (() -> ClassLoader .getSystemClassLoader ()
268- .getResourceAsStream ("DemoKeystore.jks" ))
269- .setCertificateKeystorePassword ("test123" )
229+ .setSigningProvider (new SigningProviderByJks ("DemoKeystore.jks" , "test123" ))
270230 .setRealmEnvironmentBaseUrl (BzstDipConfiguration .ENDPOINT_URL_TEST )
271231 .setMessageTypeIndic (BzstDipDpiMessageType .DPI_401 )
272232 .setReportingPeriod (LocalDate .now ())
0 commit comments