package fr.openwide.maven.artifact.notifier.core.test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import fr.openwide.core.jpa.exception.SecurityServiceException; import fr.openwide.core.jpa.exception.ServiceException; import fr.openwide.core.jpa.junit.AbstractTestCase; import fr.openwide.core.jpa.security.business.authority.model.Authority; import fr.openwide.core.jpa.security.business.authority.service.IAuthorityService; import fr.openwide.core.jpa.security.business.authority.util.CoreAuthorityConstants; import fr.openwide.core.spring.property.dao.IMutablePropertyDao; import fr.openwide.maven.artifact.notifier.core.business.user.service.IUserGroupService; import fr.openwide.maven.artifact.notifier.core.business.user.service.IUserService; import fr.openwide.maven.artifact.notifier.core.test.config.spring.MavenArtifactNotifierCoreTestCommonConfig; @ContextConfiguration(classes = MavenArtifactNotifierCoreTestCommonConfig.class) public abstract class AbstractMavenArtifactNotifierTestCase extends AbstractTestCase { @Autowired protected IUserService userService; @Autowired protected IUserGroupService userGroupService; @Autowired protected IAuthorityService authorityService; @Autowired private IMutablePropertyDao mutablePropertyDao; @Override public void init() throws ServiceException, SecurityServiceException { super.init(); initAuthorities(); } @Override protected void cleanAll() throws ServiceException, SecurityServiceException { mutablePropertyDao.cleanInTransaction(); cleanEntities(userService); cleanEntities(userGroupService); cleanEntities(authorityService); } private void initAuthorities() throws ServiceException, SecurityServiceException { authorityService.create(new Authority(CoreAuthorityConstants.ROLE_AUTHENTICATED)); } }