|
5 | 5 | import java.nio.file.Path; |
6 | 6 | import java.nio.file.Paths; |
7 | 7 | import java.util.Base64; |
| 8 | +import java.util.UUID; |
| 9 | + |
8 | 10 | import mx.com.sw.exceptions.ServicesException; |
9 | 11 | import mx.com.sw.helpers.BuildSettings; |
10 | 12 | import mx.com.sw.services.pdf.responses.PdfResponse; |
@@ -203,4 +205,87 @@ private void writePDF(String b64) { |
203 | 205 | e.printStackTrace(); |
204 | 206 | } |
205 | 207 | } |
| 208 | + |
| 209 | + //------------------------------------------ |
| 210 | + //Pruebas unitarias del metodo Regenerar PDF |
| 211 | + //------------------------------------------- |
| 212 | + /** |
| 213 | + * Método de UT consume servicio regenerar PDF, con token. |
| 214 | + */ |
| 215 | + @Test |
| 216 | + public void testRegeneratePdf_Success(){ |
| 217 | + try { |
| 218 | + Pdf pdf = new Pdf(settings.getUrlServicesSW(), settings.getTokenSW(), null, 0); |
| 219 | + PdfResponse response = pdf.regeneratePdf(UUID.fromString("5bb78a5c-9fd7-4100-8fac-9b51b585e22f")); |
| 220 | + Assertions.assertNotNull(response); |
| 221 | + Assertions.assertTrue(!response.getMessage().isEmpty()); |
| 222 | + Assertions.assertTrue("Success".equalsIgnoreCase(response.getStatus())); |
| 223 | + Assertions.assertTrue("Solicitud se proceso correctamente.".equalsIgnoreCase(response.getMessage())); |
| 224 | + } catch (ServicesException ex) { |
| 225 | + Assertions.assertNotNull(ex); |
| 226 | + } |
| 227 | + } |
| 228 | + /** |
| 229 | + * Método de UT consume servicio regenerar PDF, con Usuario y contraseña. |
| 230 | + */ |
| 231 | + @Test |
| 232 | + public void testRegeneratePdf_AuthSuccess(){ |
| 233 | + try { |
| 234 | + Pdf pdf = new Pdf(settings.getUrlSW(), settings.getUrlServicesSW(), settings.getUserSW(),settings.getPasswordSW(), null, 0); |
| 235 | + PdfResponse response = pdf.regeneratePdf(UUID.fromString("5bb78a5c-9fd7-4100-8fac-9b51b585e22f")); |
| 236 | + Assertions.assertNotNull(response); |
| 237 | + Assertions.assertTrue(!response.getMessage().isEmpty()); |
| 238 | + Assertions.assertTrue("Success".equalsIgnoreCase(response.getStatus())); |
| 239 | + Assertions.assertTrue("Solicitud se proceso correctamente.".equalsIgnoreCase(response.getMessage())); |
| 240 | + } catch (ServicesException ex) { |
| 241 | + Assertions.assertNotNull(ex); |
| 242 | + } |
| 243 | + } |
| 244 | + /** |
| 245 | + * Método de UT consume servicio regenerar PDF, error en el usuario. |
| 246 | + */ |
| 247 | + @Test |
| 248 | + public void testRegeneratePdf_ErrorAuth(){ |
| 249 | + try { |
| 250 | + String msgError = "AU2000 - El usuario y/o contraseña son inválidos, no se puede autenticar el servicio."; |
| 251 | + Pdf pdf = new Pdf(settings.getUrlSW(), settings.getUrlServicesSW(), "user",settings.getPasswordSW(), null, 0); |
| 252 | + PdfResponse response = pdf.regeneratePdf(UUID.fromString("5bb78a5c-9fd7-4100-8fac-9b51b585e22f")); |
| 253 | + Assertions.assertNotNull(response); |
| 254 | + Assertions.assertTrue(!response.getMessage().isEmpty()); |
| 255 | + Assertions.assertTrue("Error".equalsIgnoreCase(response.getStatus())); |
| 256 | + Assertions.assertTrue(msgError.equalsIgnoreCase(response.getMessage())); |
| 257 | + } catch (ServicesException ex) { |
| 258 | + Assertions.assertNotNull(ex); |
| 259 | + } |
| 260 | + } |
| 261 | + /** |
| 262 | + * Método de UT consume servicio regenerar PDF, Error con el UUID no encontrado. |
| 263 | + */ |
| 264 | + @Test |
| 265 | + public void testRegeneratePdf_ErrorUUIDNull(){ |
| 266 | + try { |
| 267 | + Pdf pdf = new Pdf(settings.getUrlSW(), settings.getUrlServicesSW(), settings.getUserSW(),settings.getPasswordSW(), null, 0); |
| 268 | + PdfResponse response = pdf.regeneratePdf(null); |
| 269 | + Assertions.assertNotNull(response); |
| 270 | + Assertions.assertTrue("Error".equalsIgnoreCase(response.getStatus())); |
| 271 | + } catch (ServicesException ex) { |
| 272 | + Assertions.assertNotNull(ex); |
| 273 | + } |
| 274 | + } |
| 275 | + /** |
| 276 | + * Método de UT consume servicio regenerar PDF, Error con el UUID no encontrado. |
| 277 | + */ |
| 278 | + @Test |
| 279 | + public void testRegeneratePdf_ErrorUUID(){ |
| 280 | + try { |
| 281 | + Pdf pdf = new Pdf(settings.getUrlSW(), settings.getUrlServicesSW(), settings.getUserSW(),settings.getPasswordSW(), null, 0); |
| 282 | + PdfResponse response = pdf.regeneratePdf(UUID.fromString("21348cb0-a94a-466c-a8e0-abef7f35a71b")); |
| 283 | + Assertions.assertNotNull(response); |
| 284 | + Assertions.assertTrue("error".equalsIgnoreCase(response.getStatus())); |
| 285 | + Assertions.assertTrue(!response.getMessage().isEmpty()); |
| 286 | + Assertions.assertTrue("No se encontro el UUID.".equalsIgnoreCase(response.getMessage())); |
| 287 | + } catch (ServicesException ex) { |
| 288 | + Assertions.assertNotNull(ex); |
| 289 | + } |
| 290 | + } |
206 | 291 | } |
0 commit comments