| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.mail.internal; |
| 21 |
|
|
| 22 |
|
import org.apache.commons.lang3.exception.ExceptionUtils; |
| 23 |
|
import org.slf4j.Logger; |
| 24 |
|
import org.slf4j.LoggerFactory; |
| 25 |
|
|
| 26 |
|
|
| 27 |
|
@link |
| 28 |
|
|
| 29 |
|
@version |
| 30 |
|
@since |
| 31 |
|
|
| |
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 9 |
Complexity Density: 0.82 |
|
| 32 |
|
public abstract class AbstractMailStatusResult implements UpdateableMailStatusResult |
| 33 |
|
{ |
| 34 |
|
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMailStatusResult.class); |
| 35 |
|
|
| 36 |
|
private long totalSize = -1; |
| 37 |
|
|
| 38 |
|
private long currentSize; |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
45 |
@Override... |
| 41 |
|
public void setTotalSize(long totalSize) |
| 42 |
|
{ |
| 43 |
45 |
this.totalSize = totalSize; |
| 44 |
|
} |
| 45 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 46 |
32 |
@Override... |
| 47 |
|
public void incrementCurrentSize() |
| 48 |
|
{ |
| 49 |
32 |
this.currentSize++; |
| 50 |
|
} |
| 51 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 52 |
44 |
@Override... |
| 53 |
|
public long getTotalMailCount() |
| 54 |
|
{ |
| 55 |
44 |
return this.totalSize; |
| 56 |
|
} |
| 57 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 58 |
45 |
@Override... |
| 59 |
|
public long getProcessedMailCount() |
| 60 |
|
{ |
| 61 |
45 |
return this.currentSize; |
| 62 |
|
} |
| 63 |
|
|
| |
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 64 |
13 |
@Override... |
| 65 |
|
public void waitTillProcessed(long timeout) |
| 66 |
|
{ |
| 67 |
13 |
long startTime = System.currentTimeMillis(); |
| 68 |
38 |
while (!isProcessed() && System.currentTimeMillis() - startTime < timeout) { |
| 69 |
25 |
try { |
| 70 |
25 |
Thread.sleep(100L); |
| 71 |
|
} catch (InterruptedException e) { |
| 72 |
|
|
| 73 |
0 |
LOGGER.warn("Interrupted while waiting for mails to be sent. Reason [{}]", |
| 74 |
|
ExceptionUtils.getRootCauseMessage(e)); |
| 75 |
0 |
break; |
| 76 |
|
} |
| 77 |
|
} |
| 78 |
|
} |
| 79 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 80 |
44 |
@Override... |
| 81 |
|
public boolean isProcessed() |
| 82 |
|
{ |
| 83 |
44 |
return getTotalMailCount() == getProcessedMailCount(); |
| 84 |
|
} |
| 85 |
|
} |