assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
assertNotNull( repo );
ArtifactDAO adao = dao.getArtifactDAO();
ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar", repo.getId() );
sqlArtifact.getModel().setLastModified( new Date() );
sqlArtifact.getModel().setSize( 1234 );
sqlArtifact.getModel().setOrigin( "testcase" );
sqlArtifact.getModel().setWhenProcessed( null );
adao.saveArtifact( sqlArtifact );
ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar", repo.getId() );
assertNotNull( artifact );
// Test for artifact existance.
List<ArchivaArtifact> artifactList = adao.queryArtifacts( null );
assertNotNull( "Artifact list should not be null.", artifactList );
assertEquals( "Artifact list size", 1, artifactList.size() );
// Test for unprocessed artifacts.
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList );
assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() );
// Execute the database task.
DatabaseTask dataTask = new DatabaseTask();
dataTask.setName( "testDataTask" );
taskExecutor.executeTask( dataTask );
// Test for artifact existance.
artifactList = adao.queryArtifacts( null );
assertNotNull( "Artifact list should not be null.", artifactList );
assertEquals( "Artifact list size", 1, artifactList.size() );
// Test for processed artifacts.
List<ArchivaArtifact> processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) );
assertNotNull( "Processed Results should not be null.", processedResultList );
assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
}