mirror of https://github.com/apache/archiva.git
[MRM-1490] REST services : more unit test for LegacyArtifactPath and LegacyArtifactPath
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1167223 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
102fd6f531
commit
97de6d3118
|
@ -92,8 +92,12 @@ public class DefaultArchivaAdministration
|
||||||
public RepositoryScanning getRepositoryScanning()
|
public RepositoryScanning getRepositoryScanning()
|
||||||
throws RepositoryAdminException
|
throws RepositoryAdminException
|
||||||
{
|
{
|
||||||
return new BeanReplicator().replicateBean( getArchivaConfiguration().getConfiguration().getRepositoryScanning(),
|
|
||||||
RepositoryScanning.class );
|
RepositoryScanning repositoryScanning =
|
||||||
|
new BeanReplicator().replicateBean( getArchivaConfiguration().getConfiguration().getRepositoryScanning(),
|
||||||
|
RepositoryScanning.class )
|
||||||
|
|
||||||
|
return repositoryScanning;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation )
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.archiva.rest.services;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import net.sf.beanlib.provider.BeanTransformer;
|
||||||
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
import net.sf.beanlib.provider.replicator.BeanReplicator;
|
||||||
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
import org.apache.archiva.admin.repository.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
import org.apache.archiva.admin.repository.admin.ArchivaAdministration;
|
||||||
|
@ -97,8 +98,25 @@ public class DefaultArchivaAdministrationService
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return new BeanReplicator().replicateBean( archivaAdministration.getRepositoryScanning(),
|
BeanTransformer beanTransformer = new BeanTransformer()
|
||||||
RepositoryScanning.class );
|
{
|
||||||
|
@Override
|
||||||
|
protected <T> T createToInstance( Object from, Class<T> toClass )
|
||||||
|
throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException
|
||||||
|
{
|
||||||
|
if ( from.getClass().equals( org.apache.maven.archiva.configuration.FileType.class ) )
|
||||||
|
{
|
||||||
|
return (T) new FileType();
|
||||||
|
}
|
||||||
|
return super.createToInstance( from, toClass );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
BeanReplicator beanReplicator = new BeanReplicator( beanTransformer );
|
||||||
|
|
||||||
|
RepositoryScanning repositoryScanning =
|
||||||
|
beanReplicator.replicateBean( archivaAdministration.getRepositoryScanning(), RepositoryScanning.class );
|
||||||
|
|
||||||
|
return repositoryScanning;
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,12 @@ package org.apache.archiva.rest.services;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.rest.api.model.FileType;
|
||||||
|
import org.apache.archiva.rest.api.model.LegacyArtifactPath;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
|
@ -33,4 +37,36 @@ public class ArchivaAdministrationServiceTest
|
||||||
assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
|
assertNotNull( getArchivaAdministrationService().getLegacyArtifactPaths() );
|
||||||
assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
|
assertFalse( getArchivaAdministrationService().getLegacyArtifactPaths().isEmpty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addAndDeleteLegacyPath()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int initialSize = getArchivaAdministrationService().getLegacyArtifactPaths().size();
|
||||||
|
LegacyArtifactPath legacyArtifactPath = new LegacyArtifactPath();
|
||||||
|
legacyArtifactPath.setArtifact( "foo" );
|
||||||
|
legacyArtifactPath.setPath( "bar" );
|
||||||
|
getArchivaAdministrationService().addLegacyArtifactPath( legacyArtifactPath );
|
||||||
|
assertEquals( initialSize + 1, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
|
||||||
|
|
||||||
|
getArchivaAdministrationService().deleteLegacyArtifactPath( "bar" );
|
||||||
|
assertEquals( initialSize, getArchivaAdministrationService().getLegacyArtifactPaths().size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addAndDeleteFileType()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int initialSize = getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size();
|
||||||
|
FileType fileType = new FileType();
|
||||||
|
fileType.setId( "foo" );
|
||||||
|
fileType.setPatterns( Arrays.asList( "foo", "bar" ) );
|
||||||
|
getArchivaAdministrationService().addFileType( fileType );
|
||||||
|
assertEquals( initialSize + 1,
|
||||||
|
getArchivaAdministrationService().getRepositoryScanning().getFileTypes().size() );
|
||||||
|
|
||||||
|
assertNotNull( getArchivaAdministrationService().getFileType( "foo" ) );
|
||||||
|
assertEquals( Arrays.asList( "foo", "bar" ),
|
||||||
|
getArchivaAdministrationService().getFileType( "foo" ).getPatterns() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue