1 package org.apache.maven.archiva.reporting.database;
4 * Copyright 2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 import junit.framework.TestCase;
21 import org.apache.maven.archiva.reporting.model.ArtifactResults;
22 import org.apache.maven.archiva.reporting.model.MetadataResults;
23 import org.apache.maven.artifact.Artifact;
24 import org.apache.maven.artifact.DefaultArtifact;
25 import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata;
26 import org.apache.maven.artifact.repository.metadata.RepositoryMetadata;
27 import org.apache.maven.artifact.versioning.VersionRange;
30 * Test for {@link ReportingDatabase}.
32 * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
35 public class ReportingDatabaseTest
38 private Artifact artifact;
39 private String processor, problem, reason;
40 private ReportingDatabase reportingDatabase;
41 private RepositoryMetadata metadata;
43 protected void setUp()
47 artifact = new DefaultArtifact( "group", "artifact", VersionRange.createFromVersion( "1.0" ), "scope", "type",
49 processor = "processor";
52 reportingDatabase = new ReportingDatabase( null );
54 metadata = new ArtifactRepositoryMetadata( artifact );
57 public void testAddNoticeArtifactStringStringString()
59 reportingDatabase.addNotice( artifact, processor, problem, reason );
60 ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
62 assertEquals( 1, reportingDatabase.getNumNotices() );
63 assertEquals( 1, artifactResults.getNotices().size() );
65 reportingDatabase.addNotice( artifact, processor, problem, reason );
66 artifactResults = reportingDatabase.getArtifactResults( artifact );
68 assertEquals( 1, reportingDatabase.getNumNotices() );
69 assertEquals( 1, artifactResults.getNotices().size() );
72 public void testAddWarningArtifactStringStringString()
74 reportingDatabase.addWarning( artifact, processor, problem, reason );
75 ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
77 assertEquals( 1, reportingDatabase.getNumWarnings() );
78 assertEquals( 1, artifactResults.getWarnings().size() );
80 reportingDatabase.addWarning( artifact, processor, problem, reason );
81 artifactResults = reportingDatabase.getArtifactResults( artifact );
83 assertEquals( 1, reportingDatabase.getNumWarnings() );
84 assertEquals( 1, artifactResults.getWarnings().size() );
87 public void testAddFailureArtifactStringStringString()
89 reportingDatabase.addFailure( artifact, processor, problem, reason );
90 ArtifactResults artifactResults = reportingDatabase.getArtifactResults( artifact );
92 assertEquals( 1, reportingDatabase.getNumFailures() );
93 assertEquals( 1, artifactResults.getFailures().size() );
95 reportingDatabase.addFailure( artifact, processor, problem, reason );
96 artifactResults = reportingDatabase.getArtifactResults( artifact );
98 assertEquals( 1, reportingDatabase.getNumFailures() );
99 assertEquals( 1, artifactResults.getFailures().size() );
102 public void testAddNoticeRepositoryMetadataStringStringString()
104 reportingDatabase.addNotice( metadata, processor, problem, reason );
105 MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
107 assertEquals( 1, reportingDatabase.getNumNotices() );
108 assertEquals( 1, metadataResults.getNotices().size() );
110 reportingDatabase.addNotice( metadata, processor, problem, reason );
111 metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
113 assertEquals( 1, reportingDatabase.getNumNotices() );
114 assertEquals( 1, metadataResults.getNotices().size() );
117 public void testAddWarningRepositoryMetadataStringStringString()
119 reportingDatabase.addWarning( metadata, processor, problem, reason );
120 MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
122 assertEquals( 1, reportingDatabase.getNumWarnings() );
123 assertEquals( 1, metadataResults.getWarnings().size() );
125 reportingDatabase.addWarning( metadata, processor, problem, reason );
126 metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
128 assertEquals( 1, reportingDatabase.getNumWarnings() );
129 assertEquals( 1, metadataResults.getWarnings().size() );
132 public void testAddFailureRepositoryMetadataStringStringString()
134 reportingDatabase.addFailure( metadata, processor, problem, reason );
135 MetadataResults metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
137 assertEquals( 1, reportingDatabase.getNumFailures() );
138 assertEquals( 1, metadataResults.getFailures().size() );
140 reportingDatabase.addFailure( metadata, processor, problem, reason );
141 metadataResults = reportingDatabase.getMetadataResults( metadata, System.currentTimeMillis() );
143 assertEquals( 1, reportingDatabase.getNumFailures() );
144 assertEquals( 1, metadataResults.getFailures().size() );