add unit test

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1447168 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-18 09:30:00 +00:00
parent 28acc7ec3a
commit e807e6d869
4 changed files with 22 additions and 5 deletions

View File

@ -400,4 +400,9 @@ public class TestRBACManager implements RBACManager
{ {
//To change body of implemented methods use File | Settings | File Templates. //To change body of implemented methods use File | Settings | File Templates.
} }
public boolean isReadOnly()
{
return false;
}
} }

View File

@ -92,7 +92,7 @@ public class AbstractImplementationInformation
{ {
return true; return true;
} }
if ( !( o instanceof UserManagerImplementationInformation ) ) if ( !( o instanceof AbstractImplementationInformation ) )
{ {
return false; return false;
} }

View File

@ -216,13 +216,13 @@ public class DefaultRedbackRuntimeConfigurationService
for ( Map.Entry<String, RBACManager> entry : beans.entrySet() ) for ( Map.Entry<String, RBACManager> entry : beans.entrySet() )
{ {
UserManager userManager = applicationContext.getBean( entry.getKey(), UserManager.class ); RBACManager rbacManager = applicationContext.getBean( entry.getKey(), RBACManager.class );
if ( userManager.isFinalImplementation() ) if ( rbacManager.isFinalImplementation() )
{ {
RBACManagerImplementationInformation information = new RBACManagerImplementationInformation(); RBACManagerImplementationInformation information = new RBACManagerImplementationInformation();
information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) ); information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) );
information.setDescriptionKey( userManager.getDescriptionKey() ); information.setDescriptionKey( rbacManager.getDescriptionKey() );
information.setReadOnly( userManager.isReadOnly() ); information.setReadOnly( rbacManager.isReadOnly() );
informations.add( information ); informations.add( information );
} }
} }

View File

@ -19,6 +19,7 @@ package org.apache.archiva.rest.services;
*/ */
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation;
import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService; import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
import org.fest.assertions.api.Assertions; import org.fest.assertions.api.Assertions;
@ -71,4 +72,15 @@ public class ArchivaRuntimeConfigurationServiceTest
} }
@Test
public void rbacmanagersinformations()
throws Exception
{
RedbackRuntimeConfigurationService service = getArchivaRuntimeConfigurationService();
List<RBACManagerImplementationInformation> infos = service.getRbacManagerImplementationInformations();
Assertions.assertThat( infos ).isNotNull().isNotEmpty().contains(
new RBACManagerImplementationInformation( "jdo", null, false ) );
}
} }