View Javadoc

1   /*
2    * Copyright 2006-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.kuali.rice.kew.stats;
18  
19  import org.apache.commons.lang.StringUtils;
20  import org.junit.Test;
21  import org.kuali.rice.kew.service.KEWServiceLocator;
22  import org.kuali.rice.kew.stats.service.StatsService;
23  import org.kuali.rice.kew.test.KEWTestCase;
24  
25  import static junit.framework.Assert.assertTrue;
26  
27  /**
28   * Test the Stats Service
29   *
30   * @author Kuali Rice Team (rice.collab@kuali.org)
31   */
32  public class StatsServiceTest extends KEWTestCase{
33  
34      @Test
35      public void testStatsService() throws  Exception{
36          StatsService statsService = KEWServiceLocator.getService(KEWServiceLocator.STATS_SERVICE);
37  
38          Stats stats = new Stats();
39          statsService.NumActiveItemsReport(stats);
40          statsService.DocumentsRoutedReport(stats, new java.util.Date(System.currentTimeMillis()),new java.util.Date(System.currentTimeMillis()));
41          statsService.NumberOfDocTypesReport(stats);
42          statsService.NumInitiatedDocsByDocTypeReport(stats);
43          statsService.NumUsersReport(stats);
44  
45          assertTrue("Stats object populated", stats != null &&
46                  StringUtils.equals(stats.getNumActionItems(),"0") &&
47                  stats.getNumInitiatedDocsByDocType().size() == 0);
48          assertTrue("Number of document types", StringUtils.equals(stats.getNumDocTypes(),"6"));
49      }
50  
51  
52  }