@Test public void testErrorLogWhenStatusUpdatedToError() throws Exception{ PowerMockito.mockStatic(faspmanager2.class); PowerMockito .when( faspmanager2.stopTransfer(anyString()) ).thenReturn(true); TransferListener spyTransferListener = spy(TransferListener.class); spyTransferListener.log = mockLog; spyTransferListener.setStatus("abc123", null, "ERROR", 0); verify(mockLog, times(1)).error(Mockito.eq("Status marked as [ERROR] for xferId [abc123]")); }
public synchronized void setStatus(String xferId, String sessionId, String status, long bytes) { log.trace("TransferListener.setStatus >> " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); if(status.equals("INIT") && isNewSession(xferId, sessionId)) { ascpCount++; } else if (status.equals("DONE") || status.equals("STOP") || status.equals("ARGSTOP")){ removeTransactionSession(xferId, sessionId); removeTransactionFromAudit(xferId); } else if (status.equals("ERROR")) { log.error("Status marked as [ERROR] for xferId [" + xferId + "]"); ascpCount -= numberOfSessionsInTransaction(xferId); removeAllTransactionSessions(xferId); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); } if(status.equals("ARGSTOP")) { removeTransactionFromAudit(xferId); removeAllTransactionSessions(xferId); } if(bytes > 0) { updateProgress(xferId, sessionId, status, bytes); } if(status.equals("DONE") || status.equals("STOP")) { if(totalPreTransferBytes.get(xferId) == null || ((bytesTransferred.get(xferId) != null && bytesTransferred.get(xferId) >= totalPreTransferBytes.get(xferId)))) { this.status.put(xferId, status); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); log.info("Status marked as [" + status + "] for xferId [" + xferId + "]"); } } else { this.status.put(xferId, status); } log.trace("TransferListener.setStatus << " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); }
TransferListener extends ITransferListener { public synchronized void setStatus(String xferId, String sessionId, String status, long bytes) { log.trace("TransferListener.setStatus >> " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); if(status.equals("INIT") && isNewSession(xferId, sessionId)) { ascpCount++; } else if (status.equals("DONE") || status.equals("STOP") || status.equals("ARGSTOP")){ removeTransactionSession(xferId, sessionId); removeTransactionFromAudit(xferId); } else if (status.equals("ERROR")) { log.error("Status marked as [ERROR] for xferId [" + xferId + "]"); ascpCount -= numberOfSessionsInTransaction(xferId); removeAllTransactionSessions(xferId); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); } if(status.equals("ARGSTOP")) { removeTransactionFromAudit(xferId); removeAllTransactionSessions(xferId); } if(bytes > 0) { updateProgress(xferId, sessionId, status, bytes); } if(status.equals("DONE") || status.equals("STOP")) { if(totalPreTransferBytes.get(xferId) == null || ((bytesTransferred.get(xferId) != null && bytesTransferred.get(xferId) >= totalPreTransferBytes.get(xferId)))) { this.status.put(xferId, status); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); log.info("Status marked as [" + status + "] for xferId [" + xferId + "]"); } } else { this.status.put(xferId, status); } log.trace("TransferListener.setStatus << " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); } }
TransferListener extends ITransferListener { public synchronized void setStatus(String xferId, String sessionId, String status, long bytes) { log.trace("TransferListener.setStatus >> " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); if(status.equals("INIT") && isNewSession(xferId, sessionId)) { ascpCount++; } else if (status.equals("DONE") || status.equals("STOP") || status.equals("ARGSTOP")){ removeTransactionSession(xferId, sessionId); removeTransactionFromAudit(xferId); } else if (status.equals("ERROR")) { log.error("Status marked as [ERROR] for xferId [" + xferId + "]"); ascpCount -= numberOfSessionsInTransaction(xferId); removeAllTransactionSessions(xferId); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); } if(status.equals("ARGSTOP")) { removeTransactionFromAudit(xferId); removeAllTransactionSessions(xferId); } if(bytes > 0) { updateProgress(xferId, sessionId, status, bytes); } if(status.equals("DONE") || status.equals("STOP")) { if(totalPreTransferBytes.get(xferId) == null || ((bytesTransferred.get(xferId) != null && bytesTransferred.get(xferId) >= totalPreTransferBytes.get(xferId)))) { this.status.put(xferId, status); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); log.info("Status marked as [" + status + "] for xferId [" + xferId + "]"); } } else { this.status.put(xferId, status); } log.trace("TransferListener.setStatus << " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); } protected  TransferListener(); }
TransferListener extends ITransferListener { public synchronized void setStatus(String xferId, String sessionId, String status, long bytes) { log.trace("TransferListener.setStatus >> " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); if(status.equals("INIT") && isNewSession(xferId, sessionId)) { ascpCount++; } else if (status.equals("DONE") || status.equals("STOP") || status.equals("ARGSTOP")){ removeTransactionSession(xferId, sessionId); removeTransactionFromAudit(xferId); } else if (status.equals("ERROR")) { log.error("Status marked as [ERROR] for xferId [" + xferId + "]"); ascpCount -= numberOfSessionsInTransaction(xferId); removeAllTransactionSessions(xferId); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); } if(status.equals("ARGSTOP")) { removeTransactionFromAudit(xferId); removeAllTransactionSessions(xferId); } if(bytes > 0) { updateProgress(xferId, sessionId, status, bytes); } if(status.equals("DONE") || status.equals("STOP")) { if(totalPreTransferBytes.get(xferId) == null || ((bytesTransferred.get(xferId) != null && bytesTransferred.get(xferId) >= totalPreTransferBytes.get(xferId)))) { this.status.put(xferId, status); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); log.info("Status marked as [" + status + "] for xferId [" + xferId + "]"); } } else { this.status.put(xferId, status); } log.trace("TransferListener.setStatus << " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); } protected  TransferListener(); static TransferListener getInstance(String xferId, AsperaTransaction transaction); synchronized void transferReporter(String xferId, String msg); String getStatus(String xferId); synchronized void setStatus(String xferId, String sessionId, String status, long bytes); static int getAscpCount(); void removeTransaction(String xferid); void removeAllTransactionSessions(String xferId); void shutdownThreadPools(); }
TransferListener extends ITransferListener { public synchronized void setStatus(String xferId, String sessionId, String status, long bytes) { log.trace("TransferListener.setStatus >> " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); if(status.equals("INIT") && isNewSession(xferId, sessionId)) { ascpCount++; } else if (status.equals("DONE") || status.equals("STOP") || status.equals("ARGSTOP")){ removeTransactionSession(xferId, sessionId); removeTransactionFromAudit(xferId); } else if (status.equals("ERROR")) { log.error("Status marked as [ERROR] for xferId [" + xferId + "]"); ascpCount -= numberOfSessionsInTransaction(xferId); removeAllTransactionSessions(xferId); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); } if(status.equals("ARGSTOP")) { removeTransactionFromAudit(xferId); removeAllTransactionSessions(xferId); } if(bytes > 0) { updateProgress(xferId, sessionId, status, bytes); } if(status.equals("DONE") || status.equals("STOP")) { if(totalPreTransferBytes.get(xferId) == null || ((bytesTransferred.get(xferId) != null && bytesTransferred.get(xferId) >= totalPreTransferBytes.get(xferId)))) { this.status.put(xferId, status); removeTransactionProgressData(xferId); removeTransactionFromAudit(xferId); log.info("Status marked as [" + status + "] for xferId [" + xferId + "]"); } } else { this.status.put(xferId, status); } log.trace("TransferListener.setStatus << " + System.nanoTime() + ": " + new Exception().getStackTrace()[1].getClassName()); } protected  TransferListener(); static TransferListener getInstance(String xferId, AsperaTransaction transaction); synchronized void transferReporter(String xferId, String msg); String getStatus(String xferId); synchronized void setStatus(String xferId, String sessionId, String status, long bytes); static int getAscpCount(); void removeTransaction(String xferid); void removeAllTransactionSessions(String xferId); void shutdownThreadPools();  }