1 package org.apache.maven.archiva.database.constraints;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase;
23 import org.apache.maven.archiva.model.RepositoryContentStatistics;
25 import java.util.List;
28 * MostRecentRepositoryScanStatisticsTest
32 public class MostRecentRepositoryScanStatisticsTest
33 extends AbstractArchivaDatabaseTestCase
35 private RepositoryContentStatistics createStats( String repoId, String timestamp, long duration, long totalfiles,
39 RepositoryContentStatistics stats = new RepositoryContentStatistics();
40 stats.setRepositoryId( repoId );
41 stats.setDuration( duration );
42 stats.setNewFileCount( newfiles );
43 stats.setTotalFileCount( totalfiles );
44 stats.setWhenGathered( toDate( timestamp ) );
50 protected void setUp()
55 dao.save( createStats( "internal", "2007/02/21 10:00:00", 20000, 12000, 400 ) );
56 dao.save( createStats( "internal", "2007/02/20 10:00:00", 20000, 11800, 0 ) );
57 dao.save( createStats( "internal", "2007/02/19 10:00:00", 20000, 11800, 100 ) );
58 dao.save( createStats( "internal", "2007/02/18 10:00:00", 20000, 11700, 320 ) );
61 public void testNotProcessedYet()
64 List results = dao.query( new MostRecentRepositoryScanStatistics( "central" ) );
65 assertNotNull( "Not Processed Yet", results );
66 assertTrue( "Not Processed Yet", results.isEmpty() );
69 public void testStats()
72 List results = dao.query( new MostRecentRepositoryScanStatistics( "internal" ) );
73 assertNotNull( "Stats: results (not null)", results );
74 assertEquals( "Stats: results.size", 1, results.size() );
76 Object o = results.get( 0 );
77 assertTrue( "Stats: result[0] instanceof RepositoryScanStatistics", o instanceof RepositoryContentStatistics );
78 RepositoryContentStatistics stats = (RepositoryContentStatistics) o;
79 assertEquals( "Stats: id", "internal", stats.getRepositoryId() );
80 assertEquals( "Stats: when gathered", "2007/02/21 10:00:00", fromDate( stats.getWhenGathered() ) );
81 assertEquals( "Stats: duration", 20000, stats.getDuration() );
82 assertEquals( "Stats: total file count", 12000, stats.getTotalFileCount() );
83 assertEquals( "Stats: new file count", 400, stats.getNewFileCount() );