@Test public void testDeleteInvalidErrorFile() throws Exception { when(objectMessage.getObject()).thenReturn(messageDataContainer); when(messageDataContainer.getAccountId()).thenReturn(ACCOUNT_ID); when(messageDataContainer.getLoadBalancerId()).thenReturn(LOAD_BALANCER_ID); when(loadBalancerService.getWithUserPages(LOAD_BALANCER_ID, ACCOUNT_ID)).thenReturn(lb); doThrow(Exception.class).when(reverseProxyLoadBalancerStmService).deleteErrorFile(lb, null); when(config.getString(Matchers.<ConfigurationKey>any())).thenReturn("REST"); deleteErrorFileListener.doOnMessage(objectMessage); verify(reverseProxyLoadBalancerStmService).deleteErrorFile(lb, null); verify(loadBalancerService).setStatus(lb, LoadBalancerStatus.ERROR); verify(notificationService).saveAlert(eq(ACCOUNT_ID), eq(LOAD_BALANCER_ID), isA(Exception.class), eq(AlertType.ZEUS_FAILURE.name()), anyString()); }
public void doOnMessage(final Message message) throws Exception { String msg = String.format("Inside %s.doMessage", this.getClass().getName()); LOG.debug("Entering " + getClass()); LOG.debug(message); MessageDataContainer data = getDataContainerFromMessage(message); LoadBalancer dbLoadBalancer = null; if (data.getAccountId() != null && data.getLoadBalancerId() != null) { try { dbLoadBalancer = loadBalancerService.getWithUserPages(data.getLoadBalancerId(), data.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", data.getLoadBalancerId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), enfe, DATABASE_FAILURE.name(), alertDescription); return; } LOG.debug("About to remove the error file from zeus... "); try { if (isRestAdapter()) { LOG.debug(String.format("Deleting error file for %s in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.deleteErrorFile(dbLoadBalancer, loadBalancerService.getUserPages(data.getLoadBalancerId(), data.getAccountId())); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Deleting error file for %s in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.deleteErrorFile(dbLoadBalancer); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String tmpMsg = String.format("Error setting Errorfile for %d_%d", data.getAccountId(), data.getLoadBalancerId()); LOG.error(tmpMsg, e); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), e, AlertType.ZEUS_FAILURE.name(), msg); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); LOG.debug("Successfully removed the error file from zeus... "); } else { LOG.error("Error LoadbalancerId or accountId was null in call to DeleteErrorFileListener"); } }
DeleteErrorFileListener extends BaseListener { public void doOnMessage(final Message message) throws Exception { String msg = String.format("Inside %s.doMessage", this.getClass().getName()); LOG.debug("Entering " + getClass()); LOG.debug(message); MessageDataContainer data = getDataContainerFromMessage(message); LoadBalancer dbLoadBalancer = null; if (data.getAccountId() != null && data.getLoadBalancerId() != null) { try { dbLoadBalancer = loadBalancerService.getWithUserPages(data.getLoadBalancerId(), data.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", data.getLoadBalancerId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), enfe, DATABASE_FAILURE.name(), alertDescription); return; } LOG.debug("About to remove the error file from zeus... "); try { if (isRestAdapter()) { LOG.debug(String.format("Deleting error file for %s in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.deleteErrorFile(dbLoadBalancer, loadBalancerService.getUserPages(data.getLoadBalancerId(), data.getAccountId())); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Deleting error file for %s in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.deleteErrorFile(dbLoadBalancer); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String tmpMsg = String.format("Error setting Errorfile for %d_%d", data.getAccountId(), data.getLoadBalancerId()); LOG.error(tmpMsg, e); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), e, AlertType.ZEUS_FAILURE.name(), msg); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); LOG.debug("Successfully removed the error file from zeus... "); } else { LOG.error("Error LoadbalancerId or accountId was null in call to DeleteErrorFileListener"); } } }
DeleteErrorFileListener extends BaseListener { public void doOnMessage(final Message message) throws Exception { String msg = String.format("Inside %s.doMessage", this.getClass().getName()); LOG.debug("Entering " + getClass()); LOG.debug(message); MessageDataContainer data = getDataContainerFromMessage(message); LoadBalancer dbLoadBalancer = null; if (data.getAccountId() != null && data.getLoadBalancerId() != null) { try { dbLoadBalancer = loadBalancerService.getWithUserPages(data.getLoadBalancerId(), data.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", data.getLoadBalancerId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), enfe, DATABASE_FAILURE.name(), alertDescription); return; } LOG.debug("About to remove the error file from zeus... "); try { if (isRestAdapter()) { LOG.debug(String.format("Deleting error file for %s in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.deleteErrorFile(dbLoadBalancer, loadBalancerService.getUserPages(data.getLoadBalancerId(), data.getAccountId())); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Deleting error file for %s in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.deleteErrorFile(dbLoadBalancer); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String tmpMsg = String.format("Error setting Errorfile for %d_%d", data.getAccountId(), data.getLoadBalancerId()); LOG.error(tmpMsg, e); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), e, AlertType.ZEUS_FAILURE.name(), msg); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); LOG.debug("Successfully removed the error file from zeus... "); } else { LOG.error("Error LoadbalancerId or accountId was null in call to DeleteErrorFileListener"); } }  }
DeleteErrorFileListener extends BaseListener { public void doOnMessage(final Message message) throws Exception { String msg = String.format("Inside %s.doMessage", this.getClass().getName()); LOG.debug("Entering " + getClass()); LOG.debug(message); MessageDataContainer data = getDataContainerFromMessage(message); LoadBalancer dbLoadBalancer = null; if (data.getAccountId() != null && data.getLoadBalancerId() != null) { try { dbLoadBalancer = loadBalancerService.getWithUserPages(data.getLoadBalancerId(), data.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", data.getLoadBalancerId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), enfe, DATABASE_FAILURE.name(), alertDescription); return; } LOG.debug("About to remove the error file from zeus... "); try { if (isRestAdapter()) { LOG.debug(String.format("Deleting error file for %s in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.deleteErrorFile(dbLoadBalancer, loadBalancerService.getUserPages(data.getLoadBalancerId(), data.getAccountId())); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Deleting error file for %s in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.deleteErrorFile(dbLoadBalancer); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String tmpMsg = String.format("Error setting Errorfile for %d_%d", data.getAccountId(), data.getLoadBalancerId()); LOG.error(tmpMsg, e); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), e, AlertType.ZEUS_FAILURE.name(), msg); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); LOG.debug("Successfully removed the error file from zeus... "); } else { LOG.error("Error LoadbalancerId or accountId was null in call to DeleteErrorFileListener"); } }  void doOnMessage(final Message message); }
DeleteErrorFileListener extends BaseListener { public void doOnMessage(final Message message) throws Exception { String msg = String.format("Inside %s.doMessage", this.getClass().getName()); LOG.debug("Entering " + getClass()); LOG.debug(message); MessageDataContainer data = getDataContainerFromMessage(message); LoadBalancer dbLoadBalancer = null; if (data.getAccountId() != null && data.getLoadBalancerId() != null) { try { dbLoadBalancer = loadBalancerService.getWithUserPages(data.getLoadBalancerId(), data.getAccountId()); } catch (EntityNotFoundException enfe) { String alertDescription = String.format("Load balancer '%d' not found in database.", data.getLoadBalancerId()); LOG.error(alertDescription, enfe); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), enfe, DATABASE_FAILURE.name(), alertDescription); return; } LOG.debug("About to remove the error file from zeus... "); try { if (isRestAdapter()) { LOG.debug(String.format("Deleting error file for %s in STM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerStmService.deleteErrorFile(dbLoadBalancer, loadBalancerService.getUserPages(data.getLoadBalancerId(), data.getAccountId())); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } else { LOG.debug(String.format("Deleting error file for %s in ZXTM...", dbLoadBalancer.getId())); reverseProxyLoadBalancerService.deleteErrorFile(dbLoadBalancer); LOG.debug(String.format("Successfully deleted error file for %s in Zeus...", dbLoadBalancer.getId())); } } catch (Exception e) { loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ERROR); String tmpMsg = String.format("Error setting Errorfile for %d_%d", data.getAccountId(), data.getLoadBalancerId()); LOG.error(tmpMsg, e); notificationService.saveAlert(data.getAccountId(), data.getLoadBalancerId(), e, AlertType.ZEUS_FAILURE.name(), msg); return; } loadBalancerService.setStatus(dbLoadBalancer, LoadBalancerStatus.ACTIVE); LOG.debug("Successfully removed the error file from zeus... "); } else { LOG.error("Error LoadbalancerId or accountId was null in call to DeleteErrorFileListener"); } }  void doOnMessage(final Message message);  }