Revision 3273ef7c
Added by Andreas Müller over 7 years ago
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/ProgresMonitorTest.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2016 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.common; |
|
11 |
|
|
12 |
import org.junit.Assert; |
|
13 |
import org.junit.Test; |
|
14 |
|
|
15 |
import eu.etaxonomy.cdm.common.monitor.DefaultProgressMonitor; |
|
16 |
|
|
17 |
/** |
|
18 |
* @author a.kohlbecker |
|
19 |
* @date Sep 12, 2016 |
|
20 |
* |
|
21 |
*/ |
|
22 |
public class ProgresMonitorTest extends Assert { |
|
23 |
|
|
24 |
@Test |
|
25 |
public void testPercentage() { |
|
26 |
DefaultProgressMonitor monitor = DefaultProgressMonitor.NewInstance(); |
|
27 |
monitor.beginTask("test", 33); |
|
28 |
monitor.worked(5); |
|
29 |
assertEquals(Double.valueOf(15.16), Double.valueOf(monitor.getPercentage())); |
|
30 |
} |
|
31 |
|
|
32 |
} |
cdmlib-commons/src/test/java/eu/etaxonomy/cdm/common/monitor/DefaultProgressMonitorTest.java | ||
---|---|---|
9 | 9 |
*/ |
10 | 10 |
package eu.etaxonomy.cdm.common.monitor; |
11 | 11 |
|
12 |
import org.junit.Assert; |
|
12 | 13 |
import org.junit.Test; |
13 | 14 |
|
14 | 15 |
/** |
... | ... | |
23 | 24 |
@Test |
24 | 25 |
public void testRoundingWithoutSubProgressMonitor() { |
25 | 26 |
DefaultProgressMonitor monitor = new DefaultProgressMonitor(); |
26 |
int subTaskTicks = 3273; |
|
27 |
|
|
28 |
int subTasks = 130; |
|
29 | 27 |
monitor.beginTask("Hallo", steps); |
30 | 28 |
for (int i = 0; i<steps; i++){ |
31 | 29 |
monitor.worked(1); |
... | ... | |
65 | 63 |
System.out.println(monitor.getPercentageRounded(3)); |
66 | 64 |
} |
67 | 65 |
|
66 |
@Test |
|
67 |
public void testPercentage() { |
|
68 |
DefaultProgressMonitor monitor = DefaultProgressMonitor.NewInstance(); |
|
69 |
monitor.beginTask("test", 33); |
|
70 |
monitor.worked(5); |
|
71 |
Assert.assertEquals(Double.valueOf(15.15152), Double.valueOf(monitor.getPercentage())); |
|
72 |
} |
|
73 |
|
|
68 | 74 |
|
69 | 75 |
|
70 | 76 |
} |
Also available in: Unified diff
ref #6086 fix failing test