1 package eu
.etaxonomy
.cdm
.api
.service
;
3 import static org
.junit
.Assert
.*;
5 import java
.util
.HashMap
;
7 import org
.junit
.Ignore
;
8 import org
.apache
.log4j
.Logger
;
9 import org
.junit
.Assert
;
10 import org
.junit
.BeforeClass
;
11 import org
.junit
.Test
;
12 import org
.springframework
.beans
.factory
.annotation
.Autowired
;
13 import org
.unitils
.UnitilsJUnit4
;
14 import org
.unitils
.spring
.annotation
.SpringBeanByType
;
16 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.Statistics
;
17 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsConfigurator
;
18 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsPartEnum
;
19 import eu
.etaxonomy
.cdm
.api
.service
.statistics
.StatisticsTypeEnum
;
20 import eu
.etaxonomy
.cdm
.test
.integration
.CdmTransactionalIntegrationTest
;
22 public class StatisticsServiceImplTest
extends CdmTransactionalIntegrationTest
{// UnitilsJUnit4
25 * this is the place to put the values in. only the types listed here are
28 private static Map
<StatisticsTypeEnum
, Number
> prototype
= new HashMap
<StatisticsTypeEnum
, Number
>() {
30 put(StatisticsTypeEnum
.ALL_TAXA
, 0);
31 put(StatisticsTypeEnum
.ACCEPTED_TAXA
, 0);
32 put(StatisticsTypeEnum
.CLASSIFICATION
, 0);
33 put(StatisticsTypeEnum
.ALL_REFERENCES
, 0);
34 put(StatisticsTypeEnum
.SYNONYMS
, 0);
35 put(StatisticsTypeEnum
.TAXON_NAMES
, 0);
36 put(StatisticsTypeEnum
.NOMECLATURAL_REFERENCES
, 0);
37 // put(StatisticsTypeEnum.DESCRIPTIVE_SOURCE_REFERENCES, 0);
42 private static final Logger logger
= Logger
43 .getLogger(StatisticsServiceImplTest
.class);
45 StatisticsConfigurator configurator
;
48 private IStatisticsService service
;
51 // public void setService(IStatisticsService service) {
52 // this.service = service;
55 // ---------- test--------------
59 public void testGetCountStatistics_partAll() {
63 Statistics resultStat
= service
.getCountStatistics(configurator
);
64 Map
<String
, Number
> resultCountMap
= resultStat
.getCountMap();
66 for (Map
.Entry
<StatisticsTypeEnum
, Number
> protoEntry
: prototype
69 logger
.info(protoEntry
.getKey().getLabel()+":\texpected count: "
70 + "\t\t" + protoEntry
.getValue() + "\tactual count: "
71 + resultCountMap
.get(protoEntry
.getKey().getLabel()));
73 if (!((resultCountMap
.get(protoEntry
.getKey().getLabel()))
74 .equals((Number
) 0))) {
78 // Assert.assertFalse("everything was counted right!!!", check);
79 Assert
.assertTrue("some count did not match!!!", check
);
80 // fail("Not yet implemented");
86 public void testGetCountStatistics_partCLASSIFICATION() {
87 fail("Not yet implemented");
90 // ------------------------------------------------------------------
92 private void createConfigurator() {
93 configurator
= new StatisticsConfigurator();
94 configurator
.addPart(StatisticsPartEnum
.ALL
);
95 for (StatisticsTypeEnum type
: StatisticsTypeEnum
.values()) {
96 configurator
.addType(type
);