@SuppressWarnings("unchecked") @Test public void deleteAssetGroupExceptionsExceptionThrowsTest1() throws PacManException, IOException { when(assetGroupExceptionRepository.findByGroupNameAndExceptionName(anyString(), anyString())).thenThrow(Exception.class); assertThatThrownBy(() -> assetGroupExceptionService.deleteAssetGroupExceptions(geDeleteAssetGroupExceptionDetailsRequest(), "userId123")).isInstanceOf(PacManException.class); }
@Override public String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId) throws PacManException { try { Response exceptionResponse = invokeAPI("GET","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_")+"/_source", null); if(exceptionResponse != null) { String exceptionBackUp = EntityUtils.toString(exceptionResponse.getEntity()); Response response = invokeAPI("DELETE","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_"), null); if(response != null) { if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) { try { List<AssetGroupException> assetGroupExceptions = assetGroupExceptionRepository.findByGroupNameAndExceptionName(assetGroupExceptionRequest.getGroupName(), assetGroupExceptionRequest.getExceptionName()); for (AssetGroupException assetGroupException : assetGroupExceptions) { assetGroupExceptionRepository.delete(assetGroupException); } } catch (Exception exception) { Response exceptionBackUpResponse = invokeAPI("POST", "/exceptions/sticky_exceptions/"+ assetGroupExceptionRequest.getExceptionName().trim().replaceAll(" ", "_"), exceptionBackUp); if(exceptionBackUpResponse != null) { if (exceptionBackUpResponse.getStatusLine().getStatusCode() == 200 || exceptionBackUpResponse.getStatusLine().getStatusCode() == 201) { throw new PacManException("Exception while updating to table as well as updating ES:"+exception.getMessage()); } } throw new PacManException("Exception while updating to table "+exception.getMessage()); } } } else { return EXCEPTION_DELETEION_FAILURE; } return EXCEPTION_DELETEION_SUCCESS; } else { return EXCEPTION_DELETEION_FAILURE; } } catch (Exception exception) { throw new PacManException("Exception while deleteing the exception "+exception.getMessage()); } }
AssetGroupExceptionServiceImpl implements AssetGroupExceptionService { @Override public String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId) throws PacManException { try { Response exceptionResponse = invokeAPI("GET","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_")+"/_source", null); if(exceptionResponse != null) { String exceptionBackUp = EntityUtils.toString(exceptionResponse.getEntity()); Response response = invokeAPI("DELETE","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_"), null); if(response != null) { if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) { try { List<AssetGroupException> assetGroupExceptions = assetGroupExceptionRepository.findByGroupNameAndExceptionName(assetGroupExceptionRequest.getGroupName(), assetGroupExceptionRequest.getExceptionName()); for (AssetGroupException assetGroupException : assetGroupExceptions) { assetGroupExceptionRepository.delete(assetGroupException); } } catch (Exception exception) { Response exceptionBackUpResponse = invokeAPI("POST", "/exceptions/sticky_exceptions/"+ assetGroupExceptionRequest.getExceptionName().trim().replaceAll(" ", "_"), exceptionBackUp); if(exceptionBackUpResponse != null) { if (exceptionBackUpResponse.getStatusLine().getStatusCode() == 200 || exceptionBackUpResponse.getStatusLine().getStatusCode() == 201) { throw new PacManException("Exception while updating to table as well as updating ES:"+exception.getMessage()); } } throw new PacManException("Exception while updating to table "+exception.getMessage()); } } } else { return EXCEPTION_DELETEION_FAILURE; } return EXCEPTION_DELETEION_SUCCESS; } else { return EXCEPTION_DELETEION_FAILURE; } } catch (Exception exception) { throw new PacManException("Exception while deleteing the exception "+exception.getMessage()); } } }
AssetGroupExceptionServiceImpl implements AssetGroupExceptionService { @Override public String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId) throws PacManException { try { Response exceptionResponse = invokeAPI("GET","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_")+"/_source", null); if(exceptionResponse != null) { String exceptionBackUp = EntityUtils.toString(exceptionResponse.getEntity()); Response response = invokeAPI("DELETE","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_"), null); if(response != null) { if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) { try { List<AssetGroupException> assetGroupExceptions = assetGroupExceptionRepository.findByGroupNameAndExceptionName(assetGroupExceptionRequest.getGroupName(), assetGroupExceptionRequest.getExceptionName()); for (AssetGroupException assetGroupException : assetGroupExceptions) { assetGroupExceptionRepository.delete(assetGroupException); } } catch (Exception exception) { Response exceptionBackUpResponse = invokeAPI("POST", "/exceptions/sticky_exceptions/"+ assetGroupExceptionRequest.getExceptionName().trim().replaceAll(" ", "_"), exceptionBackUp); if(exceptionBackUpResponse != null) { if (exceptionBackUpResponse.getStatusLine().getStatusCode() == 200 || exceptionBackUpResponse.getStatusLine().getStatusCode() == 201) { throw new PacManException("Exception while updating to table as well as updating ES:"+exception.getMessage()); } } throw new PacManException("Exception while updating to table "+exception.getMessage()); } } } else { return EXCEPTION_DELETEION_FAILURE; } return EXCEPTION_DELETEION_SUCCESS; } else { return EXCEPTION_DELETEION_FAILURE; } } catch (Exception exception) { throw new PacManException("Exception while deleteing the exception "+exception.getMessage()); } }  }
AssetGroupExceptionServiceImpl implements AssetGroupExceptionService { @Override public String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId) throws PacManException { try { Response exceptionResponse = invokeAPI("GET","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_")+"/_source", null); if(exceptionResponse != null) { String exceptionBackUp = EntityUtils.toString(exceptionResponse.getEntity()); Response response = invokeAPI("DELETE","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_"), null); if(response != null) { if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) { try { List<AssetGroupException> assetGroupExceptions = assetGroupExceptionRepository.findByGroupNameAndExceptionName(assetGroupExceptionRequest.getGroupName(), assetGroupExceptionRequest.getExceptionName()); for (AssetGroupException assetGroupException : assetGroupExceptions) { assetGroupExceptionRepository.delete(assetGroupException); } } catch (Exception exception) { Response exceptionBackUpResponse = invokeAPI("POST", "/exceptions/sticky_exceptions/"+ assetGroupExceptionRequest.getExceptionName().trim().replaceAll(" ", "_"), exceptionBackUp); if(exceptionBackUpResponse != null) { if (exceptionBackUpResponse.getStatusLine().getStatusCode() == 200 || exceptionBackUpResponse.getStatusLine().getStatusCode() == 201) { throw new PacManException("Exception while updating to table as well as updating ES:"+exception.getMessage()); } } throw new PacManException("Exception while updating to table "+exception.getMessage()); } } } else { return EXCEPTION_DELETEION_FAILURE; } return EXCEPTION_DELETEION_SUCCESS; } else { return EXCEPTION_DELETEION_FAILURE; } } catch (Exception exception) { throw new PacManException("Exception while deleteing the exception "+exception.getMessage()); } }  @Override Page<AssetGroupExceptionProjections> getAllAssetGroupExceptions(String searchTerm, int page, int size); @Override StickyExceptionResponse getAllTargetTypesByExceptionNameAndDataSource(final String exceptionName, final String dataSource); @Override String createAssetGroupExceptions(final AssetGroupExceptionDetailsRequest assetGroupExceptionDetails, final String userId); @Override String updateAssetGroupExceptions(final AssetGroupExceptionDetailsRequest assetGroupExceptionDetailsRequest, String userId); @Override String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId); @Override Collection<String> getAllExceptionNames(); }
AssetGroupExceptionServiceImpl implements AssetGroupExceptionService { @Override public String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId) throws PacManException { try { Response exceptionResponse = invokeAPI("GET","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_")+"/_source", null); if(exceptionResponse != null) { String exceptionBackUp = EntityUtils.toString(exceptionResponse.getEntity()); Response response = invokeAPI("DELETE","/exceptions/sticky_exceptions/" + assetGroupExceptionRequest.getExceptionName().replaceAll(" ", "_"), null); if(response != null) { if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) { try { List<AssetGroupException> assetGroupExceptions = assetGroupExceptionRepository.findByGroupNameAndExceptionName(assetGroupExceptionRequest.getGroupName(), assetGroupExceptionRequest.getExceptionName()); for (AssetGroupException assetGroupException : assetGroupExceptions) { assetGroupExceptionRepository.delete(assetGroupException); } } catch (Exception exception) { Response exceptionBackUpResponse = invokeAPI("POST", "/exceptions/sticky_exceptions/"+ assetGroupExceptionRequest.getExceptionName().trim().replaceAll(" ", "_"), exceptionBackUp); if(exceptionBackUpResponse != null) { if (exceptionBackUpResponse.getStatusLine().getStatusCode() == 200 || exceptionBackUpResponse.getStatusLine().getStatusCode() == 201) { throw new PacManException("Exception while updating to table as well as updating ES:"+exception.getMessage()); } } throw new PacManException("Exception while updating to table "+exception.getMessage()); } } } else { return EXCEPTION_DELETEION_FAILURE; } return EXCEPTION_DELETEION_SUCCESS; } else { return EXCEPTION_DELETEION_FAILURE; } } catch (Exception exception) { throw new PacManException("Exception while deleteing the exception "+exception.getMessage()); } }  @Override Page<AssetGroupExceptionProjections> getAllAssetGroupExceptions(String searchTerm, int page, int size); @Override StickyExceptionResponse getAllTargetTypesByExceptionNameAndDataSource(final String exceptionName, final String dataSource); @Override String createAssetGroupExceptions(final AssetGroupExceptionDetailsRequest assetGroupExceptionDetails, final String userId); @Override String updateAssetGroupExceptions(final AssetGroupExceptionDetailsRequest assetGroupExceptionDetailsRequest, String userId); @Override String deleteAssetGroupExceptions(final DeleteAssetGroupExceptionRequest assetGroupExceptionRequest, String userId); @Override Collection<String> getAllExceptionNames();  }