@@ -1538,4 +1538,80 @@ public void getTrackedDevices_shouldReturnTrackedDevices() throws Exception {
1538
1538
assertThat (result .get (0 ), is (metadataResponseMock ));
1539
1539
}
1540
1540
1541
+ @ Test
1542
+ public void deleteTrackedDevices_shouldThrowExceptionWhenSdkIdIsNull () {
1543
+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> docScanService .deleteTrackedDevices (null , KEY_PAIR , SOME_SESSION_ID ));
1544
+ assertThat (exception .getMessage (), containsString ("SDK ID" ));
1545
+ }
1546
+
1547
+ @ Test
1548
+ public void deleteTrackedDevices_shouldThrowExceptionWhenSdkIdIsEmpty () {
1549
+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> docScanService .deleteTrackedDevices ("" , KEY_PAIR , SOME_SESSION_ID ));
1550
+ assertThat (exception .getMessage (), containsString ("SDK ID" ));
1551
+ }
1552
+
1553
+ @ Test
1554
+ public void deleteTrackedDevices_shouldThrowExceptionWhenKeyPairIsNull () {
1555
+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , null , SOME_SESSION_ID ));
1556
+ assertThat (exception .getMessage (), containsString ("Application key Pair" ));
1557
+ }
1558
+
1559
+ @ Test
1560
+ public void deleteTrackedDevices_shouldThrowExceptionWhenSessionIdIsNull () {
1561
+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , null ));
1562
+ assertThat (exception .getMessage (), containsString ("sessionId" ));
1563
+ }
1564
+
1565
+ @ Test
1566
+ public void deleteTrackedDevices_shouldThrowExceptionWhenSessionIdIsEmpty () {
1567
+ IllegalArgumentException exception = assertThrows (IllegalArgumentException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , "" ));
1568
+ assertThat (exception .getMessage (), containsString ("sessionId" ));
1569
+ }
1570
+
1571
+ @ Test
1572
+ public void deleteTrackedDevices_shouldWrapGeneralSecurityException () throws Exception {
1573
+ GeneralSecurityException gse = new GeneralSecurityException ("some gse" );
1574
+ when (signedRequestBuilderMock .build ()).thenThrow (gse );
1575
+
1576
+ DocScanException ex = assertThrows (DocScanException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , SOME_SESSION_ID ));
1577
+
1578
+ assertSame (ex .getCause (), gse );
1579
+ assertThat (ex .getMessage (), containsString ("Error executing the GET: some gse" ));
1580
+ }
1581
+
1582
+ @ Test
1583
+ public void deleteTrackedDevices_shouldWrapResourceException () throws Exception {
1584
+ ResourceException resourceException = new ResourceException (400 , "Failed Request" , "Some response from API" );
1585
+ when (signedRequestBuilderMock .build ()).thenReturn (signedRequestMock );
1586
+ when (signedRequestMock .execute ()).thenThrow (resourceException );
1587
+
1588
+ DocScanException ex = assertThrows (DocScanException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , SOME_SESSION_ID ));
1589
+
1590
+ assertSame (ex .getCause (), resourceException );
1591
+ assertThat (ex .getMessage (), containsString ("Error executing the GET: Failed Request" ));
1592
+ }
1593
+
1594
+ @ Test
1595
+ public void deleteTrackedDevices_shouldWrapIOException () throws Exception {
1596
+ IOException ioException = new IOException ("Some io exception" );
1597
+ when (signedRequestBuilderMock .build ()).thenReturn (signedRequestMock );
1598
+ when (signedRequestMock .execute ()).thenThrow (ioException );
1599
+
1600
+ DocScanException ex = assertThrows (DocScanException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , SOME_SESSION_ID ));
1601
+
1602
+ assertSame (ex .getCause (), ioException );
1603
+ assertThat (ex .getMessage (), containsString ("Error building the request: Some io exception" ));
1604
+ }
1605
+
1606
+ @ Test
1607
+ public void deleteTrackedDevices_shouldWrapURISyntaxException () throws Exception {
1608
+ URISyntaxException uriSyntaxException = new URISyntaxException ("someUrl" , "Failed to build URI" );
1609
+ when (signedRequestBuilderMock .build ()).thenThrow (uriSyntaxException );
1610
+
1611
+ DocScanException ex = assertThrows (DocScanException .class , () -> docScanService .deleteTrackedDevices (SOME_APP_ID , KEY_PAIR , SOME_SESSION_ID ));
1612
+
1613
+ assertSame (ex .getCause (), uriSyntaxException );
1614
+ assertThat (ex .getMessage (), containsString ("Error building the request: Failed to build URI: someUrl" ));
1615
+ }
1616
+
1541
1617
}
0 commit comments