@Test
public void testConfigureValidRepositoryConsumer()
throws Exception
{
RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration();
repoScanning.addKnownContentConsumer( "index-artifact" );
repoScanning.addKnownContentConsumer( "index-pom" );
repoScanning.addInvalidContentConsumer( "check-pom" );
// test enable "check-metadata" consumer
recordRepoConsumers();
archivaConfigControl.reset();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.reset();
configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 5 );
archivaConfig.save( config );
archivaConfigControl.setVoidCallable();
repoConsumerUtilsControl.replay();
knownContentConsumerControl.replay();
invalidContentConsumerControl.replay();
archivaConfigControl.replay();
configControl.replay();
try
{
boolean success = service.configureRepositoryConsumer( null, "check-metadata", true );
assertTrue( success );
}
catch ( Exception e )
{
fail( "An exception should not have been thrown." );
}
repoConsumerUtilsControl.verify();
knownContentConsumerControl.verify();
invalidContentConsumerControl.verify();
archivaConfigControl.verify();
configControl.verify();
// test disable "check-metadata" consumer
repoConsumerUtilsControl.reset();
knownContentConsumerControl.reset();
invalidContentConsumerControl.reset();
archivaConfigControl.reset();
configControl.reset();
repoScanning.addInvalidContentConsumer( "check-metadata" );
recordRepoConsumers();
archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning, 1, 4 );