From 667064686cf05fad9ea49461cc0e543455d7d8ff Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 13 Sep 2011 12:56:02 +0000 Subject: [PATCH] fix unit test due to refactoring git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170160 13f79535-47bb-0310-9956-ffa450edef68 --- .../repositories/DeleteRepositoryGroupAction.java | 10 ++++++++++ .../DeleteRepositoryGroupActionTest.java | 13 +++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java index 4f2f7c78a..22e6ed154 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupAction.java @@ -108,4 +108,14 @@ public class DeleteRepositoryGroupAction { this.repoGroupId = repoGroupId; } + + public RepositoryGroupAdmin getRepositoryGroupAdmin() + { + return repositoryGroupAdmin; + } + + public void setRepositoryGroupAdmin( RepositoryGroupAdmin repositoryGroupAdmin ) + { + this.repositoryGroupAdmin = repositoryGroupAdmin; + } } diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java index 239f25fc2..e83c8d099 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/DeleteRepositoryGroupActionTest.java @@ -22,6 +22,7 @@ package org.apache.maven.archiva.web.action.admin.repositories; import com.opensymphony.xwork2.Action; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.group.RepositoryGroup; +import org.apache.archiva.admin.repository.group.DefaultRepositoryGroupAdmin; import org.apache.maven.archiva.configuration.ArchivaConfiguration; import org.apache.maven.archiva.configuration.Configuration; import org.apache.maven.archiva.configuration.RepositoryGroupConfiguration; @@ -51,12 +52,14 @@ public class DeleteRepositoryGroupActionTest { super.setUp(); - //action = (DeleteRepositoryGroupAction) lookup ( Action.class.getName(), "deleteRepositoryGroupAction" ); action = (DeleteRepositoryGroupAction) getActionProxy( "/admin/deleteRepositoryGroup.action" ).getAction(); archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class ); archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock(); action.setArchivaConfiguration( archivaConfiguration ); + + ( (DefaultRepositoryGroupAdmin) action.getRepositoryGroupAdmin() ).setArchivaConfiguration( + archivaConfiguration ); } public void testSecureActionBundle() @@ -98,7 +101,7 @@ public class DeleteRepositoryGroupActionTest Configuration configuration = createConfigurationForEditing( createRepositoryGroup() ); archivaConfiguration.getConfiguration(); - archivaConfigurationControl.setReturnValue( configuration, 3 ); + archivaConfigurationControl.setReturnValue( configuration, 5 ); archivaConfiguration.save( configuration ); archivaConfigurationControl.replay(); @@ -108,7 +111,8 @@ public class DeleteRepositoryGroupActionTest assertEquals( REPO_GROUP_ID, action.getRepoGroupId() ); RepositoryGroup repoGroup = action.getRepositoryGroup(); assertNotNull( repoGroup ); - assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); + assertEquals( Collections.singletonList( repoGroup ), + action.getRepositoryGroupAdmin().getRepositoriesGroups() ); String status = action.delete(); assertEquals( Action.SUCCESS, status ); @@ -136,7 +140,8 @@ public class DeleteRepositoryGroupActionTest String status = action.execute(); assertEquals( Action.SUCCESS, status ); - assertEquals( Collections.singletonList( repoGroup ), configuration.getRepositoryGroups() ); + assertEquals( Collections.singletonList( repoGroup ), + action.getRepositoryGroupAdmin().getRepositoriesGroups() ); } private Configuration createConfigurationForEditing( RepositoryGroupConfiguration repoGroup ) -- 2.39.5