@Test(description = "Testing search devices when unable to search devices")
public void testSearchDevicesException() throws SearchMgtException {

    SearchManagerService searchManagerService = Mockito.mock(SearchManagerServiceImpl.class, Mockito.RETURNS_MOCKS);
    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getSearchManagerService"))
            .toReturn(searchManagerService);
    Mockito.when(searchManagerService.search(Mockito.any(SearchContext.class))).thenThrow(new SearchMgtException());
    Response response = this.deviceManagementService
            .searchDevices(10, 5, new SearchContext());
    Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
            "Expects HTTP 500 when an exception occurred while searching the device");
}