package com.blueland.ebpm.engine;

import org.activiti.engine.*;
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
public abstract class BaseWfServiceTest //extends AbstractTransactionalJUnit4SpringContextTests  {  
extends AbstractJUnit4SpringContextTests  {  
	  

    @SuppressWarnings("unused")  
    @Autowired
    protected ProcessEngineConfigurationImpl processEngineConfiguration;
    @Autowired  
    protected ProcessEngine processEngine;

    @Autowired  
    protected RepositoryService repositoryService;  
    @Autowired  
    protected RuntimeService runtimeService;  
    @Autowired  
    protected TaskService taskService;  
    @Autowired  
    protected HistoryService historyService;  
    
    @Autowired  
    protected IdentityService identityService;  
    
    @Autowired  
    protected ManagementService managementService;  
      
    protected String deploymentId;  
      
    public BaseWfServiceTest() {  
        super();  
    }  
      
    @Before  
    public void initialize() throws Exception {  
        beforeTest();  
    }  
      
    @After  
    public void clean() throws Exception {  
        afterTest();  
    }  
      
    protected  void beforeTest() throws Exception{
    	
    }
      
    protected  void afterTest() throws Exception{
    	
    }

	
	/*public void setUp() throws Exception {
		if (identityService.createUserQuery().userId("fozzie").singleResult() == null) {
			identityService.saveUser(identityService.newUser("fozzie"));
		}
		if (identityService.createUserQuery().userId("kermit").singleResult() == null) {
			identityService.saveUser(identityService.newUser("kermit"));
		}
		if (identityService.createUserQuery().userId("gonzo").singleResult() == null) {
			identityService.saveUser(identityService.newUser("gonzo"));
		}

		if (identityService.createGroupQuery().groupId("accountancy")
				.singleResult() == null) {
			identityService.saveGroup(identityService.newGroup("accountancy"));
		}
		if (identityService.createGroupQuery().groupId("management")
				.singleResult() == null) {
			identityService.saveGroup(identityService.newGroup("management"));
		}

		User user1 = identityService.createUserQuery()
				.memberOfGroup("management").singleResult();
		if (user1 == null || !"kermit".equals(user1.getId())) {
			identityService.createMembership("kermit", "management");
		}
		User user2 = identityService.createUserQuery()
				.memberOfGroup("accountancy").singleResult();
		if (user2 == null || !"fozzie".equals(user2.getId())) {
			identityService.createMembership("fozzie", "accountancy");
		}
		
	}

	public void tearDown() throws Exception {
		identityService.deleteUser("fozzie");
		identityService.deleteUser("kermit");
		identityService.deleteUser("gonzo");
		identityService.deleteGroup("accountancy");
		identityService.deleteGroup("management");
		identityService.deleteMembership("fozzie", "accountancy");
		identityService.deleteMembership("kermit", "management");
	}*/
	

}
